virtfs fails to access contents of non-readable directories
Host environment
- Operating system:
Linux Gentoo
- OS/kernel version:
Linux subaru 5.18.0-gentoo-x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 29 15:50:48 JST 2022 x86_64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz GenuineIntel GNU/Linux
- Architecture:
x86_64
- QEMU flavor:
qemu-system-x86_64
- QEMU version:
7.0.0
- QEMU command line:
qemu-system-x86_64 -virtfs local,path=$PWD/test,mount_tag=pkg,security_model=none,id=host0,multidevs=remap
(as normal user)
Emulated/Virtualized environment
- Operating system: Linux
- OS/kernel version:
Linux localhost 5.15.43-azusa #1 SMP Sun Jun 5 15:14:00 UTC 2022 x86_64 GNU/Linux
- Architecture: x86_64
Description of problem
Attempting to access a directory inside a non-readable directory via virtfs fails.
Steps to reproduce
On host:
mkdir -p test/foo/bar
echo hello world >test/foo/bar/baz.txt
chmod -r test/foo
The following works on host:
$ ls test
foo
$ ls test/foo
ls: cannot open directory 'test/foo': Permission denied
$ ls test/foo/bar
baz.txt
However on guest:
bash-5.1# ls /test/
foo
bash-5.1# ls /test/foo/
ls: cannot open directory '/test/foo/': Permission denied
bash-5.1# ls /test/foo/bar/
ls: cannot access '/test/foo/bar/': Permission denied
Additional information
I am guessing virtfs attempts to check rights (via access?) on the directory itself when obtaining an inode to give to the guest, however not having read access doesn't mean something can't be executed, especially for directories.
Edited by Mark Karpeles