[linux] 07/10: net: ping: check minimum size on ICMP header length (CVE-2016-8399)

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Wed Dec 28 20:44:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch wheezy-security
in repository linux.

commit 9022b9a87d01106945f105a2a5028c0d0bf0460e
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Wed Dec 28 16:58:13 2016 +0000

    net: ping: check minimum size on ICMP header length (CVE-2016-8399)
---
 debian/changelog                                   |  1 +
 ...-check-minimum-size-on-icmp-header-length.patch | 68 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 70 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 61fce58..bc16b55 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -108,6 +108,7 @@ linux (3.2.84-1) UNRELEASED; urgency=medium
   * tty: Prevent ldisc drivers from re-using stale tty fields (CVE-2015-8964)
   * block: fix use-after-free in sys_ioprio_get() (CVE-2016-7911)
   * HID: core: prevent out-of-bound readings (CVE-2016-7915)
+  * net: ping: check minimum size on ICMP header length (CVE-2016-8399)
 
  -- Ben Hutchings <ben at decadent.org.uk>  Mon, 28 Nov 2016 18:43:52 +0000
 
diff --git a/debian/patches/bugfix/all/net-ping-check-minimum-size-on-icmp-header-length.patch b/debian/patches/bugfix/all/net-ping-check-minimum-size-on-icmp-header-length.patch
new file mode 100644
index 0000000..cf36baa
--- /dev/null
+++ b/debian/patches/bugfix/all/net-ping-check-minimum-size-on-icmp-header-length.patch
@@ -0,0 +1,68 @@
+From: Kees Cook <keescook at chromium.org>
+Date: Mon, 5 Dec 2016 10:34:38 -0800
+Subject: net: ping: check minimum size on ICMP header length
+Origin: https://git.kernel.org/linus/0eab121ef8750a5c8637d51534d5e9143fb0633f
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2016-8399
+
+Prior to commit c0371da6047a ("put iov_iter into msghdr") in v3.19, there
+was no check that the iovec contained enough bytes for an ICMP header,
+and the read loop would walk across neighboring stack contents. Since the
+iov_iter conversion, bad arguments are noticed, but the returned error is
+EFAULT. Returning EINVAL is a clearer error and also solves the problem
+prior to v3.19.
+
+This was found using trinity with KASAN on v3.18:
+
+BUG: KASAN: stack-out-of-bounds in memcpy_fromiovec+0x60/0x114 at addr ffffffc071077da0
+Read of size 8 by task trinity-c2/9623
+page:ffffffbe034b9a08 count:0 mapcount:0 mapping:          (null) index:0x0
+flags: 0x0()
+page dumped because: kasan: bad access detected
+CPU: 0 PID: 9623 Comm: trinity-c2 Tainted: G    BU         3.18.0-dirty #15
+Hardware name: Google Tegra210 Smaug Rev 1,3+ (DT)
+Call trace:
+[<ffffffc000209c98>] dump_backtrace+0x0/0x1ac arch/arm64/kernel/traps.c:90
+[<ffffffc000209e54>] show_stack+0x10/0x1c arch/arm64/kernel/traps.c:171
+[<     inline     >] __dump_stack lib/dump_stack.c:15
+[<ffffffc000f18dc4>] dump_stack+0x7c/0xd0 lib/dump_stack.c:50
+[<     inline     >] print_address_description mm/kasan/report.c:147
+[<     inline     >] kasan_report_error mm/kasan/report.c:236
+[<ffffffc000373dcc>] kasan_report+0x380/0x4b8 mm/kasan/report.c:259
+[<     inline     >] check_memory_region mm/kasan/kasan.c:264
+[<ffffffc00037352c>] __asan_load8+0x20/0x70 mm/kasan/kasan.c:507
+[<ffffffc0005b9624>] memcpy_fromiovec+0x5c/0x114 lib/iovec.c:15
+[<     inline     >] memcpy_from_msg include/linux/skbuff.h:2667
+[<ffffffc000ddeba0>] ping_common_sendmsg+0x50/0x108 net/ipv4/ping.c:674
+[<ffffffc000dded30>] ping_v4_sendmsg+0xd8/0x698 net/ipv4/ping.c:714
+[<ffffffc000dc91dc>] inet_sendmsg+0xe0/0x12c net/ipv4/af_inet.c:749
+[<     inline     >] __sock_sendmsg_nosec net/socket.c:624
+[<     inline     >] __sock_sendmsg net/socket.c:632
+[<ffffffc000cab61c>] sock_sendmsg+0x124/0x164 net/socket.c:643
+[<     inline     >] SYSC_sendto net/socket.c:1797
+[<ffffffc000cad270>] SyS_sendto+0x178/0x1d8 net/socket.c:1761
+
+CVE-2016-8399
+
+Reported-by: Qidan He <i at flanker017.me>
+Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
+Cc: stable at vger.kernel.org
+Signed-off-by: Kees Cook <keescook at chromium.org>
+Signed-off-by: David S. Miller <davem at davemloft.net>
+[bwh: Backported to 3.2: only ICMPv4 is supported]
+---
+ net/ipv4/ping.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/net/ipv4/ping.c
++++ b/net/ipv4/ping.c
+@@ -482,6 +482,10 @@ static int ping_sendmsg(struct kiocb *io
+ 	if (len > 0xFFFF)
+ 		return -EMSGSIZE;
+ 
++	/* Must have at least a full ICMP header. */
++	if (len < sizeof(struct icmphdr))
++		return -EINVAL;
++
+ 	/*
+ 	 *	Check the flags.
+ 	 */
diff --git a/debian/patches/series b/debian/patches/series
index b2b1ec6..e5625e4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1113,6 +1113,7 @@ bugfix/all/isdn-gigaset-reset-tty-receive_room-when-attaching-s.patch
 bugfix/all/tty-prevent-ldisc-drivers-from-re-using-stale-tty-fi.patch
 bugfix/all/block-fix-use-after-free-in-sys_ioprio_get.patch
 bugfix/all/hid-core-prevent-out-of-bound-readings.patch
+bugfix/all/net-ping-check-minimum-size-on-icmp-header-length.patch
 
 # ABI maintenance
 debian/perf-hide-abi-change-in-3.2.30.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list