openSUSE / libpathrs

C-friendly API to make path resolution safer on Linux.
GNU Lesser General Public License v3.0
80 stars 6 forks source link

opath resolver: implement fs.protected_symlinks emulation #63

Closed cyphar closed 2 months ago

cyphar commented 2 months ago

Because we resolve symlinks in userspace, fs.protected_symlinks doesn't get applied by the kernel to our lookups. While it's not really clear whether this is really necessary for scoped lookups, for consistency we should just emulate may_follow_link().

Unfortunately, checking fs.protected_symlinks requires looking at /proc/sys which can't be done with the currently-exposed ProcfsHandle API so we have to create a private API for that (until we come up with a nicer one for users to use). This also means that we can no longer apply "subset=pid" to fsopen-based procfs handles.

Fixes #58 Signed-off-by: Aleksa Sarai cyphar@cyphar.com