]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
exit/exec: Seperate mm_release()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 6 Nov 2019 21:55:38 +0000 (22:55 +0100)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:21:47 +0000 (14:21 -0300)
BugLink: https://bugs.launchpad.net/bugs/1855787
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: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
fs/exec.c
include/linux/sched/mm.h
kernel/exit.c
kernel/fork.c

index 916cd805d32d4bed3b4a005525534411fe486f07..94c2cb48cfaf78e28b4a6d2a147f35e3bfcbd8b1 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1017,7 +1017,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 9f7cc1d7ec4a89a9e293a4b6c7f67f3a2f865217..efb9e12e7f917602b68b87dcb19cd3782ba171d1 100644 (file)
@@ -125,8 +125,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_MEMCG
 extern void mm_update_next_owner(struct mm_struct *mm);
index 4a1552c3d53bec3d8392c59c07a556c0341984b8..44e93af6267717610131d6377d28eec7af722b80 100644 (file)
@@ -497,7 +497,7 @@ static void exit_mm(void)
        struct mm_struct *mm = current->mm;
        struct core_state *core_state;
 
-       mm_release(current, mm);
+       exit_mm_release(current, mm);
        if (!mm)
                return;
        sync_mm_rss(mm);
index f19e5b114aba30a49fab59b1d3c535dac211e174..0f72642eb75adc722649051fa17a4b73a6c79201 100644 (file)
@@ -1166,7 +1166,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);
@@ -1203,6 +1203,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.