exec: kill task_struct->did_exec
authorOleg Nesterov <oleg@redhat.com>
Thu, 23 Jan 2014 23:55:52 +0000 (15:55 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Jan 2014 00:37:02 +0000 (16:37 -0800)
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>
fs/exec.c
include/linux/sched.h
kernel/fork.c
kernel/sys.c

index f860866e04ba1bd2e16d3c00f6c9e8c8b44cabba..493b102a27c186b5fb9fb014437dc19ab1657155 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1424,7 +1424,6 @@ static int exec_binprm(struct linux_binprm *bprm)
                audit_bprm(bprm);
                trace_sched_process_exec(current, old_pid, bprm);
                ptrace_event(PTRACE_EVENT_EXEC, old_vpid);
-               current->did_exec = 1;
                proc_exec_connector(current);
        }
 
index 66a17ad55bcbc6170c67e72adee5c21184a3b3a5..68a0e84463a0eb86b273fe14b49bd9b01feab21f 100644 (file)
@@ -1239,7 +1239,6 @@ struct task_struct {
        /* Used for emulating ABI behavior of previous Linux versions */
        unsigned int personality;
 
-       unsigned did_exec:1;
        unsigned in_execve:1;   /* Tell the LSMs that the process is doing an
                                 * execve */
        unsigned in_iowait:1;
index b6dd0bbf4240d7acec4af16c57e5d4f9cb330e8d..a17621c6cd4272182a78083e736c5972c741ed7a 100644 (file)
@@ -1226,7 +1226,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
        if (!try_module_get(task_thread_info(p)->exec_domain->module))
                goto bad_fork_cleanup_count;
 
-       p->did_exec = 0;
        delayacct_tsk_init(p);  /* Must remain after dup_task_struct() */
        copy_flags(clone_flags, p);
        INIT_LIST_HEAD(&p->children);
index c72311324ea76ef2c9ae9514d2a30e4aa7c4be66..ecd3ea12f72aa48d207ac9e02a251ade47bc3738 100644 (file)
@@ -895,8 +895,7 @@ SYSCALL_DEFINE1(times, struct tms __user *, tbuf)
  * only important on a multi-user system anyway, to make sure one user
  * can't send a signal to a process owned by another.  -TYT, 12/12/91
  *
- * Auch. Had to add the 'did_exec' flag to conform completely to POSIX.
- * LBT 04.03.94
+ * !PF_FORKNOEXEC check to conform completely to POSIX.
  */
 SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
 {
@@ -932,7 +931,7 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
                if (task_session(p) != task_session(group_leader))
                        goto out;
                err = -EACCES;
-               if (p->did_exec)
+               if (!(p->flags & PF_FORKNOEXEC))
                        goto out;
        } else {
                err = -ESRCH;