Skip to content

Commit e901c7f

Browse files
scottmayhewchucklever
authored andcommitted
NFSD: Fix permission check for read access to executable-only files
Commit abc02e5 ("NFSD: Support write delegations in LAYOUTGET") added NFSD_MAY_OWNER_OVERRIDE to the access flags passed from nfsd4_layoutget() to fh_verify(). This causes LAYOUTGET to fail for executable-only files, and causes xfstests generic/126 to fail on pNFS SCSI. To allow read access to executable-only files, what we really want is: 1. The "permissions" portion of the access flags (the lower 6 bits) must be exactly NFSD_MAY_READ 2. The "hints" portion of the access flags (the upper 26 bits) can contain any combination of NFSD_MAY_OWNER_OVERRIDE and NFSD_MAY_READ_IF_EXEC Fixes: abc02e5 ("NFSD: Support write delegations in LAYOUTGET") Cc: stable@vger.kernel.org # v6.6+ Signed-off-by: Scott Mayhew <smayhew@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent c6c209c commit e901c7f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/nfsd/vfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,8 +2906,8 @@ nfsd_permission(struct svc_cred *cred, struct svc_export *exp,
29062906

29072907
/* Allow read access to binaries even when mode 111 */
29082908
if (err == -EACCES && S_ISREG(inode->i_mode) &&
2909-
(acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE) ||
2910-
acc == (NFSD_MAY_READ | NFSD_MAY_READ_IF_EXEC)))
2909+
(((acc & NFSD_MAY_MASK) == NFSD_MAY_READ) &&
2910+
(acc & (NFSD_MAY_OWNER_OVERRIDE | NFSD_MAY_READ_IF_EXEC))))
29112911
err = inode_permission(&nop_mnt_idmap, inode, MAY_EXEC);
29122912

29132913
return err? nfserrno(err) : 0;

0 commit comments

Comments
 (0)