Commit b519f2e
exec: fix the racy usage of fs_struct->in_exec
commit af7bb0d upstream.
check_unsafe_exec() sets fs->in_exec under cred_guard_mutex, then execve()
paths clear fs->in_exec lockless. This is fine if exec succeeds, but if it
fails we have the following race:
T1 sets fs->in_exec = 1, fails, drops cred_guard_mutex
T2 sets fs->in_exec = 1
T1 clears fs->in_exec
T2 continues with fs->in_exec == 0
Change fs/exec.c to clear fs->in_exec with cred_guard_mutex held.
Reported-by: syzbot+1c486d0b62032c82a968@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/67dc67f0.050a0220.25ae54.001f.GAE@google.com/
Cc: stable@vger.kernel.org
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/r/20250324160003.GA8878@redhat.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 717d9c3 commit b519f2e
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1229 | 1229 | | |
1230 | 1230 | | |
1231 | 1231 | | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
| 1232 | + | |
1235 | 1233 | | |
1236 | 1234 | | |
1237 | 1235 | | |
1238 | | - | |
| 1236 | + | |
| 1237 | + | |
1239 | 1238 | | |
1240 | 1239 | | |
1241 | 1240 | | |
| |||
1497 | 1496 | | |
1498 | 1497 | | |
1499 | 1498 | | |
| 1499 | + | |
| 1500 | + | |
1500 | 1501 | | |
1501 | 1502 | | |
1502 | 1503 | | |
| |||
1618 | 1619 | | |
1619 | 1620 | | |
1620 | 1621 | | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
1621 | 1626 | | |
1622 | 1627 | | |
1623 | 1628 | | |
| |||
1862 | 1867 | | |
1863 | 1868 | | |
1864 | 1869 | | |
1865 | | - | |
1866 | 1870 | | |
1867 | 1871 | | |
1868 | 1872 | | |
| |||
1881 | 1885 | | |
1882 | 1886 | | |
1883 | 1887 | | |
1884 | | - | |
1885 | 1888 | | |
1886 | 1889 | | |
1887 | 1890 | | |
| |||
0 commit comments