summaryrefslogtreecommitdiffstats
path: root/recipes-kernel
diff options
context:
space:
mode:
authorSona Sarmadi <sona.sarmadi@enea.com>2016-11-30 13:17:38 +0100
committerOtavio Salvador <otavio@ossystems.com.br>2016-12-09 09:41:45 -0200
commita870befa7789197b0091cc18c9c5196a848a75c7 (patch)
tree94cdd5fc34930b8fe8d695d5446419b8ca95b264 /recipes-kernel
parent0d28c2bcf1a2081e45bbb81c5efdb7c5cb3a1532 (diff)
downloadmeta-freescale-a870befa7789197b0091cc18c9c5196a848a75c7.tar.gz
linux-qoriq: fix CVE-2016-2053
The asn1_ber_decoder function in lib/asn1_decoder.c in the Linux kernel before 4.3 allows attackers to cause a denial of service (panic) via an ASN.1 BER file that lacks a public key, leading to mishandling by the public_key_verify_signature function in crypto/asymmetric_keys/public_key.c. References: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-2053 upstream patch: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/ ?id=15430f775ee686b61569a0c3e74cf0b2ad57c8eb [backported from stable 3.16] Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'recipes-kernel')
-rw-r--r--recipes-kernel/linux/linux-qoriq/CVE-2016-2053.patch133
-rw-r--r--recipes-kernel/linux/linux-qoriq_4.1.bb1
2 files changed, 134 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-qoriq/CVE-2016-2053.patch b/recipes-kernel/linux/linux-qoriq/CVE-2016-2053.patch
new file mode 100644
index 00000000..778a99fd
--- /dev/null
+++ b/recipes-kernel/linux/linux-qoriq/CVE-2016-2053.patch
@@ -0,0 +1,133 @@
1From 15430f775ee686b61569a0c3e74cf0b2ad57c8eb Mon Sep 17 00:00:00 2001
2From: David Howells <dhowells@redhat.com>
3Date: Wed, 5 Aug 2015 12:54:46 +0100
4Subject: ASN.1: Fix non-match detection failure on data overrun
5
6commit 0d62e9dd6da45bbf0f33a8617afc5fe774c8f45f upstream.
7
8If the ASN.1 decoder is asked to parse a sequence of objects, non-optional
9matches get skipped if there's no more data to be had rather than a
10data-overrun error being reported.
11
12This is due to the code segment that decides whether to skip optional
13matches (ie. matches that could get ignored because an element is marked
14OPTIONAL in the grammar) due to a lack of data also skips non-optional
15elements if the data pointer has reached the end of the buffer.
16
17This can be tested with the data decoder for the new RSA akcipher algorithm
18that takes three non-optional integers. Currently, it skips the last
19integer if there is insufficient data.
20
21Without the fix, #defining DEBUG in asn1_decoder.c will show something
22like:
23
24 next_op: pc=0/13 dp=0/270 C=0 J=0
25 - match? 30 30 00
26 - TAG: 30 266 CONS
27 next_op: pc=2/13 dp=4/270 C=1 J=0
28 - match? 02 02 00
29 - TAG: 02 257
30 - LEAF: 257
31 next_op: pc=5/13 dp=265/270 C=1 J=0
32 - match? 02 02 00
33 - TAG: 02 3
34 - LEAF: 3
35 next_op: pc=8/13 dp=270/270 C=1 J=0
36 next_op: pc=11/13 dp=270/270 C=1 J=0
37 - end cons t=4 dp=270 l=270/270
38
39The next_op line for pc=8/13 should be followed by a match line.
40
41This is not exploitable for X.509 certificates by means of shortening the
42message and fixing up the ASN.1 CONS tags because:
43
44 (1) The relevant records being built up are cleared before use.
45
46 (2) If the message is shortened sufficiently to remove the public key, the
47 ASN.1 parse of the RSA key will fail quickly due to a lack of data.
48
49 (3) Extracted signature data is either turned into MPIs (which cope with a
50 0 length) or is simpler integers specifying algoritms and suchlike
51 (which can validly be 0); and
52
53 (4) The AKID and SKID extensions are optional and their removal is handled
54 without risking passing a NULL to asymmetric_key_generate_id().
55
56 (5) If the certificate is truncated sufficiently to remove the subject,
57 issuer or serialNumber then the ASN.1 decoder will fail with a 'Cons
58 stack underflow' return.
59
60This is not exploitable for PKCS#7 messages by means of removal of elements
61from such a message from the tail end of a sequence:
62
63 (1) Any shortened X.509 certs embedded in the PKCS#7 message are survivable
64 as detailed above.
65
66 (2) The message digest content isn't used if it shows a NULL pointer,
67 similarly, the authattrs aren't used if that shows a NULL pointer.
68
69 (3) A missing signature results in a NULL MPI - which the MPI routines deal
70 with.
71
72 (4) If data is NULL, it is expected that the message has detached content and
73 that is handled appropriately.
74
75 (5) If the serialNumber is excised, the unconditional action associated
76 with it will pick up the containing SEQUENCE instead, so no NULL
77 pointer will be seen here.
78
79 If both the issuer and the serialNumber are excised, the ASN.1 decode
80 will fail with an 'Unexpected tag' return.
81
82 In either case, there's no way to get to asymmetric_key_generate_id()
83 with a NULL pointer.
84
85 (6) Other fields are decoded to simple integers. Shortening the message
86 to omit an algorithm ID field will cause checks on this to fail early
87 in the verification process.
88
89This can also be tested by snipping objects off of the end of the ASN.1 stream
90such that mandatory tags are removed - or even from the end of internal
91SEQUENCEs. If any mandatory tag is missing, the error EBADMSG *should* be
92produced. Without this patch ERANGE or ENOPKG might be produced or the parse
93may apparently succeed, perhaps with ENOKEY or EKEYREJECTED being produced
94later, depending on what gets snipped.
95
96Just snipping off the final BIT_STRING or OCTET_STRING from either sample
97should be a start since both are mandatory and neither will cause an EBADMSG
98without the patches
99
100CVE: CVE-2016-2053
101Upstream-Status: Backport [kernel.org linux-stable 3.16 branch]
102
103Reported-by: Marcel Holtmann <marcel@holtmann.org>
104Signed-off-by: David Howells <dhowells@redhat.com>
105Tested-by: Marcel Holtmann <marcel@holtmann.org>
106Reviewed-by: David Woodhouse <David.Woodhouse@intel.com>
107Cc: Moritz Muehlenhoff <jmm@inutil.org>
108[ luis: backported to 3.16: adjusted context ]
109Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
110Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
111---
112 lib/asn1_decoder.c | 5 ++---
113 1 file changed, 2 insertions(+), 3 deletions(-)
114
115diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
116index 1a000bb..d60ce8a 100644
117--- a/lib/asn1_decoder.c
118+++ b/lib/asn1_decoder.c
119@@ -208,9 +208,8 @@ next_op:
120 unsigned char tmp;
121
122 /* Skip conditional matches if possible */
123- if ((op & ASN1_OP_MATCH__COND &&
124- flags & FLAG_MATCHED) ||
125- dp == datalen) {
126+ if ((op & ASN1_OP_MATCH__COND && flags & FLAG_MATCHED) ||
127+ (op & ASN1_OP_MATCH__SKIP && dp == datalen)) {
128 pc += asn1_op_lengths[op];
129 goto next_op;
130 }
131--
132cgit v0.12
133
diff --git a/recipes-kernel/linux/linux-qoriq_4.1.bb b/recipes-kernel/linux/linux-qoriq_4.1.bb
index b5a67e64..ac0f25fe 100644
--- a/recipes-kernel/linux/linux-qoriq_4.1.bb
+++ b/recipes-kernel/linux/linux-qoriq_4.1.bb
@@ -15,6 +15,7 @@ SRC_URI = "git://git.freescale.com/ppc/sdk/linux.git;nobranch=1 \
15 file://powerpc-fsl-Fix-build-of-the-dtb-embedded-kernel-images.patch \ 15 file://powerpc-fsl-Fix-build-of-the-dtb-embedded-kernel-images.patch \
16 file://CVE-2016-5696-limiting-of-all-challenge.patch \ 16 file://CVE-2016-5696-limiting-of-all-challenge.patch \
17 file://CVE-2016-5696-make-challenge-acks-less-predictable.patch \ 17 file://CVE-2016-5696-make-challenge-acks-less-predictable.patch \
18 file://CVE-2016-2053.patch \
18" 19"
19SRCREV = "667e6ba9ca2150b3cabdd0c07b57d1b88ef3b86a" 20SRCREV = "667e6ba9ca2150b3cabdd0c07b57d1b88ef3b86a"
20 21