Skip to content

Commit 90383cc

Browse files
committed
exec: Distinguish in_execve from in_exec
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 <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jan Kara <[email protected]> Cc: Eric Biederman <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 84c39ec commit 90383cc

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

fs/exec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
16331633
}
16341634
rcu_read_unlock();
16351635

1636+
/* "users" and "in_exec" locked for copy_fs() */
16361637
if (p->fs->users > n_fs)
16371638
bprm->unsafe |= LSM_UNSAFE_SHARE;
16381639
else

include/linux/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ struct task_struct {
920920
unsigned sched_rt_mutex:1;
921921
#endif
922922

923-
/* Bit to tell LSMs we're in execve(): */
923+
/* Bit to tell TOMOYO we're in execve(): */
924924
unsigned in_execve:1;
925925
unsigned in_iowait:1;
926926
#ifndef TIF_RESTORE_SIGMASK

kernel/fork.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,7 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
17481748
if (clone_flags & CLONE_FS) {
17491749
/* tsk->fs is already what we want */
17501750
spin_lock(&fs->lock);
1751+
/* "users" and "in_exec" locked for check_unsafe_exec() */
17511752
if (fs->in_exec) {
17521753
spin_unlock(&fs->lock);
17531754
return -EAGAIN;

0 commit comments

Comments
 (0)