[PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread

Subsystems: exec & binfmt api, elf, filesystems (vfs and infrastructure), the rest

STALE2336d

6 messages, 5 authors, 2020-03-10 · open the first message on its own page

[PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread

From: Eric W. Biederman <hidden>
Date: 2020-03-08 21:39:19

These functions have very little to do with de_thread move them out
of de_thread an into flush_old_exec proper so it can be more clearly
seen what flush_old_exec is doing.

Signed-off-by: "Eric W. Biederman" <redacted>
---
 fs/exec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index ff74b9a74d34..215d86f77b63 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1189,11 +1189,6 @@ static int de_thread(struct task_struct *tsk)
 	/* we have changed execution domain */
 	tsk->exit_signal = SIGCHLD;
 
-#ifdef CONFIG_POSIX_TIMERS
-	exit_itimers(sig);
-	flush_itimer_signals();
-#endif
-
 	BUG_ON(!thread_group_leader(tsk));
 	return 0;
 
@@ -1277,6 +1272,11 @@ int flush_old_exec(struct linux_binprm * bprm)
 	if (retval)
 		goto out;
 
+#ifdef CONFIG_POSIX_TIMERS
+	exit_itimers(me->signal);
+	flush_itimer_signals();
+#endif
+
 	/*
 	 * Make the signal table private.
 	 */
-- 
2.25.0

Re: [PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread

From: Bernd Edlinger <hidden>
Date: 2020-03-09 19:31:01

On 3/8/20 10:36 PM, Eric W. Biederman wrote:
These functions have very little to do with de_thread move them out
of de_thread an into flush_old_exec proper so it can be more clearly
seen what flush_old_exec is doing.

Signed-off-by: "Eric W. Biederman" <redacted>
Reviewed-by: Bernd Edlinger <redacted>


Bernd.
quoted hunk
---
 fs/exec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index ff74b9a74d34..215d86f77b63 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1189,11 +1189,6 @@ static int de_thread(struct task_struct *tsk)
 	/* we have changed execution domain */
 	tsk->exit_signal = SIGCHLD;
 
-#ifdef CONFIG_POSIX_TIMERS
-	exit_itimers(sig);
-	flush_itimer_signals();
-#endif
-
 	BUG_ON(!thread_group_leader(tsk));
 	return 0;
 
@@ -1277,6 +1272,11 @@ int flush_old_exec(struct linux_binprm * bprm)
 	if (retval)
 		goto out;
 
+#ifdef CONFIG_POSIX_TIMERS
+	exit_itimers(me->signal);
+	flush_itimer_signals();
+#endif
+
 	/*
 	 * Make the signal table private.
 	 */

Re: [PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread

From: Christian Brauner <hidden>
Date: 2020-03-09 19:59:57

On Sun, Mar 08, 2020 at 04:36:55PM -0500, Eric W. Biederman wrote:
quoted hunk
These functions have very little to do with de_thread move them out
of de_thread an into flush_old_exec proper so it can be more clearly
seen what flush_old_exec is doing.

Signed-off-by: "Eric W. Biederman" <redacted>
---
 fs/exec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index ff74b9a74d34..215d86f77b63 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1189,11 +1189,6 @@ static int de_thread(struct task_struct *tsk)
While you're cleaning up de_thread() wouldn't it be good to also take
the opportunity and remove the task argument from de_thread(). It's only
ever used with current. Could be done in one of your patches or as a
separate patch.
diff --git a/fs/exec.c b/fs/exec.c
index db17be51b112..ee108707e4b0 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1061,8 +1061,9 @@ static int exec_mmap(struct mm_struct *mm)
  * disturbing other processes.  (Other processes might share the signal
  * table via the CLONE_SIGHAND option to clone().)
  */
-static int de_thread(struct task_struct *tsk)
+static int de_thread(void)
 {
+       struct task_struct *tsk = current;
        struct signal_struct *sig = tsk->signal;
        struct sighand_struct *oldsighand = tsk->sighand;
        spinlock_t *lock = &oldsighand->siglock;
@@ -1266,7 +1267,7 @@ int flush_old_exec(struct linux_binprm * bprm)
         * Make sure we have a private signal table and that
         * we are unassociated from the previous thread group.
         */
-       retval = de_thread(current);
+       retval = de_thread();
        if (retval)
                goto out;

Re: [PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread

From: Kees Cook <hidden>
Date: 2020-03-10 20:31:25

On Sun, Mar 08, 2020 at 04:36:55PM -0500, Eric W. Biederman wrote:
quoted hunk
These functions have very little to do with de_thread move them out
of de_thread an into flush_old_exec proper so it can be more clearly
seen what flush_old_exec is doing.

Signed-off-by: "Eric W. Biederman" <redacted>
---
 fs/exec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index ff74b9a74d34..215d86f77b63 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1189,11 +1189,6 @@ static int de_thread(struct task_struct *tsk)
 	/* we have changed execution domain */
 	tsk->exit_signal = SIGCHLD;
 
-#ifdef CONFIG_POSIX_TIMERS
-	exit_itimers(sig);
-	flush_itimer_signals();
-#endif
-
 	BUG_ON(!thread_group_leader(tsk));
 	return 0;
 
@@ -1277,6 +1272,11 @@ int flush_old_exec(struct linux_binprm * bprm)
 	if (retval)
 		goto out;
 
+#ifdef CONFIG_POSIX_TIMERS
+	exit_itimers(me->signal);
+	flush_itimer_signals();
+#endif
+
I twitch at seeing #ifdefs in .c instead of hidden in the .h declarations
of these two functions, but as this is a copy/paste, I'll live. ;)

Reviewed-by: Kees Cook <redacted>

-Kees
 	/*
 	 * Make the signal table private.
 	 */
-- 
2.25.0
-- 
Kees Cook

Re: [PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread

From: Jann Horn <jannh@google.com>
Date: 2020-03-10 20:58:22

On Sun, Mar 8, 2020 at 10:39 PM Eric W. Biederman [off-list ref] wrote:
quoted hunk
These functions have very little to do with de_thread move them out
of de_thread an into flush_old_exec proper so it can be more clearly
seen what flush_old_exec is doing.

Signed-off-by: "Eric W. Biederman" <redacted>
---
 fs/exec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index ff74b9a74d34..215d86f77b63 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1189,11 +1189,6 @@ static int de_thread(struct task_struct *tsk)
        /* we have changed execution domain */
        tsk->exit_signal = SIGCHLD;

-#ifdef CONFIG_POSIX_TIMERS
-       exit_itimers(sig);
-       flush_itimer_signals();
-#endif
-
        BUG_ON(!thread_group_leader(tsk));
        return 0;
@@ -1277,6 +1272,11 @@ int flush_old_exec(struct linux_binprm * bprm)
        if (retval)
                goto out;

+#ifdef CONFIG_POSIX_TIMERS
+       exit_itimers(me->signal);
+       flush_itimer_signals();
+#endif
nit: exit_itimers() has a comment referring to de_thread, that should
probably be updated

Re: [PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread

From: Christian Brauner <hidden>
Date: 2020-03-10 21:23:34

On Sun, Mar 08, 2020 at 04:36:55PM -0500, Eric W. Biederman wrote:
These functions have very little to do with de_thread move them out
of de_thread an into flush_old_exec proper so it can be more clearly
seen what flush_old_exec is doing.

Signed-off-by: "Eric W. Biederman" <redacted>
Acked-by: Christian Brauner <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help