From: Pavel Machek <pavel@denx.de>
To: Sasha Levin <sashal@kernel.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Kees Cook <keescook@chromium.org>,
Kentaro Takeda <takedakn@nttdata.co.jp>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Eric Biederman <ebiederm@xmission.com>,
Andrew Morton <akpm@linux-foundation.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, surenb@google.com,
michael.christie@oracle.com, mst@redhat.com, mjguzik@gmail.com,
npiggin@gmail.com, zhangpeng.00@bytedance.com, hca@linux.ibm.com
Subject: Re: [PATCH AUTOSEL 5.10 7/8] exec: Distinguish in_execve from in_exec
Date: Sun, 18 Feb 2024 20:12:56 +0100 [thread overview]
Message-ID: <ZdJWuMifIiNnrLbZ@duo.ucw.cz> (raw)
In-Reply-To: <20240202184156.541981-7-sashal@kernel.org>
[-- 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 --]
next prev parent reply other threads:[~2024-02-18 19:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240202184156.541981-1-sashal@kernel.org>
2024-02-02 18:41 ` Sasha Levin
2024-02-18 19:12 ` Pavel Machek [this message]
2024-02-22 12:36 ` Sasha Levin
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=ZdJWuMifIiNnrLbZ@duo.ucw.cz \
--to=pavel@denx.de \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=hca@linux.ibm.com \
--cc=jack@suse.cz \
--cc=juri.lelli@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=michael.christie@oracle.com \
--cc=mingo@redhat.com \
--cc=mjguzik@gmail.com \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=peterz@infradead.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=takedakn@nttdata.co.jp \
--cc=vincent.guittot@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zhangpeng.00@bytedance.com \
/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