Skip to content

Commit 98611e4

Browse files
oleg-nesterovtorvalds
authored andcommitted
exec: kill task_struct->did_exec
We can kill either task->did_exec or PF_FORKNOEXEC, they are mutually exclusive. The patch kills ->did_exec because it has a single user. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Kees Cook <keescook@chromium.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 63e46b9 commit 98611e4

4 files changed

Lines changed: 2 additions & 6 deletions

File tree

‎fs/exec.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,6 @@ static int exec_binprm(struct linux_binprm *bprm)
14241424
audit_bprm(bprm);
14251425
trace_sched_process_exec(current, old_pid, bprm);
14261426
ptrace_event(PTRACE_EVENT_EXEC, old_vpid);
1427-
current->did_exec = 1;
14281427
proc_exec_connector(current);
14291428
}
14301429

‎include/linux/sched.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,6 @@ struct task_struct {
12391239
/* Used for emulating ABI behavior of previous Linux versions */
12401240
unsigned int personality;
12411241

1242-
unsigned did_exec:1;
12431242
unsigned in_execve:1; /* Tell the LSMs that the process is doing an
12441243
* execve */
12451244
unsigned in_iowait:1;

‎kernel/fork.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
12261226
if (!try_module_get(task_thread_info(p)->exec_domain->module))
12271227
goto bad_fork_cleanup_count;
12281228

1229-
p->did_exec = 0;
12301229
delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
12311230
copy_flags(clone_flags, p);
12321231
INIT_LIST_HEAD(&p->children);

‎kernel/sys.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,7 @@ SYSCALL_DEFINE1(times, struct tms __user *, tbuf)
895895
* only important on a multi-user system anyway, to make sure one user
896896
* can't send a signal to a process owned by another. -TYT, 12/12/91
897897
*
898-
* Auch. Had to add the 'did_exec' flag to conform completely to POSIX.
899-
* LBT 04.03.94
898+
* !PF_FORKNOEXEC check to conform completely to POSIX.
900899
*/
901900
SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
902901
{
@@ -932,7 +931,7 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
932931
if (task_session(p) != task_session(group_leader))
933932
goto out;
934933
err = -EACCES;
935-
if (p->did_exec)
934+
if (!(p->flags & PF_FORKNOEXEC))
936935
goto out;
937936
} else {
938937
err = -ESRCH;

0 commit comments

Comments
 (0)