Skip to content

Commit 2aa7c57

Browse files
committed
NFSD: Support write delegations in LAYOUTGET
JIRA: https://issues.redhat.com/browse/RHEL-53004 commit abc02e5 Author: Chuck Lever <chuck.lever@oracle.com> Date: Tue Jun 11 15:36:46 2024 -0400 NFSD: Support write delegations in LAYOUTGET 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. Cc: Christoph Hellwig <hch@lst.de> Cc: stable@vger.kernel.org # v6.6+ Message-Id: 4E9C0D74-A06D-4DC3-A48A-73034DC40395@oracle.com Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
1 parent b64aae3 commit 2aa7c57

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ nfsd4_layoutget(struct svc_rqst *rqstp,
22552255
const struct nfsd4_layout_ops *ops;
22562256
struct nfs4_layout_stateid *ls;
22572257
__be32 nfserr;
2258-
int accmode = NFSD_MAY_READ_IF_EXEC;
2258+
int accmode = NFSD_MAY_READ_IF_EXEC | NFSD_MAY_OWNER_OVERRIDE;
22592259

22602260
switch (lgp->lg_seg.iomode) {
22612261
case IOMODE_READ:
@@ -2345,7 +2345,8 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp,
23452345
struct nfs4_layout_stateid *ls;
23462346
__be32 nfserr;
23472347

2348-
nfserr = fh_verify(rqstp, current_fh, 0, NFSD_MAY_WRITE);
2348+
nfserr = fh_verify(rqstp, current_fh, 0,
2349+
NFSD_MAY_WRITE | NFSD_MAY_OWNER_OVERRIDE);
23492350
if (nfserr)
23502351
goto out;
23512352

0 commit comments

Comments
 (0)