public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kentaro Takeda <takedakn@nttdata.co.jp>
To: jmorris@namei.org
Cc: linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	haradats@nttdata.co.jp,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	David Howells <dhowells@redhat.com>
Subject: [TOMOYO #15 1/8] Add in_execve flag into task_struct.
Date: Thu, 05 Feb 2009 17:18:11 +0900	[thread overview]
Message-ID: <20090205082224.360343106@nttdata.co.jp> (raw)
In-Reply-To: 20090205081810.331987920@nttdata.co.jp

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>
---
 fs/compat.c           |    3 +++
 fs/exec.c             |    3 +++
 include/linux/sched.h |    2 ++
 3 files changed, 8 insertions(+)

--- security-testing-2.6.git.orig/fs/compat.c
+++ security-testing-2.6.git/fs/compat.c
@@ -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:
--- security-testing-2.6.git.orig/fs/exec.c
+++ security-testing-2.6.git/fs/exec.c
@@ -1268,6 +1268,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();
@@ -1321,6 +1322,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);
@@ -1339,6 +1341,7 @@ out_file:
 	}
 
 out_unlock:
+	current->in_execve = 0;
 	mutex_unlock(&current->cred_exec_mutex);
 
 out_free:
--- security-testing-2.6.git.orig/include/linux/sched.h
+++ security-testing-2.6.git/include/linux/sched.h
@@ -1157,6 +1157,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;
 

--


  reply	other threads:[~2009-02-05  9:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05  8:18 [TOMOYO #15 0/8] TOMOYO Linux Kentaro Takeda
2009-02-05  8:18 ` Kentaro Takeda [this message]
2009-02-05  8:18 ` [TOMOYO #15 2/8] Memory and pathname management functions Kentaro Takeda
2009-02-05  8:18 ` [TOMOYO #15 3/8] Common functions for TOMOYO Linux Kentaro Takeda
2009-02-05  8:18 ` [TOMOYO #15 4/8] File operation restriction part Kentaro Takeda
2009-02-05  8:18 ` [TOMOYO #15 5/8] Domain transition handler Kentaro Takeda
2009-02-05  8:18 ` [TOMOYO #15 6/8] LSM adapter functions Kentaro Takeda
2009-02-05 17:10   ` Alexey Dobriyan
2009-02-06  1:41     ` Tetsuo Handa
2009-02-05  8:18 ` [TOMOYO #15 7/8] Kconfig and Makefile Kentaro Takeda
2009-02-05  8:18 ` [TOMOYO #15 8/8] MAINTAINERS info Kentaro Takeda
2009-02-12  5:34 ` [TOMOYO #15 0/8] TOMOYO Linux James Morris
2009-02-12  6:53   ` Tetsuo Handa
2009-02-12  9:25     ` James Morris
2009-02-13  7:00       ` Tetsuo Handa
2009-02-14  1:33         ` James Morris
2009-02-22 14:23   ` Pavel Machek
2009-02-22 14:27     ` Tetsuo Handa
2009-02-22 14:48       ` Pavel Machek
2009-02-23  7:37         ` Toshiharu Harada
2009-02-25 19:46           ` Pavel Machek
2009-02-27  1:27             ` KOSAKI Motohiro
2009-03-01 22:45               ` Pavel Machek

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=20090205082224.360343106@nttdata.co.jp \
    --to=takedakn@nttdata.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=haradats@nttdata.co.jp \
    --cc=jmorris@namei.org \
    --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