On Tue, Jun 11, 2024 at 03:36:46PM -0400, cel@xxxxxxxxxx wrote: > From: Chuck Lever <chuck.lever@xxxxxxxxxx> > > I noticed LAYOUTGET(LAYOUTIOMODE4_RW) returning NFS4ERR_ACCESS > unexpectedly. The NFS client had created a file with mode 0444, and > the server had returned a write delegation on the OPEN(CREATE). The > client was requesting a RW layout using the write delegation stateid > so that it could flush file modifications. > > Creating a read-only file does not seem to be problematic for > NFSv4.1 without pNFS, so I began looking at NFSD's implementation of > LAYOUTGET. > > The failure was because fh_verify() was doing a permission check as > part of verifying the FH presented during the LAYOUTGET. It uses the > loga_iomode value to specify the @accmode argument to fh_verify(). > fh_verify(MAY_WRITE) on a file whose mode is 0444 fails with -EACCES. > > To permit LAYOUT* operations in this case, add OWNER_OVERRIDE when > checking the access permission of the incoming file handle for > LAYOUTGET and LAYOUTCOMMIT. This looks reasonable to me: Reviewed-by: Christoph Hellwig <hch@xxxxxx>