From: David Howells <dhowells@redhat.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: dhowells@redhat.com, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] CRED: ptrace_attach() should use the target process\'s mutex
Date: Fri, 03 Oct 2008 16:33:24 +0100 [thread overview]
Message-ID: <25964.1223048004@redhat.com> (raw)
In-Reply-To: <200810030356.m933uYeX005874@www262.sakura.ne.jp>
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:
> Subject: Add in_execve flag into task_struct.
>
> This patch allows LSM modules 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 doesn't apply on top of my patches. How about the attached variant?
I've also:
(1) Extended the patch description. Please check that I've summed up TOMOYA's
process correctly.
(2) Used current directly rather than caching it in a variable. I don't
think it's worth doing that, given the amount you make use of it, but I
can revert this change if you'd really prefer.
David
---
From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
CRED: 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 allows TOMOYA to dispense with a readability check on a file to be
executed under the process's current credentials, and to do it instead under
the proposed credentials.
This is required with the new COW credentials because TOMOYA is no longer
allowed to mark the state temporarily in the security struct attached to the
task_struct.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/compat.c | 3 +++
fs/exec.c | 3 +++
include/linux/sched.h | 2 ++
3 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/fs/compat.c b/fs/compat.c
index 0c400ad..9e0dc12 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1355,6 +1355,7 @@ int compat_do_execve(char * filename,
struct file *file;
int retval;
+ current->in_execve = 1;
retval = -ENOMEM;
bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
if (!bprm)
@@ -1418,6 +1419,7 @@ int compat_do_execve(char * filename,
mutex_unlock(¤t->cred_exec_mutex);
acct_update_integrals(current);
free_bprm(bprm);
+ current->in_execve = 0;
return retval;
out:
@@ -1437,6 +1439,7 @@ out_free:
free_bprm(bprm);
out_ret:
+ current->in_execve = 0;
return retval;
}
diff --git a/fs/exec.c b/fs/exec.c
index a03a435..c1aab0c 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1296,6 +1296,7 @@ int do_execve(char * filename,
struct files_struct *displaced;
int retval;
+ current->in_execve = 1;
retval = unshare_files(&displaced);
if (retval)
goto out_ret;
@@ -1366,6 +1367,7 @@ int do_execve(char * filename,
free_bprm(bprm);
if (displaced)
put_files_struct(displaced);
+ current->in_execve = 0;
return retval;
out:
@@ -1388,6 +1390,7 @@ out_files:
if (displaced)
reset_files_struct(displaced);
out_ret:
+ current->in_execve = 0;
return retval;
}
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2ae6ef8..2648559 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1052,6 +1052,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;
next prev parent reply other threads:[~2008-10-03 15:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200810012000.CGG73421.FQOHtLOJFVMOSF@I-love.SAKURA.ne.jp>
2008-10-01 15:38 ` [PATCH] CRED: ptrace_attach() should use the target process's mutex David Howells
2008-10-01 23:23 ` James Morris
2008-10-02 10:52 ` Tetsuo Handa
2008-10-03 3:56 ` [PATCH] CRED: ptrace_attach() should use the target process\'s mutex Tetsuo Handa
2008-10-03 15:33 ` David Howells [this message]
2008-10-04 11:15 ` Tetsuo Handa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25964.1223048004@redhat.com \
--to=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox