diff options
author | Sona Sarmadi <sona.sarmadi@enea.com> | 2015-01-27 09:09:30 +0100 |
---|---|---|
committer | Zhenhua Luo <zhenhua.luo@freescale.com> | 2015-02-03 10:03:53 +0800 |
commit | 42590aa5fb3ae3212c7950f2c71fcf7b3b19ecde (patch) | |
tree | d52fd0bdf242a28db4386c98b0cb9f9a0eb6a0f2 /meta-fsl-ppc/recipes-kernel | |
parent | d59902329c7554727bfd0456891fbc6807021864 (diff) | |
download | meta-freescale-42590aa5fb3ae3212c7950f2c71fcf7b3b19ecde.tar.gz |
net-sctp: CVE-2014-0101
Fixes null pointer dereference when processing authenticated cookie_echo chunk
Reference:
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0101
https://bugzilla.redhat.com/show_bug.cgi?id=1070705
Introduced by:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=bbd0d59809f9
Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
Diffstat (limited to 'meta-fsl-ppc/recipes-kernel')
-rw-r--r-- | meta-fsl-ppc/recipes-kernel/linux/files/net-sctp-CVE-2014-0101.patch | 145 | ||||
-rw-r--r-- | meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb | 1 |
2 files changed, 146 insertions, 0 deletions
diff --git a/meta-fsl-ppc/recipes-kernel/linux/files/net-sctp-CVE-2014-0101.patch b/meta-fsl-ppc/recipes-kernel/linux/files/net-sctp-CVE-2014-0101.patch new file mode 100644 index 00000000..6fc5610e --- /dev/null +++ b/meta-fsl-ppc/recipes-kernel/linux/files/net-sctp-CVE-2014-0101.patch | |||
@@ -0,0 +1,145 @@ | |||
1 | From 00c53b02cb01976b35d37670a4b5c5d7a6ad3c62 Mon Sep 17 00:00:00 2001 | ||
2 | From: Daniel Borkmann <dborkman@redhat.com> | ||
3 | Date: Mon, 3 Mar 2014 17:23:04 +0100 | ||
4 | Subject: [PATCH] net: sctp: fix sctp_sf_do_5_1D_ce to verify if we/peer is | ||
5 | AUTH capable | ||
6 | |||
7 | [ Upstream commit ec0223ec48a90cb605244b45f7c62de856403729 ] | ||
8 | |||
9 | RFC4895 introduced AUTH chunks for SCTP; during the SCTP | ||
10 | handshake RANDOM; CHUNKS; HMAC-ALGO are negotiated (CHUNKS | ||
11 | being optional though): | ||
12 | |||
13 | ---------- INIT[RANDOM; CHUNKS; HMAC-ALGO] ----------> | ||
14 | <------- INIT-ACK[RANDOM; CHUNKS; HMAC-ALGO] --------- | ||
15 | -------------------- COOKIE-ECHO --------------------> | ||
16 | <-------------------- COOKIE-ACK --------------------- | ||
17 | |||
18 | A special case is when an endpoint requires COOKIE-ECHO | ||
19 | chunks to be authenticated: | ||
20 | |||
21 | ---------- INIT[RANDOM; CHUNKS; HMAC-ALGO] ----------> | ||
22 | <------- INIT-ACK[RANDOM; CHUNKS; HMAC-ALGO] --------- | ||
23 | ------------------ AUTH; COOKIE-ECHO ----------------> | ||
24 | <-------------------- COOKIE-ACK --------------------- | ||
25 | |||
26 | RFC4895, section 6.3. Receiving Authenticated Chunks says: | ||
27 | |||
28 | The receiver MUST use the HMAC algorithm indicated in | ||
29 | the HMAC Identifier field. If this algorithm was not | ||
30 | specified by the receiver in the HMAC-ALGO parameter in | ||
31 | the INIT or INIT-ACK chunk during association setup, the | ||
32 | AUTH chunk and all the chunks after it MUST be discarded | ||
33 | and an ERROR chunk SHOULD be sent with the error cause | ||
34 | defined in Section 4.1. [...] If no endpoint pair shared | ||
35 | key has been configured for that Shared Key Identifier, | ||
36 | all authenticated chunks MUST be silently discarded. [...] | ||
37 | |||
38 | When an endpoint requires COOKIE-ECHO chunks to be | ||
39 | authenticated, some special procedures have to be followed | ||
40 | because the reception of a COOKIE-ECHO chunk might result | ||
41 | in the creation of an SCTP association. If a packet arrives | ||
42 | containing an AUTH chunk as a first chunk, a COOKIE-ECHO | ||
43 | chunk as the second chunk, and possibly more chunks after | ||
44 | them, and the receiver does not have an STCB for that | ||
45 | packet, then authentication is based on the contents of | ||
46 | the COOKIE-ECHO chunk. In this situation, the receiver MUST | ||
47 | authenticate the chunks in the packet by using the RANDOM | ||
48 | parameters, CHUNKS parameters and HMAC_ALGO parameters | ||
49 | obtained from the COOKIE-ECHO chunk, and possibly a local | ||
50 | shared secret as inputs to the authentication procedure | ||
51 | specified in Section 6.3. If authentication fails, then | ||
52 | the packet is discarded. If the authentication is successful, | ||
53 | the COOKIE-ECHO and all the chunks after the COOKIE-ECHO | ||
54 | MUST be processed. If the receiver has an STCB, it MUST | ||
55 | process the AUTH chunk as described above using the STCB | ||
56 | from the existing association to authenticate the | ||
57 | COOKIE-ECHO chunk and all the chunks after it. [...] | ||
58 | |||
59 | Commit bbd0d59809f9 introduced the possibility to receive | ||
60 | and verification of AUTH chunk, including the edge case for | ||
61 | authenticated COOKIE-ECHO. On reception of COOKIE-ECHO, | ||
62 | the function sctp_sf_do_5_1D_ce() handles processing, | ||
63 | unpacks and creates a new association if it passed sanity | ||
64 | checks and also tests for authentication chunks being | ||
65 | present. After a new association has been processed, it | ||
66 | invokes sctp_process_init() on the new association and | ||
67 | walks through the parameter list it received from the INIT | ||
68 | chunk. It checks SCTP_PARAM_RANDOM, SCTP_PARAM_HMAC_ALGO | ||
69 | and SCTP_PARAM_CHUNKS, and copies them into asoc->peer | ||
70 | meta data (peer_random, peer_hmacs, peer_chunks) in case | ||
71 | sysctl -w net.sctp.auth_enable=1 is set. If in INIT's | ||
72 | SCTP_PARAM_SUPPORTED_EXT parameter SCTP_CID_AUTH is set, | ||
73 | peer_random != NULL and peer_hmacs != NULL the peer is to be | ||
74 | assumed asoc->peer.auth_capable=1, in any other case | ||
75 | asoc->peer.auth_capable=0. | ||
76 | |||
77 | Now, if in sctp_sf_do_5_1D_ce() chunk->auth_chunk is | ||
78 | available, we set up a fake auth chunk and pass that on to | ||
79 | sctp_sf_authenticate(), which at latest in | ||
80 | sctp_auth_calculate_hmac() reliably dereferences a NULL pointer | ||
81 | at position 0..0008 when setting up the crypto key in | ||
82 | crypto_hash_setkey() by using asoc->asoc_shared_key that is | ||
83 | NULL as condition key_id == asoc->active_key_id is true if | ||
84 | the AUTH chunk was injected correctly from remote. This | ||
85 | happens no matter what net.sctp.auth_enable sysctl says. | ||
86 | |||
87 | The fix is to check for net->sctp.auth_enable and for | ||
88 | asoc->peer.auth_capable before doing any operations like | ||
89 | sctp_sf_authenticate() as no key is activated in | ||
90 | sctp_auth_asoc_init_active_key() for each case. | ||
91 | |||
92 | Now as RFC4895 section 6.3 states that if the used HMAC-ALGO | ||
93 | passed from the INIT chunk was not used in the AUTH chunk, we | ||
94 | SHOULD send an error; however in this case it would be better | ||
95 | to just silently discard such a maliciously prepared handshake | ||
96 | as we didn't even receive a parameter at all. Also, as our | ||
97 | endpoint has no shared key configured, section 6.3 says that | ||
98 | MUST silently discard, which we are doing from now onwards. | ||
99 | |||
100 | Before calling sctp_sf_pdiscard(), we need not only to free | ||
101 | the association, but also the chunk->auth_chunk skb, as | ||
102 | commit bbd0d59809f9 created a skb clone in that case. | ||
103 | |||
104 | I have tested this locally by using netfilter's nfqueue and | ||
105 | re-injecting packets into the local stack after maliciously | ||
106 | modifying the INIT chunk (removing RANDOM; HMAC-ALGO param) | ||
107 | and the SCTP packet containing the COOKIE_ECHO (injecting | ||
108 | AUTH chunk before COOKIE_ECHO). Fixed with this patch applied. | ||
109 | |||
110 | This fixes CVE-2014-0101 | ||
111 | Upstream-Status: Backport | ||
112 | |||
113 | Fixes: bbd0d59809f9 ("[SCTP]: Implement the receive and verification of AUTH chunk") | ||
114 | Signed-off-by: Daniel Borkmann <dborkman@redhat.com> | ||
115 | Cc: Vlad Yasevich <yasevich@gmail.com> | ||
116 | Cc: Neil Horman <nhorman@tuxdriver.com> | ||
117 | Acked-by: Vlad Yasevich <vyasevich@gmail.com> | ||
118 | Signed-off-by: David S. Miller <davem@davemloft.net> | ||
119 | Signed-off-by: Jiri Slaby <jslaby@suse.cz> | ||
120 | Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com> | ||
121 | --- | ||
122 | net/sctp/sm_statefuns.c | 7 +++++++ | ||
123 | 1 file changed, 7 insertions(+) | ||
124 | |||
125 | diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c | ||
126 | index dfe3f36..56ebe71 100644 | ||
127 | --- a/net/sctp/sm_statefuns.c | ||
128 | +++ b/net/sctp/sm_statefuns.c | ||
129 | @@ -759,6 +759,13 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net, | ||
130 | struct sctp_chunk auth; | ||
131 | sctp_ierror_t ret; | ||
132 | |||
133 | + /* Make sure that we and the peer are AUTH capable */ | ||
134 | + if (!net->sctp.auth_enable || !new_asoc->peer.auth_capable) { | ||
135 | + kfree_skb(chunk->auth_chunk); | ||
136 | + sctp_association_free(new_asoc); | ||
137 | + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
138 | + } | ||
139 | + | ||
140 | /* set-up our fake chunk so that we can process it */ | ||
141 | auth.skb = chunk->auth_chunk; | ||
142 | auth.asoc = chunk->asoc; | ||
143 | -- | ||
144 | 1.9.1 | ||
145 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb b/meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb index 48a67c0d..874a3f2b 100644 --- a/meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb +++ b/meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb | |||
@@ -12,6 +12,7 @@ SRC_URI = "git://git.freescale.com/ppc/sdk/linux.git;nobranch=1 \ | |||
12 | file://0004-mnt-CVE-2014-5206_CVE-2014-5207.patch \ | 12 | file://0004-mnt-CVE-2014-5206_CVE-2014-5207.patch \ |
13 | file://0005-mnt-CVE-2014-5206_CVE-2014-5207.patch \ | 13 | file://0005-mnt-CVE-2014-5206_CVE-2014-5207.patch \ |
14 | file://udf-CVE-2014-6410.patch \ | 14 | file://udf-CVE-2014-6410.patch \ |
15 | file://net-sctp-CVE-2014-0101.patch \ | ||
15 | " | 16 | " |
16 | SRCREV = "6619b8b55796cdf0cec04b66a71288edd3057229" | 17 | SRCREV = "6619b8b55796cdf0cec04b66a71288edd3057229" |
17 | 18 | ||