Skip to content

Commit

Permalink
exec: don't turn PF_KTHREAD off when a target command was not found
Browse files Browse the repository at this point in the history
Presently do_execve() turns PF_KTHREAD off before search_binary_handler().
 THis has a theorical risk of PF_KTHREAD getting lost.  We don't have to
turn PF_KTHREAD off in the ENOEXEC case.

This patch moves this flag modification to after the finding of the
executable file.

This is only a theorical issue because kthreads do not call do_execve()
directly.  But fixing would be better.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Acked-by: Roland McGrath <[email protected]>
Acked-by: Oleg Nesterov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kosaki authored and torvalds committed Oct 28, 2010
1 parent 478735e commit 98391cf
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ int flush_old_exec(struct linux_binprm * bprm)

bprm->mm = NULL; /* We're using it now */

current->flags &= ~PF_RANDOMIZE;
current->flags &= ~(PF_RANDOMIZE | PF_KTHREAD);
flush_thread();
current->personality &= ~bprm->per_clear;

Expand Down Expand Up @@ -1412,7 +1412,6 @@ int do_execve(const char * filename,
if (retval < 0)
goto out;

current->flags &= ~PF_KTHREAD;
retval = search_binary_handler(bprm,regs);
if (retval < 0)
goto out;
Expand Down

0 comments on commit 98391cf

Please sign in to comment.