HomeFreeBSD

p9fs: Fix creating files with restrictive permissions

Description

p9fs: Fix creating files with restrictive permissions

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

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56494

Details

Provenance
arichardsonAuthored on May 7 2026, 4:23 AM
Reviewer
markj
Differential Revision
D56494: p9fs: Fix creating files with restrictive permissions
Parents
rG96b2f4a91241: p9fs: implement basic pathconf support
Branches
Unknown
Tags
Unknown