Commit 8141c7f3e7aee618312fa1c15109e1219de784a7

Authored by Linus Torvalds
1 parent 9c7c354645

Move "exit_robust_list" into mm_release()

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@freemail.hu
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Brad Spengler <spender@grsecurity.net>
Cc: Alex Efros <powerman@powerman.name>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 11 additions and 9 deletions Side-by-side Diff

... ... @@ -40,7 +40,6 @@
40 40 #include <linux/cn_proc.h>
41 41 #include <linux/mutex.h>
42 42 #include <linux/futex.h>
43   -#include <linux/compat.h>
44 43 #include <linux/pipe_fs_i.h>
45 44 #include <linux/audit.h> /* for audit_free() */
46 45 #include <linux/resource.h>
... ... @@ -1059,14 +1058,6 @@
1059 1058 exit_itimers(tsk->signal);
1060 1059 }
1061 1060 acct_collect(code, group_dead);
1062   -#ifdef CONFIG_FUTEX
1063   - if (unlikely(tsk->robust_list))
1064   - exit_robust_list(tsk);
1065   -#ifdef CONFIG_COMPAT
1066   - if (unlikely(tsk->compat_robust_list))
1067   - compat_exit_robust_list(tsk);
1068   -#endif
1069   -#endif
1070 1061 if (group_dead)
1071 1062 tty_audit_exit();
1072 1063 if (unlikely(tsk->audit_context))
... ... @@ -40,6 +40,7 @@
40 40 #include <linux/jiffies.h>
41 41 #include <linux/tracehook.h>
42 42 #include <linux/futex.h>
  43 +#include <linux/compat.h>
43 44 #include <linux/task_io_accounting_ops.h>
44 45 #include <linux/rcupdate.h>
45 46 #include <linux/ptrace.h>
... ... @@ -518,6 +519,16 @@
518 519 void mm_release(struct task_struct *tsk, struct mm_struct *mm)
519 520 {
520 521 struct completion *vfork_done = tsk->vfork_done;
  522 +
  523 + /* Get rid of any futexes when releasing the mm */
  524 +#ifdef CONFIG_FUTEX
  525 + if (unlikely(tsk->robust_list))
  526 + exit_robust_list(tsk);
  527 +#ifdef CONFIG_COMPAT
  528 + if (unlikely(tsk->compat_robust_list))
  529 + compat_exit_robust_list(tsk);
  530 +#endif
  531 +#endif
521 532  
522 533 /* Get rid of any cached register state */
523 534 deactivate_mm(tsk, mm);