test: add overlay copy-up tests for FIFOs and sockets - #14075
Conversation
Add syscall coverage for lower-layer FIFOs and Unix sockets under overlayfs. Verify that write access fails with EACCES and writable opens fail with EPERM for non-copy-upable lower dentries. Adjust host FIFO and UDS fixtures so special-file attach mounts are omitted from overlay variants while preserving the directory-backed lower layers used by the tests. Updates google#13998 Assisted-by: ChatGPT
| add_host_fifo = True, | ||
| add_host_uds = True, | ||
| add_overlay = True, | ||
| allow_native = False, |
There was a problem hiding this comment.
Why "allow_native = False" ? The whole point of these tests is to test compatibility against Linux...
There was a problem hiding this comment.
Thank you! I originally set allow_native = False because the generated native syscall-test variant does not get the runner-provided overlay setup. In test/runner/defs.bzl, allow_native = True generates a native variant with overlay = False. As a result, my current native tests would just hit the IsOverlayfs() skip rather than actually exercise Linux overlayfs.
I also tested the equivalent setup manually on native Linux overlayfs on Ubuntu 22.04.5 LTS with kernel 6.8.0-136-generic. I observed:
access(path, W_OK)on lower FIFO/socket succeeds.open(FIFO, O_WRONLY | O_NONBLOCK)returnsENXIOwhen there is no reader.- This differs from the current gVisor expectations of
EACCES/EPERM.
Would you prefer that I update the expected behavior accordingly?
Also, for the native variant, would you recommend having the test create its own Linux overlayfs setup (lower/upper/work/merged), or extending the runner so that the native variant gets an overlay-backed test tree as well? I don't see an existing syscall_test option that generates a native variant with the runner's overlay setup, so I'd appreciate your guidance on which approach fits the test infrastructure better.
There was a problem hiding this comment.
Hmm I see. IMO it makes sense to do it right and extend the runner, and yeah for those places where we have a divergence with Linux we should fix it unless it's there for a specific reason.
@milantracy WDYT?
Description
Add
CopyUpTestcoverage for non-copy-upable lower-layer FIFOs and Unix domain sockets under overlayfs.The tests verify that:
access(..., W_OK)fails withEACCESfor lower-layer FIFOs and sockets.open(O_WRONLY)fails withEPERMinstead of proceeding through an invalid copy-up path.The host FIFO and UDS test fixtures are also adjusted for overlay variants. Individual special-file bind mounts are omitted because a FIFO or socket cannot itself be used as an overlay lower root, while the directory-backed mounts remain available to expose these files as lower-layer dentries.
This covers the non-copy-upable FIFO/socket cases from #13998. The remaining copy-up trigger, permission, and read-only mount cases can be covered separately.
Updates #13998
Testing
make syscall-tests OPTIONS="--nocache_test_results" TARGETS="//test/syscalls:copy_up_test_runsc_systrap_overlay"make syscall-tests OPTIONS="--nocache_test_results" TARGETS="//test/syscalls:copy_up_test_runsc_systrap_directfs"make syscall-tests OPTIONS="--nocache_test_results" TARGETS="//test/syscalls:pipe_external_test_runsc_systrap_directfs"make syscall-tests OPTIONS="--nocache_test_results" TARGETS="//test/syscalls:connect_external_test_runsc_systrap_directfs"make test TARGETS="//test/runner:runner_nogo"Also verified the regression coverage by locally restoring the writable-open ordering that previously bypassed the non-copy-upable lower-layer check:
LowerFIFOOpenForWriteFailsfailed withEROFSinstead of the expectedEPERM. Restoring the current implementation makes the test pass.