lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200810030356.m933uYeX005874@www262.sakura.ne.jp>
Date:	Fri, 03 Oct 2008 12:56:34 +0900
From:	Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>
To:	linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:	dhowells@...hat.com
Subject: Re: [PATCH] CRED: ptrace_attach() should use the target process\'s mutex

Hello.

David Howells wrote:
> Tetsuo Handa wrote:
> 
> > Thus, I'm trying to use
> > 
> >   struct execve_entry {
> >          struct list_head list;
> >          struct task_struct *task;
> >   };
> > ...
> 
> It might be better to see about setting a flag in the task_struct.  All you
> need is a single bit, and since it's process-local it doesn't need any funny
> locking stuff.

Indeed. If I can use one bit in the task_struct, I don't need to add
security_start_execve() / security_finish_execve() hooks.

Now, I cancel the previous patch and propose this patch.

Thanks.
----------
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.

Signed-off-by: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
---
 fs/compat.c           |    4 ++++
 fs/exec.c             |    4 ++++
 include/linux/sched.h |    1 +
 3 files changed, 9 insertions(+)

--- linux-2.6.27-rc8-mm1.orig/fs/compat.c
+++ linux-2.6.27-rc8-mm1/fs/compat.c
@@ -1387,6 +1387,8 @@ int compat_do_execve(char * filename,
 	struct linux_binprm *bprm;
 	struct file *file;
 	int retval;
+	struct task_struct *task = current;
+	task->in_execve = 1;
 
 	retval = -ENOMEM;
 	bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
@@ -1443,6 +1445,7 @@ int compat_do_execve(char * filename,
 		security_bprm_free(bprm);
 		acct_update_integrals(current);
 		free_bprm(bprm);
+		task->in_execve = 0;
 		return retval;
 	}
 
@@ -1464,6 +1467,7 @@ out_kfree:
 	free_bprm(bprm);
 
 out_ret:
+	task->in_execve = 0;
 	return retval;
 }
 
--- linux-2.6.27-rc8-mm1.orig/fs/exec.c
+++ linux-2.6.27-rc8-mm1/fs/exec.c
@@ -1275,6 +1275,8 @@ int do_execve(char * filename,
 	struct file *file;
 	struct files_struct *displaced;
 	int retval;
+	struct task_struct *task = current;
+	task->in_execve = 1;
 
 	retval = unshare_files(&displaced);
 	if (retval)
@@ -1338,6 +1340,7 @@ int do_execve(char * filename,
 		free_bprm(bprm);
 		if (displaced)
 			put_files_struct(displaced);
+		task->in_execve = 0;
 		return retval;
 	}
 
@@ -1361,6 +1364,7 @@ out_files:
 	if (displaced)
 		reset_files_struct(displaced);
 out_ret:
+	task->in_execve = 0;
 	return retval;
 }
 
--- linux-2.6.27-rc8-mm1.orig/include/linux/sched.h
+++ linux-2.6.27-rc8-mm1/include/linux/sched.h
@@ -1088,6 +1088,7 @@ struct task_struct {
 	/* ??? */
 	unsigned int personality;
 	unsigned did_exec:1;
+	unsigned in_execve:1;
 	pid_t pid;
 	pid_t tgid;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ