]> git.hungrycats.org Git - bees/commit
roots: use openat2 instead of openat when available
authorZygo Blaxell <bees@furryterror.org>
Thu, 9 Jan 2025 07:20:11 +0000 (02:20 -0500)
committerZygo Blaxell <bees@furryterror.org>
Thu, 9 Jan 2025 07:26:53 +0000 (02:26 -0500)
commit2f2a68be3db5c323323e49c17395029a2ddc2d9a
tree919faacb275412d10e1facb297dbff05f84ca7f5
parent82f1fd8054364fd638c95e4e6a0f9e887bcb69bd
roots: use openat2 instead of openat when available

This increases resistance to symlink and mount attacks.

Previously, bees could follow a symlink or a mount point in a directory
component of a subvol or file name.  Once the file is opened, the open
file descriptor would be checked to see if its subvol and inode matches
the expected file in the target filesystem.  Files that fail to match
would be immediately closed.

With openat2 resolve flags, symlinks and mount points terminate path
resolution in the kernel.  Paths that lead through symlinks or onto
mount points cannot be opened at all.

Fall back to openat() if openat2() returns ENOSYS, so bees will still
run on kernels before v5.6.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-roots.cc