openSUSE / libpathrs

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

procfs: make is_subset check cheaper #90

Closed cyphar closed 1 month ago

cyphar commented 1 month ago

Allocating file descriptors for the is_subset check is completely unnecessary. We can just do a basic faccessat(2) check -- the paths we care about are very basic and we only care if they exist at all and not their contents or what they point to.

In addition, because we check /proc/1 and /proc/stat, using faccessat(2) will avoid us thinking that /proc is a subset if something has overmounted /proc/stat (technically is a subset but that's just a game of whack-a-mole we can't win).

Signed-off-by: Aleksa Sarai cyphar@cyphar.com