Fix CVE-2014-0038
This commit is contained in:
parent
61a419dc51
commit
f7d1116394
|
@ -0,0 +1,80 @@
|
||||||
|
From 2def2ef2ae5f3990aabdbe8a755911902707d268 Mon Sep 17 00:00:00 2001
|
||||||
|
From: PaX Team <pageexec@freemail.hu>
|
||||||
|
Date: Thu, 30 Jan 2014 16:59:25 -0800
|
||||||
|
Subject: [PATCH] x86, x32: Correct invalid use of user timespec in the kernel
|
||||||
|
|
||||||
|
The x32 case for the recvmsg() timout handling is broken:
|
||||||
|
|
||||||
|
asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
|
||||||
|
unsigned int vlen, unsigned int flags,
|
||||||
|
struct compat_timespec __user *timeout)
|
||||||
|
{
|
||||||
|
int datagrams;
|
||||||
|
struct timespec ktspec;
|
||||||
|
|
||||||
|
if (flags & MSG_CMSG_COMPAT)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (COMPAT_USE_64BIT_TIME)
|
||||||
|
return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
|
||||||
|
flags | MSG_CMSG_COMPAT,
|
||||||
|
(struct timespec *) timeout);
|
||||||
|
...
|
||||||
|
|
||||||
|
The timeout pointer parameter is provided by userland (hence the __user
|
||||||
|
annotation) but for x32 syscalls it's simply cast to a kernel pointer
|
||||||
|
and is passed to __sys_recvmmsg which will eventually directly
|
||||||
|
dereference it for both reading and writing. Other callers to
|
||||||
|
__sys_recvmmsg properly copy from userland to the kernel first.
|
||||||
|
|
||||||
|
The bug was introduced by commit ee4fa23c4bfc ("compat: Use
|
||||||
|
COMPAT_USE_64BIT_TIME in net/compat.c") and should affect all kernels
|
||||||
|
since 3.4 (and perhaps vendor kernels if they backported x32 support
|
||||||
|
along with this code).
|
||||||
|
|
||||||
|
Note that CONFIG_X86_X32_ABI gets enabled at build time and only if
|
||||||
|
CONFIG_X86_X32 is enabled and ld can build x32 executables.
|
||||||
|
|
||||||
|
Other uses of COMPAT_USE_64BIT_TIME seem fine.
|
||||||
|
|
||||||
|
This addresses CVE-2014-0038.
|
||||||
|
|
||||||
|
Signed-off-by: PaX Team <pageexec@freemail.hu>
|
||||||
|
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
||||||
|
Cc: <stable@vger.kernel.org> # v3.4+
|
||||||
|
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
|
---
|
||||||
|
net/compat.c | 9 ++-------
|
||||||
|
1 file changed, 2 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/net/compat.c b/net/compat.c
|
||||||
|
index dd32e34..f50161f 100644
|
||||||
|
--- a/net/compat.c
|
||||||
|
+++ b/net/compat.c
|
||||||
|
@@ -780,21 +780,16 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
|
||||||
|
if (flags & MSG_CMSG_COMPAT)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
- if (COMPAT_USE_64BIT_TIME)
|
||||||
|
- return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
|
||||||
|
- flags | MSG_CMSG_COMPAT,
|
||||||
|
- (struct timespec *) timeout);
|
||||||
|
-
|
||||||
|
if (timeout == NULL)
|
||||||
|
return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
|
||||||
|
flags | MSG_CMSG_COMPAT, NULL);
|
||||||
|
|
||||||
|
- if (get_compat_timespec(&ktspec, timeout))
|
||||||
|
+ if (compat_get_timespec(&ktspec, timeout))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
|
||||||
|
flags | MSG_CMSG_COMPAT, &ktspec);
|
||||||
|
- if (datagrams > 0 && put_compat_timespec(&ktspec, timeout))
|
||||||
|
+ if (datagrams > 0 && compat_put_timespec(&ktspec, timeout))
|
||||||
|
datagrams = -EFAULT;
|
||||||
|
|
||||||
|
return datagrams;
|
||||||
|
--
|
||||||
|
1.8.5.3
|
||||||
|
|
12
PKGBUILD
12
PKGBUILD
|
@ -5,7 +5,7 @@ pkgbase=linux # Build stock -ARCH kernel
|
||||||
#pkgbase=linux-custom # Build kernel with a different name
|
#pkgbase=linux-custom # Build kernel with a different name
|
||||||
_srcname=linux-3.13
|
_srcname=linux-3.13
|
||||||
pkgver=3.13.1
|
pkgver=3.13.1
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
url="http://www.kernel.org/"
|
url="http://www.kernel.org/"
|
||||||
license=('GPL2')
|
license=('GPL2')
|
||||||
|
@ -26,7 +26,9 @@ source=("http://www.kernel.org/pub/linux/kernel/v3.x/${_srcname}.tar.xz"
|
||||||
'0005-sunrpc-add-an-info-file-for-the-dummy-gssd-pipe.patch'
|
'0005-sunrpc-add-an-info-file-for-the-dummy-gssd-pipe.patch'
|
||||||
'0006-rpc_pipe-fix-cleanup-of-dummy-gssd-directory-when-no.patch'
|
'0006-rpc_pipe-fix-cleanup-of-dummy-gssd-directory-when-no.patch'
|
||||||
'0001-syscalls.h-use-gcc-alias-instead-of-assembler-aliase.patch'
|
'0001-syscalls.h-use-gcc-alias-instead-of-assembler-aliase.patch'
|
||||||
'i8042-fix-aliases.patch')
|
'i8042-fix-aliases.patch'
|
||||||
|
'0001-x86-x32-Correct-invalid-use-of-user-timespec-in-the-.patch'
|
||||||
|
)
|
||||||
md5sums=('0ecbaf65c00374eb4a826c2f9f37606f'
|
md5sums=('0ecbaf65c00374eb4a826c2f9f37606f'
|
||||||
'675692f24410f375055d422e7886f3d8'
|
'675692f24410f375055d422e7886f3d8'
|
||||||
'ba4468d313adfaf22368add7f58204aa'
|
'ba4468d313adfaf22368add7f58204aa'
|
||||||
|
@ -41,7 +43,8 @@ md5sums=('0ecbaf65c00374eb4a826c2f9f37606f'
|
||||||
'd5907a721b97299f0685c583499f7820'
|
'd5907a721b97299f0685c583499f7820'
|
||||||
'a724515b350b29c53f20e631c6cf9a14'
|
'a724515b350b29c53f20e631c6cf9a14'
|
||||||
'e6fa278c092ad83780e2dd0568e24ca6'
|
'e6fa278c092ad83780e2dd0568e24ca6'
|
||||||
'93dbf73af819b77f03453a9c6de2bb47')
|
'93dbf73af819b77f03453a9c6de2bb47'
|
||||||
|
'336d2c4afd7ee5f2bdf0dcb1a54df4b2')
|
||||||
|
|
||||||
_kernelname=${pkgbase#linux}
|
_kernelname=${pkgbase#linux}
|
||||||
|
|
||||||
|
@ -88,6 +91,9 @@ prepare() {
|
||||||
# Fix i8042 aliases
|
# Fix i8042 aliases
|
||||||
patch -p1 -i "${srcdir}/i8042-fix-aliases.patch"
|
patch -p1 -i "${srcdir}/i8042-fix-aliases.patch"
|
||||||
|
|
||||||
|
# Fix CVE-2014-0038
|
||||||
|
patch -p1 -i "${srcdir}/0001-x86-x32-Correct-invalid-use-of-user-timespec-in-the-.patch"
|
||||||
|
|
||||||
if [ "${CARCH}" = "x86_64" ]; then
|
if [ "${CARCH}" = "x86_64" ]; then
|
||||||
cat "${srcdir}/config.x86_64" > ./.config
|
cat "${srcdir}/config.x86_64" > ./.config
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue