Skip to content

Commit 54b1a62

Browse files
committed
procfs: add note about exporting
libpathrs has a minimal resolver for procfs, which protects against static overmounts and bad symlinks as well as a few other protections. If we want to export procThreadSelf we would need to reimplement them, which is not really worth it in my view. Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 2cc3429 commit 54b1a62

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

procfs_linux.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ type procThreadSelfCloser func()
207207
//
208208
// This is similar to ProcThreadSelf from runc, but with extra hardening
209209
// applied and using *os.File.
210+
//
211+
// NOTE: THIS IS NOT YET SAFE TO EXPORT. The non-openat2(2) case is just using
212+
// a plain openat(2), which is not entirely safe against overmount attacks.
213+
// Yes, if we are using fsopen(2) or open_tree(2) (without AT_RECURSIVE), then
214+
// this is safe, but we shouldn't make less privileged users (or users on older
215+
// kernels) incorrectly assume this is safe. libpathrs does it correctly, and
216+
// it's best to leave it to them.
210217
func procThreadSelf(procRoot *os.File, subpath string) (_ *os.File, _ procThreadSelfCloser, Err error) {
211218
// We need to lock our thread until the caller is done with the handle
212219
// because between getting the handle and using it we could get interrupted

0 commit comments

Comments
 (0)