diff options
| author | Oleg Nesterov <oleg@redhat.com> | 2014-01-23 18:55:52 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:37:02 -0500 |
| commit | 98611e4e6a2b4a03fd2d4750cce8e4455a995c8d (patch) | |
| tree | 5979f4761ba67616eaeb3c5fd6fd19dbd265f9f2 | |
| parent | 63e46b95e9eae1161832bf45cb40bbad37bfb182 (diff) | |
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>
| -rw-r--r-- | fs/exec.c | 1 | ||||
| -rw-r--r-- | include/linux/sched.h | 1 | ||||
| -rw-r--r-- | kernel/fork.c | 1 | ||||
| -rw-r--r-- | kernel/sys.c | 5 |
4 files changed, 2 insertions, 6 deletions
| @@ -1424,7 +1424,6 @@ static int exec_binprm(struct linux_binprm *bprm) | |||
| 1424 | audit_bprm(bprm); | 1424 | audit_bprm(bprm); |
| 1425 | trace_sched_process_exec(current, old_pid, bprm); | 1425 | trace_sched_process_exec(current, old_pid, bprm); |
| 1426 | ptrace_event(PTRACE_EVENT_EXEC, old_vpid); | 1426 | ptrace_event(PTRACE_EVENT_EXEC, old_vpid); |
| 1427 | current->did_exec = 1; | ||
| 1428 | proc_exec_connector(current); | 1427 | proc_exec_connector(current); |
| 1429 | } | 1428 | } |
| 1430 | 1429 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index 66a17ad55bcb..68a0e84463a0 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -1239,7 +1239,6 @@ struct task_struct { | |||
| 1239 | /* Used for emulating ABI behavior of previous Linux versions */ | 1239 | /* Used for emulating ABI behavior of previous Linux versions */ |
| 1240 | unsigned int personality; | 1240 | unsigned int personality; |
| 1241 | 1241 | ||
| 1242 | unsigned did_exec:1; | ||
| 1243 | unsigned in_execve:1; /* Tell the LSMs that the process is doing an | 1242 | unsigned in_execve:1; /* Tell the LSMs that the process is doing an |
| 1244 | * execve */ | 1243 | * execve */ |
| 1245 | unsigned in_iowait:1; | 1244 | unsigned in_iowait:1; |
diff --git a/kernel/fork.c b/kernel/fork.c index b6dd0bbf4240..a17621c6cd42 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -1226,7 +1226,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1226 | if (!try_module_get(task_thread_info(p)->exec_domain->module)) | 1226 | if (!try_module_get(task_thread_info(p)->exec_domain->module)) |
| 1227 | goto bad_fork_cleanup_count; | 1227 | goto bad_fork_cleanup_count; |
| 1228 | 1228 | ||
| 1229 | p->did_exec = 0; | ||
| 1230 | delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ | 1229 | delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ |
| 1231 | copy_flags(clone_flags, p); | 1230 | copy_flags(clone_flags, p); |
| 1232 | INIT_LIST_HEAD(&p->children); | 1231 | INIT_LIST_HEAD(&p->children); |
diff --git a/kernel/sys.c b/kernel/sys.c index c72311324ea7..ecd3ea12f72a 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -895,8 +895,7 @@ SYSCALL_DEFINE1(times, struct tms __user *, tbuf) | |||
| 895 | * only important on a multi-user system anyway, to make sure one user | 895 | * only important on a multi-user system anyway, to make sure one user |
| 896 | * can't send a signal to a process owned by another. -TYT, 12/12/91 | 896 | * can't send a signal to a process owned by another. -TYT, 12/12/91 |
| 897 | * | 897 | * |
| 898 | * Auch. Had to add the 'did_exec' flag to conform completely to POSIX. | 898 | * !PF_FORKNOEXEC check to conform completely to POSIX. |
| 899 | * LBT 04.03.94 | ||
| 900 | */ | 899 | */ |
| 901 | SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) | 900 | SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) |
| 902 | { | 901 | { |
| @@ -932,7 +931,7 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) | |||
| 932 | if (task_session(p) != task_session(group_leader)) | 931 | if (task_session(p) != task_session(group_leader)) |
| 933 | goto out; | 932 | goto out; |
| 934 | err = -EACCES; | 933 | err = -EACCES; |
| 935 | if (p->did_exec) | 934 | if (!(p->flags & PF_FORKNOEXEC)) |
| 936 | goto out; | 935 | goto out; |
| 937 | } else { | 936 | } else { |
| 938 | err = -ESRCH; | 937 | err = -ESRCH; |
