CVE-2010-4258: failure to revert address limit override in OOPS error path

This commit is contained in:
Chuck Ebbert 2010-12-10 22:25:38 -05:00
parent fa44e9fd9f
commit ed56c73082
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,53 @@
From: Nelson Elhage <nelhage@ksplice.com>
Date: Thu, 2 Dec 2010 22:31:21 +0000 (-0800)
Subject: do_exit(): make sure that we run with get_fs() == USER_DS
X-Git-Tag: v2.6.37-rc5~17
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=33dd94ae1ccbfb7bf0fb6c692bc3d1c4269e6177
do_exit(): make sure that we run with get_fs() == USER_DS
If a user manages to trigger an oops with fs set to KERNEL_DS, fs is not
otherwise reset before do_exit(). do_exit may later (via mm_release in
fork.c) do a put_user to a user-controlled address, potentially allowing
a user to leverage an oops into a controlled write into kernel memory.
This is only triggerable in the presence of another bug, but this
potentially turns a lot of DoS bugs into privilege escalations, so it's
worth fixing. I have proof-of-concept code which uses this bug along
with CVE-2010-3849 to write a zero to an arbitrary kernel address, so
I've tested that this is not theoretical.
A more logical place to put this fix might be when we know an oops has
occurred, before we call do_exit(), but that would involve changing
every architecture, in multiple places.
Let's just stick it in do_exit instead.
[akpm@linux-foundation.org: update code comment]
Signed-off-by: Nelson Elhage <nelhage@ksplice.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
diff --git a/kernel/exit.c b/kernel/exit.c
index 21aa7b3..676149a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -914,6 +914,15 @@ NORET_TYPE void do_exit(long code)
if (unlikely(!tsk->pid))
panic("Attempted to kill the idle task!");
+ /*
+ * If do_exit is called because this processes oopsed, it's possible
+ * that get_fs() was left as KERNEL_DS, so reset it to USER_DS before
+ * continuing. Amongst other possible reasons, this is to prevent
+ * mm_release()->clear_child_tid() from writing to a user-controlled
+ * kernel address.
+ */
+ set_fs(USER_DS);
+
tracehook_report_exit(&code);
validate_creds_for_do_exit(tsk);

View File

@ -887,6 +887,8 @@ Patch13911: kvm-fix-fs-gs-reload-oops-with-invalid-ldt.patch
Patch13912: sctp-fix-out-of-bounds-reading-in-sctp_asoc_get_hmac.patch
# CVE-2010-3442
Patch13913: alsa-prevent-heap-corruption-in-snd_ctl_new.patch
# CVE-2010-4258
Patch13914: do_exit-make-sure-that-we-run-with-get_fs-user_ds.patch
%endif
@ -1699,6 +1701,8 @@ ApplyPatch kvm-fix-fs-gs-reload-oops-with-invalid-ldt.patch
ApplyPatch sctp-fix-out-of-bounds-reading-in-sctp_asoc_get_hmac.patch
# CVE-2010-3442
ApplyPatch alsa-prevent-heap-corruption-in-snd_ctl_new.patch
# CVE-2010-4258
ApplyPatch do_exit-make-sure-that-we-run-with-get_fs-user_ds.patch
# END OF PATCH APPLICATIONS
@ -2327,6 +2331,7 @@ fi
- CVE-2010-3698: kvm: invalid selector in fs/gs causes kernel panic
- CVE-2010-3705: sctp: Fix out-of-bounds reading in sctp_asoc_get_hmac()
- CVE-2010-3442: ALSA: prevent heap corruption in snd_ctl_new()
- CVE-2010-4258: failure to revert address limit override in OOPS error path
* Thu Dec 09 2010 Kyle McMartin <kyle@redhat.com>
- ioat2-catch-and-recover-from-broken-vtd-configurations.patch: copy patch