[linux] 01/10: Fix CVE-2012-6704 and avoid CVE-2016-9793

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 ad38f0b64b518e611aa70ea410883bb79a932199
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Wed Dec 28 15:51:41 2016 +0000

    Fix CVE-2012-6704 and avoid CVE-2016-9793
    
    The first change accidentally fixes CVE-2012-6704 and introduces
    CVE-2016-9793, so we need to deal with both together.
---
 debian/changelog                                   |  2 +
 ...signed-overflows-for-so_-snd-rcv-bufforce.patch | 45 ++++++++++
 .../all/net-cleanups-in-sock_setsockopt.patch      | 96 ++++++++++++++++++++++
 debian/patches/series                              |  2 +
 4 files changed, 145 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 94bc2b7..1d4a7d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -100,6 +100,8 @@ linux (3.2.84-1) UNRELEASED; urgency=medium
   * [rt] Update to 3.2.83-rt121:
     - genirq: Fix pointer cast warning for randomness on 32-bit architectures
     - work-simple: Add missing #include <linux/export.h>
+  * net: cleanups in sock_setsockopt() (CVE-2012-6704)
+  * net: avoid signed overflows for SO_{SND|RCV}BUFFORCE (CVE-2016-9793)
 
  -- Ben Hutchings <ben at decadent.org.uk>  Mon, 28 Nov 2016 18:43:52 +0000
 
diff --git a/debian/patches/bugfix/all/net-avoid-signed-overflows-for-so_-snd-rcv-bufforce.patch b/debian/patches/bugfix/all/net-avoid-signed-overflows-for-so_-snd-rcv-bufforce.patch
new file mode 100644
index 0000000..c883bcc
--- /dev/null
+++ b/debian/patches/bugfix/all/net-avoid-signed-overflows-for-so_-snd-rcv-bufforce.patch
@@ -0,0 +1,45 @@
+From: Eric Dumazet <edumazet at google.com>
+Date: Fri, 2 Dec 2016 09:44:53 -0800
+Subject: net: avoid signed overflows for SO_{SND|RCV}BUFFORCE
+Origin: https://git.kernel.org/linus/b98b0bc8c431e3ceb4b26b0dfc8db509518fb290
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2016-9793
+
+CAP_NET_ADMIN users should not be allowed to set negative
+sk_sndbuf or sk_rcvbuf values, as it can lead to various memory
+corruptions, crashes, OOM...
+
+Note that before commit 82981930125a ("net: cleanups in
+sock_setsockopt()"), the bug was even more serious, since SO_SNDBUF
+and SO_RCVBUF were vulnerable.
+
+This needs to be backported to all known linux kernels.
+
+Again, many thanks to syzkaller team for discovering this gem.
+
+Signed-off-by: Eric Dumazet <edumazet at google.com>
+Reported-by: Andrey Konovalov <andreyknvl at google.com>
+Signed-off-by: David S. Miller <davem at davemloft.net>
+---
+ net/core/sock.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/net/core/sock.c
++++ b/net/core/sock.c
+@@ -533,7 +533,7 @@ int sock_setsockopt(struct socket *sock,
+ 		val = min_t(u32, val, sysctl_wmem_max);
+ set_sndbuf:
+ 		sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
+-		sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF);
++		sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF);
+ 		/* Wake up sending tasks if we upped the value. */
+ 		sk->sk_write_space(sk);
+ 		break;
+@@ -569,7 +569,7 @@ set_rcvbuf:
+ 		 * returning the value we actually used in getsockopt
+ 		 * is the most desirable behavior.
+ 		 */
+-		sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF);
++		sk->sk_rcvbuf = max_t(int, val * 2, SOCK_MIN_RCVBUF);
+ 		break;
+ 
+ 	case SO_RCVBUFFORCE:
diff --git a/debian/patches/bugfix/all/net-cleanups-in-sock_setsockopt.patch b/debian/patches/bugfix/all/net-cleanups-in-sock_setsockopt.patch
new file mode 100644
index 0000000..2e1756d
--- /dev/null
+++ b/debian/patches/bugfix/all/net-cleanups-in-sock_setsockopt.patch
@@ -0,0 +1,96 @@
+From: Eric Dumazet <edumazet at google.com>
+Date: Thu, 26 Apr 2012 20:07:59 +0000
+Subject: net: cleanups in sock_setsockopt()
+Origin: https://git.kernel.org/linus/82981930125abfd39d7c8378a9cfdf5e1be2002b
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2012-6704
+
+Use min_t()/max_t() macros, reformat two comments, use !!test_bit() to
+match !!sock_flag()
+
+Signed-off-by: Eric Dumazet <edumazet at google.com>
+Signed-off-by: David S. Miller <davem at davemloft.net>
+---
+ net/core/sock.c | 42 +++++++++++++++---------------------------
+ 1 file changed, 15 insertions(+), 27 deletions(-)
+
+--- a/net/core/sock.c
++++ b/net/core/sock.c
+@@ -526,23 +526,15 @@ int sock_setsockopt(struct socket *sock,
+ 		break;
+ 	case SO_SNDBUF:
+ 		/* Don't error on this BSD doesn't and if you think
+-		   about it this is right. Otherwise apps have to
+-		   play 'guess the biggest size' games. RCVBUF/SNDBUF
+-		   are treated in BSD as hints */
+-
+-		if (val > sysctl_wmem_max)
+-			val = sysctl_wmem_max;
++		 * about it this is right. Otherwise apps have to
++		 * play 'guess the biggest size' games. RCVBUF/SNDBUF
++		 * are treated in BSD as hints
++		 */
++		val = min_t(u32, val, sysctl_wmem_max);
+ set_sndbuf:
+ 		sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
+-		if ((val * 2) < SOCK_MIN_SNDBUF)
+-			sk->sk_sndbuf = SOCK_MIN_SNDBUF;
+-		else
+-			sk->sk_sndbuf = val * 2;
+-
+-		/*
+-		 *	Wake up sending tasks if we
+-		 *	upped the value.
+-		 */
++		sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF);
++		/* Wake up sending tasks if we upped the value. */
+ 		sk->sk_write_space(sk);
+ 		break;
+ 
+@@ -555,12 +547,11 @@ set_sndbuf:
+ 
+ 	case SO_RCVBUF:
+ 		/* Don't error on this BSD doesn't and if you think
+-		   about it this is right. Otherwise apps have to
+-		   play 'guess the biggest size' games. RCVBUF/SNDBUF
+-		   are treated in BSD as hints */
+-
+-		if (val > sysctl_rmem_max)
+-			val = sysctl_rmem_max;
++		 * about it this is right. Otherwise apps have to
++		 * play 'guess the biggest size' games. RCVBUF/SNDBUF
++		 * are treated in BSD as hints
++		 */
++		val = min_t(u32, val, sysctl_rmem_max);
+ set_rcvbuf:
+ 		sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
+ 		/*
+@@ -578,10 +569,7 @@ set_rcvbuf:
+ 		 * returning the value we actually used in getsockopt
+ 		 * is the most desirable behavior.
+ 		 */
+-		if ((val * 2) < SOCK_MIN_RCVBUF)
+-			sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
+-		else
+-			sk->sk_rcvbuf = val * 2;
++		sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF);
+ 		break;
+ 
+ 	case SO_RCVBUFFORCE:
+@@ -923,7 +911,7 @@ int sock_getsockopt(struct socket *sock,
+ 		break;
+ 
+ 	case SO_PASSCRED:
+-		v.val = test_bit(SOCK_PASSCRED, &sock->flags) ? 1 : 0;
++		v.val = !!test_bit(SOCK_PASSCRED, &sock->flags);
+ 		break;
+ 
+ 	case SO_PEERCRED:
+@@ -958,7 +946,7 @@ int sock_getsockopt(struct socket *sock,
+ 		break;
+ 
+ 	case SO_PASSSEC:
+-		v.val = test_bit(SOCK_PASSSEC, &sock->flags) ? 1 : 0;
++		v.val = !!test_bit(SOCK_PASSSEC, &sock->flags);
+ 		break;
+ 
+ 	case SO_PEERSEC:
diff --git a/debian/patches/series b/debian/patches/series
index 90cd5bc..37d72db 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1105,6 +1105,8 @@ features/all/hpsa/0011-hpsa-add-in-P840ar-controller-model-name.patch
 bugfix/all/netfilter-ipset-Check-and-reject-crazy-0-input-param.patch
 bugfix/all/KEYS-Don-t-permit-request_key-to-construct-a-new-key.patch
 bugfix/all/ecryptfs-fix-handling-of-directory-opening.patch
+bugfix/all/net-cleanups-in-sock_setsockopt.patch
+bugfix/all/net-avoid-signed-overflows-for-so_-snd-rcv-bufforce.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