Skip to content

Commit 1b2552c

Browse files
committed
fork: Stop allowing kthreads to call execve
Now that kernel_execve is no longer called from kernel threads stop supporting kernel threads calling kernel_execve. Remove the code for converting a kthread to a normal thread in execve. Document the restriction that kthreads may not call kernel_execve by having kernel_execve fail if called by a kthread. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 753550e commit 1b2552c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/exec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ int begin_new_exec(struct linux_binprm * bprm)
13081308
if (retval)
13091309
goto out_unlock;
13101310

1311-
me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
1311+
me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC |
13121312
PF_NOFREEZE | PF_NO_SETAFFINITY);
13131313
flush_thread();
13141314
me->personality &= ~bprm->per_clear;
@@ -1953,8 +1953,8 @@ int kernel_execve(const char *kernel_filename,
19531953
int fd = AT_FDCWD;
19541954
int retval;
19551955

1956-
if (WARN_ON_ONCE((current->flags & PF_KTHREAD) &&
1957-
(current->worker_private)))
1956+
/* It is non-sense for kernel threads to call execve */
1957+
if (WARN_ON_ONCE(current->flags & PF_KTHREAD))
19581958
return -EINVAL;
19591959

19601960
filename = getname_kernel(kernel_filename);

0 commit comments

Comments
 (0)