rpms/kernel/F-11 do_sigaltstack-avoid-copying-stack_t-as-a-structure-to-userspace.patch, NONE, 1.1.2.2 kernel.spec, 1.1679.2.13, 1.1679.2.14

Kyle McMartin kyle at fedoraproject.org
Wed Aug 19 14:21:52 UTC 2009


Author: kyle

Update of /cvs/pkgs/rpms/kernel/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv30615

Modified Files:
      Tag: private-fedora-11-2_6_29_6
	kernel.spec 
Added Files:
      Tag: private-fedora-11-2_6_29_6
	do_sigaltstack-avoid-copying-stack_t-as-a-structure-to-userspace.patch 
Log Message:
CVE-2009-2847 fix kernel information leak in sigaltstack

do_sigaltstack-avoid-copying-stack_t-as-a-structure-to-userspace.patch:
 signal.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

--- NEW FILE do_sigaltstack-avoid-copying-stack_t-as-a-structure-to-userspace.patch ---
From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Sat, 1 Aug 2009 17:34:56 +0000 (-0700)
Subject: do_sigaltstack: avoid copying 'stack_t' as a structure to user space
X-Git-Tag: v2.6.31-rc6~89
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=0083fc2c50e6c5127c2802ad323adf8143ab7856

do_sigaltstack: avoid copying 'stack_t' as a structure to user space

Ulrich Drepper correctly points out that there is generally padding in
the structure on 64-bit hosts, and that copying the structure from
kernel to user space can leak information from the kernel stack in those
padding bytes.

Avoid the whole issue by just copying the three members one by one
instead, which also means that the function also can avoid the need for
a stack frame.  This also happens to match how we copy the new structure
from user space, so it all even makes sense.

[ The obvious solution of adding a memset() generates horrid code, gcc
  does really stupid things. ]

Reported-by: Ulrich Drepper <drepper at redhat.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

diff --git a/kernel/signal.c b/kernel/signal.c
index ccf1cee..f268372 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2454,11 +2454,9 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
 	stack_t oss;
 	int error;
 
-	if (uoss) {
-		oss.ss_sp = (void __user *) current->sas_ss_sp;
-		oss.ss_size = current->sas_ss_size;
-		oss.ss_flags = sas_ss_flags(sp);
-	}
+	oss.ss_sp = (void __user *) current->sas_ss_sp;
+	oss.ss_size = current->sas_ss_size;
+	oss.ss_flags = sas_ss_flags(sp);
 
 	if (uss) {
 		void __user *ss_sp;
@@ -2501,13 +2499,16 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
 		current->sas_ss_size = ss_size;
 	}
 
+	error = 0;
 	if (uoss) {
 		error = -EFAULT;
-		if (copy_to_user(uoss, &oss, sizeof(oss)))
+		if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
 			goto out;
+		error = __put_user(oss.ss_sp, &uoss->ss_sp) |
+			__put_user(oss.ss_size, &uoss->ss_size) |
+			__put_user(oss.ss_flags, &uoss->ss_flags);
 	}
 
-	error = 0;
 out:
 	return error;
 }


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-11/kernel.spec,v
retrieving revision 1.1679.2.13
retrieving revision 1.1679.2.14
diff -u -p -r1.1679.2.13 -r1.1679.2.14
--- kernel.spec	19 Aug 2009 05:13:13 -0000	1.1679.2.13
+++ kernel.spec	19 Aug 2009 14:21:52 -0000	1.1679.2.14
@@ -828,6 +828,9 @@ Patch12020: execve-must-clear-current-cl
 # CVE-2009-2849
 Patch12030: md-avoid-dereferencing-NULL-ptr-suspend-sysfs.patch
 
+# CVE-2009-2847
+Patch12040: do_sigaltstack-avoid-copying-stack_t-as-a-structure-to-userspace.patch
+
 # make gcc stop optimizing away null pointer tests
 Patch13000: add-fno-delete-null-pointer-checks-to-gcc-cflags.patch
 
@@ -1555,6 +1558,9 @@ ApplyPatch execve-must-clear-current-cle
 # CVE-2009-2849
 ApplyPatch md-avoid-dereferencing-NULL-ptr-suspend-sysfs.patch
 
+# CVE-2009-2847
+ApplyPatch do_sigaltstack-avoid-copying-stack_t-as-a-structure-to-userspace.patch
+
 # don't optimize out null pointer tests
 ApplyPatch add-fno-delete-null-pointer-checks-to-gcc-cflags.patch
 
@@ -2164,6 +2170,8 @@ fi
   which improve mmap_min_addr.
 - CVE-2009-2849: md: avoid dereferencing null ptr when accessing suspend
   sysfs attributes.
+- CVE-2009-2847: do_sigaltstack: avoid copying 'stack_t' as a structure
+  to userspace
 
 * Mon Aug 17 2009 Jarod Wilson <jarod at redhat.com> 2.6.29.6-217.2.9
 - Fix flub in prior lirc patch update that resulted in no lirc




More information about the fedora-extras-commits mailing list