]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Add in_execve flag into task_struct.
authorKentaro Takeda <takedakn@nttdata.co.jp>
Thu, 5 Feb 2009 08:18:11 +0000 (17:18 +0900)
committerJames Morris <jmorris@namei.org>
Thu, 12 Feb 2009 04:15:03 +0000 (15:15 +1100)
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: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
fs/compat.c
fs/exec.c
include/linux/sched.h

index 65a070e705ab1d8112ae6085c8d3e7d7c6202c90..25589f8322f280e54c4380e605702d027afe0c85 100644 (file)
@@ -1402,6 +1402,7 @@ int compat_do_execve(char * filename,
        retval = mutex_lock_interruptible(&current->cred_exec_mutex);
        if (retval < 0)
                goto out_free;
+       current->in_execve = 1;
 
        retval = -ENOMEM;
        bprm->cred = prepare_exec_creds();
@@ -1454,6 +1455,7 @@ int compat_do_execve(char * filename,
                goto out;
 
        /* execve succeeded */
+       current->in_execve = 0;
        mutex_unlock(&current->cred_exec_mutex);
        acct_update_integrals(current);
        free_bprm(bprm);
@@ -1470,6 +1472,7 @@ out_file:
        }
 
 out_unlock:
+       current->in_execve = 0;
        mutex_unlock(&current->cred_exec_mutex);
 
 out_free:
index febfd8ed6ad178ba31b5d858a8f371b3958ab388..9881dc3bb488760000fea3afea2e4b5d251632e2 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1278,6 +1278,7 @@ int do_execve(char * filename,
        retval = mutex_lock_interruptible(&current->cred_exec_mutex);
        if (retval < 0)
                goto out_free;
+       current->in_execve = 1;
 
        retval = -ENOMEM;
        bprm->cred = prepare_exec_creds();
@@ -1331,6 +1332,7 @@ int do_execve(char * filename,
                goto out;
 
        /* execve succeeded */
+       current->in_execve = 0;
        mutex_unlock(&current->cred_exec_mutex);
        acct_update_integrals(current);
        free_bprm(bprm);
@@ -1349,6 +1351,7 @@ out_file:
        }
 
 out_unlock:
+       current->in_execve = 0;
        mutex_unlock(&current->cred_exec_mutex);
 
 out_free:
index 2127e959e0f4ac86565ff0832063586ac6387dab..397c20cfb6a50d1468d8c367b92781cbbe84bdbb 100644 (file)
@@ -1158,6 +1158,8 @@ struct task_struct {
        /* ??? */
        unsigned int personality;
        unsigned did_exec:1;
+       unsigned in_execve:1;   /* Tell the LSMs that the process is doing an
+                                * execve */
        pid_t pid;
        pid_t tgid;