Commit a2e5edb
committed
syscalls: retry openat2 on -EAGAIN
In order to avoid in-kernel DoS due to unbounded retries, openat2(2)
will return -EAGAIN when trying to walk through ".." if there is any
racing rename or mount on the entire system.
Note that this applies regardless of whether the rename was on the same
filesytem or mount was in the same mount namespace as the process doing
openat(2) -- as a result, calling openat2(2) on even a modestly busy
system will result in spurious -EAGAIN errors every once in a while and
it is necessary to implement a retry loop for it. (Libraries such as
libpathrs and heavy users of openat2(2) like runc all do this, and in
our testing we found that ~256 iterations is enough to provide
resilience even on incredibly rename-heavy machines.)
Fixes: 4fa7156 ("syscall: use openat2(RESOLVE_BENEATH) on Linux for secure_relative_open")
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>1 parent f49a494 commit a2e5edb
1 file changed
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1806 | 1806 | | |
1807 | 1807 | | |
1808 | 1808 | | |
1809 | | - | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
1810 | 1815 | | |
1811 | | - | |
1812 | | - | |
1813 | | - | |
1814 | | - | |
1815 | | - | |
| 1816 | + | |
1816 | 1817 | | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
1817 | 1822 | | |
1818 | 1823 | | |
1819 | 1824 | | |
| |||
0 commit comments