[kernel] r22394 - in dists/wheezy-security/linux/debian: . patches patches/bugfix/all

Ben Hutchings benh at moszumanska.debian.org
Tue Feb 17 04:54:45 UTC 2015


Author: benh
Date: Tue Feb 17 04:54:45 2015
New Revision: 22394

Log:
ASLR: fix stack randomization on 64-bit systems (CVE-2015-1593)

Added:
   dists/wheezy-security/linux/debian/patches/bugfix/all/aslr-fix-stack-randomization-on-64-bit-systems.patch
Modified:
   dists/wheezy-security/linux/debian/changelog
   dists/wheezy-security/linux/debian/patches/series

Modified: dists/wheezy-security/linux/debian/changelog
==============================================================================
--- dists/wheezy-security/linux/debian/changelog	Tue Feb 17 04:50:11 2015	(r22393)
+++ dists/wheezy-security/linux/debian/changelog	Tue Feb 17 04:54:45 2015	(r22394)
@@ -17,6 +17,7 @@
   * aufs: move d_rcu from overlapping d_child to overlapping d_alias
   * vfs: deal with deadlock in d_walk() (CVE-2014-8559)
   * vfs: read file_handle only once in handle_to_path (CVE-2015-1420)
+  * ASLR: fix stack randomization on 64-bit systems (CVE-2015-1593)
 
  -- Ben Hutchings <ben at decadent.org.uk>  Thu, 29 Jan 2015 04:02:31 +0000
 

Added: dists/wheezy-security/linux/debian/patches/bugfix/all/aslr-fix-stack-randomization-on-64-bit-systems.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/wheezy-security/linux/debian/patches/bugfix/all/aslr-fix-stack-randomization-on-64-bit-systems.patch	Tue Feb 17 04:54:45 2015	(r22394)
@@ -0,0 +1,98 @@
+From: Hector Marco-Gisbert <hecmargi at upv.es>
+Date: Sat, 14 Feb 2015 09:33:50 -0800
+Subject: ASLR: fix stack randomization on 64-bit systems
+Origin: http://article.gmane.org/gmane.linux.kernel/1888210
+
+The issue is that the stack for processes is not properly randomized on 64 bit
+architectures due to an integer overflow.
+
+The affected function is randomize_stack_top() in file "fs/binfmt_elf.c":
+
+static unsigned long randomize_stack_top(unsigned long stack_top)
+{
+         unsigned int random_variable = 0;
+
+         if ((current->flags & PF_RANDOMIZE) &&
+                 !(current->personality & ADDR_NO_RANDOMIZE)) {
+                 random_variable = get_random_int() & STACK_RND_MASK;
+                 random_variable <<= PAGE_SHIFT;
+         }
+         return PAGE_ALIGN(stack_top) + random_variable;
+         return PAGE_ALIGN(stack_top) - random_variable;
+}
+
+Note that, it declares the "random_variable" variable as "unsigned int". Since
+the result of the shifting operation between STACK_RND_MASK (which is
+0x3fffff on x86_64, 22 bits) and PAGE_SHIFT (which is 12 on x86_64):
+
+random_variable <<= PAGE_SHIFT;
+
+then the two leftmost bits are dropped when storing the result in the
+"random_variable". This variable shall be at least 34 bits long to hold the
+(22+12) result.
+
+These two dropped bits have an impact on the entropy of process stack.
+Concretely, the total stack entropy is reduced by four: from 2^28 to 2^30 (One
+fourth of expected entropy).
+
+This patch restores back the entropy by correcting the types involved in the
+operations in the functions randomize_stack_top() and stack_maxrandom_size().
+
+The successful fix can be tested with:
+$ for i in `seq 1 10`; do cat /proc/self/maps | grep stack; done
+7ffeda566000-7ffeda587000 rw-p 00000000 00:00 0                          [stack]
+7fff5a332000-7fff5a353000 rw-p 00000000 00:00 0                          [stack]
+7ffcdb7a1000-7ffcdb7c2000 rw-p 00000000 00:00 0                          [stack]
+7ffd5e2c4000-7ffd5e2e5000 rw-p 00000000 00:00 0                          [stack]
+...
+
+Once corrected, the leading bytes should be between 7ffc and 7fff, rather
+than always being 7fff.
+
+CVE-2015-1593
+
+Signed-off-by: Hector Marco-Gisbert <hecmargi at upv.es>
+Signed-off-by: Ismael Ripoll <iripoll at upv.es>
+[kees: rebase, fix 80 char, clean up commit message, add test example, cve]
+Signed-off-by: Kees Cook <keescook at chromium.org>
+Cc: stable at vger.kernel.org
+---
+ arch/x86/mm/mmap.c | 6 +++---
+ fs/binfmt_elf.c    | 5 +++--
+ 2 files changed, 6 insertions(+), 5 deletions(-)
+
+--- a/arch/x86/mm/mmap.c
++++ b/arch/x86/mm/mmap.c
+@@ -35,12 +35,12 @@ struct __read_mostly va_alignment va_ali
+ 	.flags = -1,
+ };
+ 
+-static unsigned int stack_maxrandom_size(void)
++static unsigned long stack_maxrandom_size(void)
+ {
+-	unsigned int max = 0;
++	unsigned long max = 0;
+ 	if ((current->flags & PF_RANDOMIZE) &&
+ 		!(current->personality & ADDR_NO_RANDOMIZE)) {
+-		max = ((-1U) & STACK_RND_MASK) << PAGE_SHIFT;
++		max = ((-1UL) & STACK_RND_MASK) << PAGE_SHIFT;
+ 	}
+ 
+ 	return max;
+--- a/fs/binfmt_elf.c
++++ b/fs/binfmt_elf.c
+@@ -542,11 +542,12 @@ out:
+ 
+ static unsigned long randomize_stack_top(unsigned long stack_top)
+ {
+-	unsigned int random_variable = 0;
++	unsigned long random_variable = 0;
+ 
+ 	if ((current->flags & PF_RANDOMIZE) &&
+ 		!(current->personality & ADDR_NO_RANDOMIZE)) {
+-		random_variable = get_random_int() & STACK_RND_MASK;
++		random_variable = (unsigned long) get_random_int();
++		random_variable &= STACK_RND_MASK;
+ 		random_variable <<= PAGE_SHIFT;
+ 	}
+ #ifdef CONFIG_STACK_GROWSUP

Modified: dists/wheezy-security/linux/debian/patches/series
==============================================================================
--- dists/wheezy-security/linux/debian/patches/series	Tue Feb 17 04:50:11 2015	(r22393)
+++ dists/wheezy-security/linux/debian/patches/series	Tue Feb 17 04:54:45 2015	(r22394)
@@ -1167,3 +1167,4 @@
 bugfix/all/dcache-fix-locking-bugs-in-backported-deal-with-deadlock-in-d_walk.patch
 debian/vfs-avoid-abi-change-for-dentry-union-changes.patch
 bugfix/all/vfs-read-file_handle-only-once-in-handle_to_path.patch
+bugfix/all/aslr-fix-stack-randomization-on-64-bit-systems.patch



More information about the Kernel-svn-changes mailing list