[kernel] r16288 - in dists/lenny-security/linux-2.6/debian: . patches/bugfix/all patches/features/all/openvz patches/series

Dann Frazier dannf at alioth.debian.org
Thu Sep 16 04:41:14 UTC 2010


Author: dannf
Date: Thu Sep 16 04:41:07 2010
New Revision: 16288

Log:
compat: Make compat_alloc_user_space() incorporate the access_ok() (CVE-2010-3081)

Added:
   dists/lenny-security/linux-2.6/debian/patches/bugfix/all/compat-make-compat_alloc_user_space-incorporate-the_access_ok.patch
Modified:
   dists/lenny-security/linux-2.6/debian/changelog
   dists/lenny-security/linux-2.6/debian/patches/features/all/openvz/openvz.patch
   dists/lenny-security/linux-2.6/debian/patches/series/25lenny1

Modified: dists/lenny-security/linux-2.6/debian/changelog
==============================================================================
--- dists/lenny-security/linux-2.6/debian/changelog	Thu Sep 16 00:51:38 2010	(r16287)
+++ dists/lenny-security/linux-2.6/debian/changelog	Thu Sep 16 04:41:07 2010	(r16288)
@@ -2,6 +2,8 @@
 
   * irda: Correctly clean up self->ias_obj on irda_bind() failure.
     (CVE-2010-2954)
+  * compat: Make compat_alloc_user_space() incorporate the access_ok()
+    (CVE-2010-3081)
 
  -- dann frazier <dannf at debian.org>  Thu, 09 Sep 2010 19:11:27 -0600
 

Added: dists/lenny-security/linux-2.6/debian/patches/bugfix/all/compat-make-compat_alloc_user_space-incorporate-the_access_ok.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny-security/linux-2.6/debian/patches/bugfix/all/compat-make-compat_alloc_user_space-incorporate-the_access_ok.patch	Thu Sep 16 04:41:07 2010	(r16288)
@@ -0,0 +1,185 @@
+commit 95590fa4258743702d64cd89214013ec2a0537ee
+Author: H. Peter Anvin <hpa at linux.intel.com>
+Date:   Tue Sep 7 16:16:18 2010 -0700
+
+    compat: Make compat_alloc_user_space() incorporate the access_ok()
+    
+    [Backported to Debian's 2.6.26 by dann frazier <dannf at debian.org>]
+    
+    compat_alloc_user_space() expects the caller to independently call
+    access_ok() to verify the returned area.  A missing call could
+    introduce problems on some architectures.
+    
+    This patch incorporates the access_ok() check into
+    compat_alloc_user_space() and also adds a sanity check on the length.
+    The existing compat_alloc_user_space() implementations are renamed
+    arch_compat_alloc_user_space() and are used as part of the
+    implementation of the new global function.
+    
+    This patch assumes NULL will cause __get_user()/__put_user() to either
+    fail or access userspace on all architectures.  This should be
+    followed by checking the return value of compat_access_user_space()
+    for NULL in the callers, at which time the access_ok() in the callers
+    can also be removed.
+    
+    Reported-by: Ben Hawkes <hawkes at sota.gen.nz>
+    Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>
+    Acked-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
+    Acked-by: Chris Metcalf <cmetcalf at tilera.com>
+    Acked-by: David S. Miller <davem at davemloft.net>
+    Acked-by: Ingo Molnar <mingo at elte.hu>
+    Acked-by: Thomas Gleixner <tglx at linutronix.de>
+    Acked-by: Tony Luck <tony.luck at intel.com>
+    Cc: Andrew Morton <akpm at linux-foundation.org>
+    Cc: Arnd Bergmann <arnd at arndb.de>
+    Cc: Fenghua Yu <fenghua.yu at intel.com>
+    Cc: H. Peter Anvin <hpa at zytor.com>
+    Cc: Heiko Carstens <heiko.carstens at de.ibm.com>
+    Cc: Helge Deller <deller at gmx.de>
+    Cc: James Bottomley <jejb at parisc-linux.org>
+    Cc: Kyle McMartin <kyle at mcmartin.ca>
+    Cc: Martin Schwidefsky <schwidefsky at de.ibm.com>
+    Cc: Paul Mackerras <paulus at samba.org>
+    Cc: Ralf Baechle <ralf at linux-mips.org>
+    Cc: <stable at kernel.org>
+
+diff --git a/include/asm-ia64/compat.h b/include/asm-ia64/compat.h
+index dfcf75b..c8662cd 100644
+--- a/include/asm-ia64/compat.h
++++ b/include/asm-ia64/compat.h
+@@ -198,7 +198,7 @@ ptr_to_compat(void __user *uptr)
+ }
+ 
+ static __inline__ void __user *
+-compat_alloc_user_space (long len)
++arch_compat_alloc_user_space (long len)
+ {
+ 	struct pt_regs *regs = task_pt_regs(current);
+ 	return (void __user *) (((regs->r12 & 0xffffffff) & -16) - len);
+diff --git a/include/asm-mips/compat.h b/include/asm-mips/compat.h
+index 6c5b409..8df5cee 100644
+--- a/include/asm-mips/compat.h
++++ b/include/asm-mips/compat.h
+@@ -145,7 +145,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
+ 	return (u32)(unsigned long)uptr;
+ }
+ 
+-static inline void __user *compat_alloc_user_space(long len)
++static inline void __user *arch_compat_alloc_user_space(long len)
+ {
+ 	struct pt_regs *regs = (struct pt_regs *)
+ 		((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
+diff --git a/include/asm-parisc/compat.h b/include/asm-parisc/compat.h
+index 7f32611..7c77fa9 100644
+--- a/include/asm-parisc/compat.h
++++ b/include/asm-parisc/compat.h
+@@ -146,7 +146,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
+ 	return (u32)(unsigned long)uptr;
+ }
+ 
+-static __inline__ void __user *compat_alloc_user_space(long len)
++static __inline__ void __user *arch_compat_alloc_user_space(long len)
+ {
+ 	struct pt_regs *regs = &current->thread.regs;
+ 	return (void __user *)regs->gr[30];
+diff --git a/include/asm-powerpc/compat.h b/include/asm-powerpc/compat.h
+index 4774c2f..8d0fff3 100644
+--- a/include/asm-powerpc/compat.h
++++ b/include/asm-powerpc/compat.h
+@@ -133,7 +133,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
+ 	return (u32)(unsigned long)uptr;
+ }
+ 
+-static inline void __user *compat_alloc_user_space(long len)
++static inline void __user *arch_compat_alloc_user_space(long len)
+ {
+ 	struct pt_regs *regs = current->thread.regs;
+ 	unsigned long usp = regs->gpr[1];
+diff --git a/include/asm-s390/compat.h b/include/asm-s390/compat.h
+index de065b3..307cac1 100644
+--- a/include/asm-s390/compat.h
++++ b/include/asm-s390/compat.h
+@@ -163,7 +163,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
+ 	return (u32)(unsigned long)uptr;
+ }
+ 
+-static inline void __user *compat_alloc_user_space(long len)
++static inline void __user *arch_compat_alloc_user_space(long len)
+ {
+ 	unsigned long stack;
+ 
+diff --git a/include/asm-sparc64/compat.h b/include/asm-sparc64/compat.h
+index 0e70625..612bb38 100644
+--- a/include/asm-sparc64/compat.h
++++ b/include/asm-sparc64/compat.h
+@@ -166,7 +166,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
+ 	return (u32)(unsigned long)uptr;
+ }
+ 
+-static inline void __user *compat_alloc_user_space(long len)
++static inline void __user *arch_compat_alloc_user_space(long len)
+ {
+ 	struct pt_regs *regs = current_thread_info()->kregs;
+ 	unsigned long usp = regs->u_regs[UREG_I6];
+diff --git a/include/asm-x86/compat.h b/include/asm-x86/compat.h
+index 1793ac3..8b1b00e 100644
+--- a/include/asm-x86/compat.h
++++ b/include/asm-x86/compat.h
+@@ -204,7 +204,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
+ 	return (u32)(unsigned long)uptr;
+ }
+ 
+-static inline void __user *compat_alloc_user_space(long len)
++static inline void __user *arch_compat_alloc_user_space(long len)
+ {
+ 	struct pt_regs *regs = task_pt_regs(current);
+ 	return (void __user *)regs->sp - len;
+diff --git a/include/linux/compat.h b/include/linux/compat.h
+index 275b9bd..8cb2fcf 100644
+--- a/include/linux/compat.h
++++ b/include/linux/compat.h
+@@ -291,5 +291,7 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,
+ asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
+ 				  int flags, int mode);
+ 
++extern void __user *compat_alloc_user_space(unsigned long len);
++
+ #endif /* CONFIG_COMPAT */
+ #endif /* _LINUX_COMPAT_H */
+diff --git a/kernel/compat.c b/kernel/compat.c
+index 32c254a..0c56d52 100644
+--- a/kernel/compat.c
++++ b/kernel/compat.c
+@@ -22,6 +22,7 @@
+ #include <linux/security.h>
+ #include <linux/timex.h>
+ #include <linux/migrate.h>
++#include <linux/module.h>
+ #include <linux/posix-timers.h>
+ 
+ #include <asm/uaccess.h>
+@@ -1081,3 +1082,24 @@ compat_sys_sysinfo(struct compat_sysinfo __user *info)
+ 
+ 	return 0;
+ }
++
++/*
++ * Allocate user-space memory for the duration of a single system call,
++ * in order to marshall parameters inside a compat thunk.
++ */
++void __user *compat_alloc_user_space(unsigned long len)
++{
++	void __user *ptr;
++
++	/* If len would occupy more than half of the entire compat space... */
++	if (unlikely(len > (((compat_uptr_t)~0) >> 1)))
++		return NULL;
++
++	ptr = arch_compat_alloc_user_space(len);
++
++	if (unlikely(!access_ok(VERIFY_WRITE, ptr, len)))
++		return NULL;
++
++	return ptr;
++}
++EXPORT_SYMBOL_GPL(compat_alloc_user_space);

Modified: dists/lenny-security/linux-2.6/debian/patches/features/all/openvz/openvz.patch
==============================================================================
--- dists/lenny-security/linux-2.6/debian/patches/features/all/openvz/openvz.patch	Thu Sep 16 00:51:38 2010	(r16287)
+++ dists/lenny-security/linux-2.6/debian/patches/features/all/openvz/openvz.patch	Thu Sep 16 04:41:07 2010	(r16288)
@@ -37840,14 +37840,6 @@
 index 32c254a..58506ef 100644
 --- a/kernel/compat.c
 +++ b/kernel/compat.c
-@@ -22,6 +22,7 @@
- #include <linux/security.h>
- #include <linux/timex.h>
- #include <linux/migrate.h>
-+#include <linux/module.h>
- #include <linux/posix-timers.h>
- 
- #include <asm/uaccess.h>
 @@ -40,7 +41,7 @@ int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user
  			__put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
  }

Modified: dists/lenny-security/linux-2.6/debian/patches/series/25lenny1
==============================================================================
--- dists/lenny-security/linux-2.6/debian/patches/series/25lenny1	Thu Sep 16 00:51:38 2010	(r16287)
+++ dists/lenny-security/linux-2.6/debian/patches/series/25lenny1	Thu Sep 16 04:41:07 2010	(r16288)
@@ -1 +1,2 @@
 + bugfix/all/irda-correctly-clean-up-self-ias_obj-on-irda_bind-failure.patch
++ bugfix/all/compat-make-compat_alloc_user_space-incorporate-the_access_ok.patch



More information about the Kernel-svn-changes mailing list