[hardy CVE 1/2] Move "exit_robust_list" into mm_release()
Andy Whitcroft
apw at canonical.com
Wed Feb 8 19:14:17 UTC 2012
From: Linus Torvalds <torvalds at linux-foundation.org>
We don't want to get rid of the futexes just at exit() time, we want to
drop them when doing an execve() too, since that gets rid of the
previous VM image too.
Doing it at mm_release() time means that we automatically always do it
when we disassociate a VM map from the task.
Reported-by: pageexec at freemail.hu
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Nick Piggin <npiggin at suse.de>
Cc: Hugh Dickins <hugh at veritas.com>
Cc: Ingo Molnar <mingo at elte.hu>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Brad Spengler <spender at grsecurity.net>
Cc: Alex Efros <powerman at powerman.name>
Cc: Peter Zijlstra <a.p.zijlstra at chello.nl>
Cc: Oleg Nesterov <oleg at redhat.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
(cherry picked from commit 8141c7f3e7aee618312fa1c15109e1219de784a7)
CVE-2012-0028
BugLink: http://bugs.launchpad.net/bugs/927889
Signed-off-by: Andy Whitcroft <apw at canonical.com>
---
kernel/exit.c | 9 ---------
kernel/fork.c | 11 +++++++++++
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index a22a2fe..92b4cc8 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -38,7 +38,6 @@
#include <linux/cn_proc.h>
#include <linux/mutex.h>
#include <linux/futex.h>
-#include <linux/compat.h>
#include <linux/pipe_fs_i.h>
#include <linux/audit.h> /* for audit_free() */
#include <linux/resource.h>
@@ -990,14 +989,6 @@ fastcall NORET_TYPE void do_exit(long code)
exit_itimers(tsk->signal);
}
acct_collect(code, group_dead);
-#ifdef CONFIG_FUTEX
- if (unlikely(tsk->robust_list))
- exit_robust_list(tsk);
-#ifdef CONFIG_COMPAT
- if (unlikely(tsk->compat_robust_list))
- compat_exit_robust_list(tsk);
-#endif
-#endif
if (group_dead)
tty_audit_exit();
if (unlikely(tsk->audit_context))
diff --git a/kernel/fork.c b/kernel/fork.c
index 0f8a779..3106adb 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -35,6 +35,7 @@
#include <linux/syscalls.h>
#include <linux/jiffies.h>
#include <linux/futex.h>
+#include <linux/compat.h>
#include <linux/task_io_accounting_ops.h>
#include <linux/rcupdate.h>
#include <linux/ptrace.h>
@@ -458,6 +459,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
{
struct completion *vfork_done = tsk->vfork_done;
+ /* Get rid of any futexes when releasing the mm */
+#ifdef CONFIG_FUTEX
+ if (unlikely(tsk->robust_list))
+ exit_robust_list(tsk);
+#ifdef CONFIG_COMPAT
+ if (unlikely(tsk->compat_robust_list))
+ compat_exit_robust_list(tsk);
+#endif
+#endif
+
/* Get rid of any cached register state */
deactivate_mm(tsk, mm);
--
1.7.9
More information about the kernel-team
mailing list