]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
exit/exec: Seperate mm_release()
authorThomas Gleixner <tglx@linutronix.de>
Mon, 1 Feb 2021 15:12:06 +0000 (15:12 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Feb 2021 22:16:16 +0000 (23:16 +0100)
commit 4610ba7ad877fafc0a25a30c6c82015304120426 upstream.

mm_release() contains the futex exit handling. mm_release() is called from
do_exit()->exit_mm() and from exec()->exec_mm().

In the exit_mm() case PF_EXITING and the futex state is updated. In the
exec_mm() case these states are not touched.

As the futex exit code needs further protections against exit races, this
needs to be split into two functions.

Preparatory only, no functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20191106224556.240518241@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/exec.c
include/linux/sched.h
kernel/exit.c
kernel/fork.c

index 46cc0c072246d6ae1b7a4d1be13591398994a31d..ce111af5784be2441e16a98e91c53e4fe2c2a0d4 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -875,7 +875,7 @@ static int exec_mmap(struct mm_struct *mm)
        /* Notify parent that we're no longer interested in the old VM */
        tsk = current;
        old_mm = current->mm;
-       mm_release(tsk, old_mm);
+       exec_mm_release(tsk, old_mm);
 
        if (old_mm) {
                sync_mm_rss(old_mm);
index bdd41a0127d107e8b16960b549044e694c5e0857..aba34bba5e9e309bbb85f67487a097dcef455aa2 100644 (file)
@@ -2647,8 +2647,10 @@ extern struct mm_struct *get_task_mm(struct task_struct *task);
  * succeeds.
  */
 extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode);
-/* Remove the current tasks stale references to the old mm_struct */
-extern void mm_release(struct task_struct *, struct mm_struct *);
+/* Remove the current tasks stale references to the old mm_struct on exit() */
+extern void exit_mm_release(struct task_struct *, struct mm_struct *);
+/* Remove the current tasks stale references to the old mm_struct on exec() */
+extern void exec_mm_release(struct task_struct *, struct mm_struct *);
 
 #ifdef CONFIG_HAVE_COPY_THREAD_TLS
 extern int copy_thread_tls(unsigned long, unsigned long, unsigned long,
index 274a3c3834a1595bf023af3a4af457c01e1ade4d..a098d76a9877ec8463195d2d806e2d67b5f68bd1 100644 (file)
@@ -389,7 +389,7 @@ static void exit_mm(struct task_struct *tsk)
        struct mm_struct *mm = tsk->mm;
        struct core_state *core_state;
 
-       mm_release(tsk, mm);
+       exit_mm_release(tsk, mm);
        if (!mm)
                return;
        sync_mm_rss(mm);
index d0ab6aff5efdc307e4042e6dc51063496913c6b2..43a50072dd5b4c88cd298079bb1e8c4e545ff4c6 100644 (file)
@@ -887,7 +887,7 @@ static int wait_for_vfork_done(struct task_struct *child,
  * restoring the old one. . .
  * Eric Biederman 10 January 1998
  */
-void mm_release(struct task_struct *tsk, struct mm_struct *mm)
+static void mm_release(struct task_struct *tsk, struct mm_struct *mm)
 {
        /* Get rid of any futexes when releasing the mm */
        futex_mm_release(tsk);
@@ -924,6 +924,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
                complete_vfork_done(tsk);
 }
 
+void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm)
+{
+       mm_release(tsk, mm);
+}
+
+void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm)
+{
+       mm_release(tsk, mm);
+}
+
 /*
  * Allocate a new mm structure and copy contents from the
  * mm structure of the passed in task structure.