Commit af7bb0d
exec: fix the racy usage of fs_struct->in_exec
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: [email protected]
Closes: https://lore.kernel.org/all/[email protected]/
Cc: [email protected]
Signed-off-by: Oleg Nesterov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Christian Brauner <[email protected]>1 parent 8661bb9 commit af7bb0d
1 file changed
+9
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1227 | 1227 | | |
1228 | 1228 | | |
1229 | 1229 | | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
| 1230 | + | |
1233 | 1231 | | |
1234 | 1232 | | |
1235 | 1233 | | |
1236 | | - | |
| 1234 | + | |
| 1235 | + | |
1237 | 1236 | | |
1238 | 1237 | | |
1239 | 1238 | | |
| |||
1495 | 1494 | | |
1496 | 1495 | | |
1497 | 1496 | | |
| 1497 | + | |
| 1498 | + | |
1498 | 1499 | | |
1499 | 1500 | | |
1500 | 1501 | | |
| |||
1616 | 1617 | | |
1617 | 1618 | | |
1618 | 1619 | | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
1619 | 1624 | | |
1620 | 1625 | | |
1621 | 1626 | | |
| |||
1860 | 1865 | | |
1861 | 1866 | | |
1862 | 1867 | | |
1863 | | - | |
1864 | 1868 | | |
1865 | 1869 | | |
1866 | 1870 | | |
| |||
1879 | 1883 | | |
1880 | 1884 | | |
1881 | 1885 | | |
1882 | | - | |
1883 | 1886 | | |
1884 | 1887 | | |
1885 | 1888 | | |
| |||
0 commit comments