Commit f9ce1f1c authored by Kentaro Takeda's avatar Kentaro Takeda Committed by James Morris

Add in_execve flag into task_struct.

This patch allows LSM modules to determine whether current process is in an
execve operation or not so that they can behave differently while an execve
operation is in progress.

This patch is needed by TOMOYO. Please see another patch titled "LSM adapter
functions." for backgrounds.
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 523979ad
...@@ -1402,6 +1402,7 @@ int compat_do_execve(char * filename, ...@@ -1402,6 +1402,7 @@ int compat_do_execve(char * filename,
retval = mutex_lock_interruptible(&current->cred_exec_mutex); retval = mutex_lock_interruptible(&current->cred_exec_mutex);
if (retval < 0) if (retval < 0)
goto out_free; goto out_free;
current->in_execve = 1;
retval = -ENOMEM; retval = -ENOMEM;
bprm->cred = prepare_exec_creds(); bprm->cred = prepare_exec_creds();
...@@ -1454,6 +1455,7 @@ int compat_do_execve(char * filename, ...@@ -1454,6 +1455,7 @@ int compat_do_execve(char * filename,
goto out; goto out;
/* execve succeeded */ /* execve succeeded */
current->in_execve = 0;
mutex_unlock(&current->cred_exec_mutex); mutex_unlock(&current->cred_exec_mutex);
acct_update_integrals(current); acct_update_integrals(current);
free_bprm(bprm); free_bprm(bprm);
...@@ -1470,6 +1472,7 @@ int compat_do_execve(char * filename, ...@@ -1470,6 +1472,7 @@ int compat_do_execve(char * filename,
} }
out_unlock: out_unlock:
current->in_execve = 0;
mutex_unlock(&current->cred_exec_mutex); mutex_unlock(&current->cred_exec_mutex);
out_free: out_free:
......
...@@ -1278,6 +1278,7 @@ int do_execve(char * filename, ...@@ -1278,6 +1278,7 @@ int do_execve(char * filename,
retval = mutex_lock_interruptible(&current->cred_exec_mutex); retval = mutex_lock_interruptible(&current->cred_exec_mutex);
if (retval < 0) if (retval < 0)
goto out_free; goto out_free;
current->in_execve = 1;
retval = -ENOMEM; retval = -ENOMEM;
bprm->cred = prepare_exec_creds(); bprm->cred = prepare_exec_creds();
...@@ -1331,6 +1332,7 @@ int do_execve(char * filename, ...@@ -1331,6 +1332,7 @@ int do_execve(char * filename,
goto out; goto out;
/* execve succeeded */ /* execve succeeded */
current->in_execve = 0;
mutex_unlock(&current->cred_exec_mutex); mutex_unlock(&current->cred_exec_mutex);
acct_update_integrals(current); acct_update_integrals(current);
free_bprm(bprm); free_bprm(bprm);
...@@ -1349,6 +1351,7 @@ int do_execve(char * filename, ...@@ -1349,6 +1351,7 @@ int do_execve(char * filename,
} }
out_unlock: out_unlock:
current->in_execve = 0;
mutex_unlock(&current->cred_exec_mutex); mutex_unlock(&current->cred_exec_mutex);
out_free: out_free:
......
...@@ -1158,6 +1158,8 @@ struct task_struct { ...@@ -1158,6 +1158,8 @@ struct task_struct {
/* ??? */ /* ??? */
unsigned int personality; unsigned int personality;
unsigned did_exec:1; unsigned did_exec:1;
unsigned in_execve:1; /* Tell the LSMs that the process is doing an
* execve */
pid_t pid; pid_t pid;
pid_t tgid; pid_t tgid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment