Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id B3DEEE00BAF; Mon, 28 Nov 2016 05:40:54 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [185.38.181.35 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from smtp-out11.electric.net (smtp-out11.electric.net [185.38.181.35]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id ADE94E00AAB for ; Mon, 28 Nov 2016 05:40:51 -0800 (PST) Received: from 1cBMAr-0000Lv-UG by out11d.electric.net with emc1-ok (Exim 4.87) (envelope-from ) id 1cBMAr-0000Mj-VW for meta-freescale@yoctoproject.org; Mon, 28 Nov 2016 05:40:49 -0800 Received: by emcmailer; Mon, 28 Nov 2016 05:40:49 -0800 Received: from [192.36.1.72] (helo=mx-3.enea.com) by out11d.electric.net with esmtps (TLSv1:AES128-SHA:128) (Exim 4.87) (envelope-from ) id 1cBMAr-0000Lv-UG for meta-freescale@yoctoproject.org; Mon, 28 Nov 2016 05:40:49 -0800 Received: from sestofb10.enea.se (172.21.3.145) by smtp.enea.com (172.21.1.208) with Microsoft SMTP Server id 14.3.294.0; Mon, 28 Nov 2016 14:40:49 +0100 From: Sona Sarmadi To: Date: Mon, 28 Nov 2016 14:40:49 +0100 Message-ID: <1480340449-35552-1-git-send-email-sona.sarmadi@enea.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Received-SPF: None (SESTOEX08.enea.se: sona.sarmadi@enea.com does not designate permitted sender hosts) X-Outbound-IP: 192.36.1.72 X-Env-From: sona.sarmadi@enea.com X-Proto: esmtps X-Revdns: mx-3.enea.com X-HELO: mx-3.enea.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 6551647 X-Virus-Status: Scanned by VirusSMART (c) X-Virus-Status: Scanned by VirusSMART (s) Subject: [meta-fsl-ppc krogoth][PATCH] kernel: CVE-2016-0758 X-BeenThere: meta-freescale@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Usage and development list for the meta-fsl-* layers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2016 13:40:54 -0000 Content-Type: text/plain Fixes a flaw in the Linux kernel's ASN.1 DER decoder processed certain certificate files with tags of indefinite length. A local, unprivileged user could use a specially crafted X.509 certificate DER file to crash the system or, potentially, escalate their privileges on the system. References: https://lkml.org/lkml/2016/5/12/270 Upstream fix: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/patch/?id=012d81589afb85807b7ebe72f3505d90f34aa265 Signed-off-by: Sona Sarmadi --- recipes-kernel/linux/files/CVE-2016-0758.patch | 98 ++++++++++++++++++++++++++ recipes-kernel/linux/linux-qoriq_3.12.bb | 1 + 2 files changed, 99 insertions(+) create mode 100644 recipes-kernel/linux/files/CVE-2016-0758.patch diff --git a/recipes-kernel/linux/files/CVE-2016-0758.patch b/recipes-kernel/linux/files/CVE-2016-0758.patch new file mode 100644 index 0000000..5e444f4 --- /dev/null +++ b/recipes-kernel/linux/files/CVE-2016-0758.patch @@ -0,0 +1,98 @@ +From 012d81589afb85807b7ebe72f3505d90f34aa265 Mon Sep 17 00:00:00 2001 +From: David Howells +Date: Tue, 23 Feb 2016 11:03:12 +0000 +Subject: KEYS: Fix ASN.1 indefinite length object parsing + +commit 23c8a812dc3c621009e4f0e5342aa4e2ede1ceaa upstream. + +This fixes CVE-2016-0758. + +In the ASN.1 decoder, when the length field of an ASN.1 value is extracted, +it isn't validated against the remaining amount of data before being added +to the cursor. With a sufficiently large size indicated, the check: + + datalen - dp < 2 + +may then fail due to integer overflow. + +Fix this by checking the length indicated against the amount of remaining +data in both places a definite length is determined. + +Whilst we're at it, make the following changes: + + (1) Check the maximum size of extended length does not exceed the capacity + of the variable it's being stored in (len) rather than the type that + variable is assumed to be (size_t). + + (2) Compare the EOC tag to the symbolic constant ASN1_EOC rather than the + integer 0. + + (3) To reduce confusion, move the initialisation of len outside of: + + for (len = 0; n > 0; n--) { + + since it doesn't have anything to do with the loop counter n. + +CVE: CVE-2016-0758. +Upstream-Status: Backport + +Signed-off-by: David Howells +Reviewed-by: Mimi Zohar +Acked-by: David Woodhouse +Acked-by: Peter Jones +Signed-off-by: Jiri Slaby +Signed-off-by: Sona Sarmadi +--- + lib/asn1_decoder.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c +index 3787d02..b1c8852 100644 +--- a/lib/asn1_decoder.c ++++ b/lib/asn1_decoder.c +@@ -69,7 +69,7 @@ next_tag: + + /* Extract a tag from the data */ + tag = data[dp++]; +- if (tag == 0) { ++ if (tag == ASN1_EOC) { + /* It appears to be an EOC. */ + if (data[dp++] != 0) + goto invalid_eoc; +@@ -91,10 +91,8 @@ next_tag: + + /* Extract the length */ + len = data[dp++]; +- if (len <= 0x7f) { +- dp += len; +- goto next_tag; +- } ++ if (len <= 0x7f) ++ goto check_length; + + if (unlikely(len == ASN1_INDEFINITE_LENGTH)) { + /* Indefinite length */ +@@ -105,14 +103,18 @@ next_tag: + } + + n = len - 0x80; +- if (unlikely(n > sizeof(size_t) - 1)) ++ if (unlikely(n > sizeof(len) - 1)) + goto length_too_long; + if (unlikely(n > datalen - dp)) + goto data_overrun_error; +- for (len = 0; n > 0; n--) { ++ len = 0; ++ for (; n > 0; n--) { + len <<= 8; + len |= data[dp++]; + } ++check_length: ++ if (len > datalen - dp) ++ goto data_overrun_error; + dp += len; + goto next_tag; + +-- +cgit v0.12 + diff --git a/recipes-kernel/linux/linux-qoriq_3.12.bb b/recipes-kernel/linux/linux-qoriq_3.12.bb index f78186d..a9c046b 100644 --- a/recipes-kernel/linux/linux-qoriq_3.12.bb +++ b/recipes-kernel/linux/linux-qoriq_3.12.bb @@ -9,5 +9,6 @@ SRC_URI = "git://git.freescale.com/ppc/sdk/linux.git;branch=sdk-v1.9.x \ file://CVE-2015-8767.patch \ file://CVE-2015-8816.patch \ file://CVE-2015-2053.patch \ + file://CVE-2016-0758.patch \ " SRCREV = "43cecda943a6c40a833b588801b0929e8bd48813" -- 1.9.1