Skip to content

Commit 2ca7be7

Browse files
committed
exec: Only compute current once in flush_old_exec
Make it clear that current only needs to be computed once in flush_old_exec. This may have some efficiency improvements and it makes the code easier to change. Signed-off-by: "Eric W. Biederman" <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Kees Cook <[email protected]> Acked-by: Christian Brauner <[email protected]> Reviewed-by: Kirill Tkhai <[email protected]> Signed-off-by: Bernd Edlinger <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent a0d4a14 commit 2ca7be7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/exec.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,13 +1260,14 @@ void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec)
12601260
*/
12611261
int flush_old_exec(struct linux_binprm * bprm)
12621262
{
1263+
struct task_struct *me = current;
12631264
int retval;
12641265

12651266
/*
12661267
* Make sure we have a private signal table and that
12671268
* we are unassociated from the previous thread group.
12681269
*/
1269-
retval = de_thread(current);
1270+
retval = de_thread(me);
12701271
if (retval)
12711272
goto out;
12721273

@@ -1294,18 +1295,18 @@ int flush_old_exec(struct linux_binprm * bprm)
12941295
bprm->mm = NULL;
12951296

12961297
set_fs(USER_DS);
1297-
current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
1298+
me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
12981299
PF_NOFREEZE | PF_NO_SETAFFINITY);
12991300
flush_thread();
1300-
current->personality &= ~bprm->per_clear;
1301+
me->personality &= ~bprm->per_clear;
13011302

13021303
/*
13031304
* We have to apply CLOEXEC before we change whether the process is
13041305
* dumpable (in setup_new_exec) to avoid a race with a process in userspace
13051306
* trying to access the should-be-closed file descriptors of a process
13061307
* undergoing exec(2).
13071308
*/
1308-
do_close_on_exec(current->files);
1309+
do_close_on_exec(me->files);
13091310
return 0;
13101311

13111312
out:

0 commit comments

Comments
 (0)