Commit 753a620
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 72a3b5c commit 753a620
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1257 | 1257 | | |
1258 | 1258 | | |
1259 | 1259 | | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
| 1260 | + | |
1263 | 1261 | | |
1264 | 1262 | | |
1265 | 1263 | | |
1266 | | - | |
| 1264 | + | |
| 1265 | + | |
1267 | 1266 | | |
1268 | 1267 | | |
1269 | 1268 | | |
| |||
1516 | 1515 | | |
1517 | 1516 | | |
1518 | 1517 | | |
| 1518 | + | |
| 1519 | + | |
1519 | 1520 | | |
1520 | 1521 | | |
1521 | 1522 | | |
| |||
1604 | 1605 | | |
1605 | 1606 | | |
1606 | 1607 | | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
1607 | 1612 | | |
1608 | 1613 | | |
1609 | 1614 | | |
| |||
1890 | 1895 | | |
1891 | 1896 | | |
1892 | 1897 | | |
1893 | | - | |
1894 | 1898 | | |
1895 | 1899 | | |
1896 | 1900 | | |
| |||
1910 | 1914 | | |
1911 | 1915 | | |
1912 | 1916 | | |
1913 | | - | |
1914 | 1917 | | |
1915 | 1918 | | |
1916 | 1919 | | |
| |||
0 commit comments