* [PATCH AUTOSEL 5.10 7/8] exec: Distinguish in_execve from in_exec [not found] <20240202184156.541981-1-sashal@kernel.org> @ 2024-02-02 18:41 ` Sasha Levin 2024-02-18 19:12 ` Pavel Machek 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2024-02-02 18:41 UTC (permalink / raw) To: linux-kernel, stable Cc: Kees Cook, Kentaro Takeda, Tetsuo Handa, Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman, Andrew Morton, Sebastian Andrzej Siewior, linux-fsdevel, linux-mm, Sasha Levin, mingo, peterz, juri.lelli, vincent.guittot, surenb, michael.christie, mst, mjguzik, npiggin, zhangpeng.00, hca From: Kees Cook <keescook@chromium.org> [ Upstream commit 90383cc07895183c75a0db2460301c2ffd912359 ] Just to help distinguish the fs->in_exec flag from the current->in_execve flag, add comments in check_unsafe_exec() and copy_fs() for more context. Also note that in_execve is only used by TOMOYO now. Cc: Kentaro Takeda <takedakn@nttdata.co.jp> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <brauner@kernel.org> Cc: Jan Kara <jack@suse.cz> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/exec.c | 1 + include/linux/sched.h | 2 +- kernel/fork.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/exec.c b/fs/exec.c index 983295c0b8ac..b809f4a39296 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1565,6 +1565,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm) } rcu_read_unlock(); + /* "users" and "in_exec" locked for copy_fs() */ if (p->fs->users > n_fs) bprm->unsafe |= LSM_UNSAFE_SHARE; else diff --git a/include/linux/sched.h b/include/linux/sched.h index aa015416c569..65cfe85de8d5 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -806,7 +806,7 @@ struct task_struct { */ unsigned sched_remote_wakeup:1; - /* Bit to tell LSMs we're in execve(): */ + /* Bit to tell TOMOYO we're in execve(): */ unsigned in_execve:1; unsigned in_iowait:1; #ifndef TIF_RESTORE_SIGMASK diff --git a/kernel/fork.c b/kernel/fork.c index 633b0af1d1a7..906dbaf25058 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1452,6 +1452,7 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) if (clone_flags & CLONE_FS) { /* tsk->fs is already what we want */ spin_lock(&fs->lock); + /* "users" and "in_exec" locked for check_unsafe_exec() */ if (fs->in_exec) { spin_unlock(&fs->lock); return -EAGAIN; -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 5.10 7/8] exec: Distinguish in_execve from in_exec 2024-02-02 18:41 ` [PATCH AUTOSEL 5.10 7/8] exec: Distinguish in_execve from in_exec Sasha Levin @ 2024-02-18 19:12 ` Pavel Machek 2024-02-22 12:36 ` Sasha Levin 0 siblings, 1 reply; 3+ messages in thread From: Pavel Machek @ 2024-02-18 19:12 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, stable, Kees Cook, Kentaro Takeda, Tetsuo Handa, Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman, Andrew Morton, Sebastian Andrzej Siewior, linux-fsdevel, linux-mm, mingo, peterz, juri.lelli, vincent.guittot, surenb, michael.christie, mst, mjguzik, npiggin, zhangpeng.00, hca [-- Attachment #1: Type: text/plain, Size: 1783 bytes --] Hi! > From: Kees Cook <keescook@chromium.org> > > [ Upstream commit 90383cc07895183c75a0db2460301c2ffd912359 ] > > Just to help distinguish the fs->in_exec flag from the current->in_execve > flag, add comments in check_unsafe_exec() and copy_fs() for more > context. Also note that in_execve is only used by TOMOYO now. These are just a whitespace changes, we should not need them. Best regards, Pavel > +++ b/fs/exec.c > @@ -1565,6 +1565,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm) > } > rcu_read_unlock(); > > + /* "users" and "in_exec" locked for copy_fs() */ > if (p->fs->users > n_fs) > bprm->unsafe |= LSM_UNSAFE_SHARE; > else > diff --git a/include/linux/sched.h b/include/linux/sched.h > index aa015416c569..65cfe85de8d5 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -806,7 +806,7 @@ struct task_struct { > */ > unsigned sched_remote_wakeup:1; > > - /* Bit to tell LSMs we're in execve(): */ > + /* Bit to tell TOMOYO we're in execve(): */ > unsigned in_execve:1; > unsigned in_iowait:1; > #ifndef TIF_RESTORE_SIGMASK > diff --git a/kernel/fork.c b/kernel/fork.c > index 633b0af1d1a7..906dbaf25058 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -1452,6 +1452,7 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) > if (clone_flags & CLONE_FS) { > /* tsk->fs is already what we want */ > spin_lock(&fs->lock); > + /* "users" and "in_exec" locked for check_unsafe_exec() */ > if (fs->in_exec) { > spin_unlock(&fs->lock); > return -EAGAIN; -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 5.10 7/8] exec: Distinguish in_execve from in_exec 2024-02-18 19:12 ` Pavel Machek @ 2024-02-22 12:36 ` Sasha Levin 0 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2024-02-22 12:36 UTC (permalink / raw) To: Pavel Machek Cc: linux-kernel, stable, Kees Cook, Kentaro Takeda, Tetsuo Handa, Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman, Andrew Morton, Sebastian Andrzej Siewior, linux-fsdevel, linux-mm, mingo, peterz, juri.lelli, vincent.guittot, surenb, michael.christie, mst, mjguzik, npiggin, zhangpeng.00, hca On Sun, Feb 18, 2024 at 08:12:56PM +0100, Pavel Machek wrote: >Hi! > >> From: Kees Cook <keescook@chromium.org> >> >> [ Upstream commit 90383cc07895183c75a0db2460301c2ffd912359 ] >> >> Just to help distinguish the fs->in_exec flag from the current->in_execve >> flag, add comments in check_unsafe_exec() and copy_fs() for more >> context. Also note that in_execve is only used by TOMOYO now. > >These are just a whitespace changes, we should not need them. Dropped, thanks! -- Thanks, Sasha ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-22 12:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240202184156.541981-1-sashal@kernel.org>
2024-02-02 18:41 ` [PATCH AUTOSEL 5.10 7/8] exec: Distinguish in_execve from in_exec Sasha Levin
2024-02-18 19:12 ` Pavel Machek
2024-02-22 12:36 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).