crosvm/seccomp/x86_64
Chirantan Ekbote b696d4feb2 fs: Don't use path-based operations
There are no *at variants for the xattr syscalls so we were using the
path-based variants by reading the /proc/self/fd symlink.  While this
symlink can track renames it cannot track if the user hard links the
file to some other location and then unlinks the original location.  In
this case the symlink simply shows that the path was deleted even though
the fd is still valid.

To deal with this, stop using the path-based method.  For regular files
and directories, we can simply open them and then make the appropriate
f{get,set,list,remove}xattr syscall.  For non-regular files and
directories we can emulate an *at syscall by changing the CWD to /proc
and then making the path-based syscall via the self/fd path.  Even
though the symlink is no longer valid, manipulating the fd via this path
still works.

BUG=b:168689429
TEST=Create a file, set an xattr, hard link it to a new location,
     unlink the original, and then verify that {get,set}fattr still
     works on the new link

Change-Id: Ic291f432b96f18e3e7ccbcf27737d5f8fd240a65
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2437684
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-10-12 15:45:19 +00:00
..
9p_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
balloon_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
block_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
common_device.frequency seccomp: add frequency file to x86_64 2020-03-19 07:24:56 +00:00
common_device.policy seccomp: add frequency file to x86_64 2020-03-19 07:24:56 +00:00
cras_audio_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
fs_device.policy fs: Don't use path-based operations 2020-10-12 15:45:19 +00:00
gpu_device.policy devices: gpu: add support for mesa gpu shader cache 2020-09-29 19:02:24 +00:00
input_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
net_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
null_audio_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
pmem_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
rng_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
serial.policy crosvm: Support UnixDatagram sockets for serial output. 2020-07-16 00:05:19 +00:00
tpm_device.policy tpm: Update libtpm2 to master 2020-07-24 08:08:21 +00:00
vfio_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
vhost_net_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
vhost_vsock_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
video_device.policy seccomp: x86_64: Allow fstat for video device 2020-07-17 00:48:12 +00:00
wl_device.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00
xhci.policy seccomp: remove redundant unconditional rules 2020-01-22 17:36:36 +00:00