Page MenuHomeFreeBSD

p9fs: Fix creating files with restrictive permissions
ClosedPublic

Authored by arichardson on Sat, Apr 18, 5:58 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 15, 7:18 AM
Unknown Object (File)
Thu, May 14, 11:36 PM
Unknown Object (File)
Thu, May 14, 7:30 PM
Unknown Object (File)
Thu, May 14, 7:20 PM
Unknown Object (File)
Wed, May 13, 6:07 PM
Unknown Object (File)
Tue, May 12, 7:10 PM
Unknown Object (File)
Tue, May 12, 11:53 AM
Unknown Object (File)
Tue, May 12, 1:43 AM
Subscribers

Details

Summary

When a file is created via p9fs with restrictive permissions (like 000),
the 9P TCREATE request successfully creates and natively opens the file,
returning an open, writable file descriptor. Previously, p9fs would
attempt a subsequent TOPEN. That TOPEN would fail with EACCES due to the
restrictive mode, leaving a 0-byte file and causing operations like 'mv'
to abort.

We now preserve the writable descriptor returned by TCREATE so that the
subsequent VOP_OPEN can use it directly, avoiding the failing TOPEN.
Additionally, p9fs_compatible_mode now appropriately isolates the base
access intent when matching fids, preventing extended flags from
breaking the match.

A test case for this behavior has been submitted to pjdfstest:
https://github.com/pjd/pjdfstest/pull/87

Resolves: https://github.com/CTSRD-CHERI/cheribsd/issues/2617

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Tue, Apr 21, 1:04 PM
jhb added inline comments.
sys/fs/p9fs/p9fs_subr.c
284

An old bug perhaps, but what about O_EXEC? Hmm, seems that isn't handled elsewhere either (e.g. in p9fs_uflags_mode() over in p9fs_vnops.c), so not anything trivial to try to handle here.