NFSD: Fix permission check for read access to executable-only files
Subsystems (2)
PATCH 1/1 NFSD: Fix permission check for read access to executable-only files
Commit abc02e5602f7 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
--- fs/nfsd/vfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/vfs.c +2 -2
@@ -2865,8 +2865,8 @@ nfsd_permission(struct svc_cred *cred, struct svc_export *exp,/* Allow read access to binaries even when mode 111 */ if (err == -EACCES &&S_ISREG (inode->i_mode) && - (acc == (NFSD_MAY_READ |NFSD_MAY_OWNER_OVERRIDE ) || - acc == (NFSD_MAY_READ |NFSD_MAY_READ_IF_EXEC ))) + (((acc &NFSD_MAY_MASK ) ==NFSD_MAY_READ ) && + (acc & (NFSD_MAY_OWNER_OVERRIDE |NFSD_MAY_READ_IF_EXEC )))) err =inode_permission (&nop_mnt_idmap, inode,MAY_EXEC );return err?nfserrno (err) :0 ;
Signature · 1 line
2.51.0
Quoted 23 lines · Scott Mayhew
Commit
abc02e5602f7addedNFSD_MAY_OWNER_OVERRIDEto the access flags passed fromnfsd4_layoutget()tofh_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 exactlyNFSD_MAY_READ
2. The "hints" portion of the access flags (the upper 26 bits) can contain any combination ofNFSD_MAY_OWNER_OVERRIDEandNFSD_MAY_READ_IF_EXECFixes abc02e5602f7 ("NFSD: Support write delegations in LAYOUTGET")Signed-off-by Scott Mayhew <[email protected]>--- fs/nfsd/vfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/nfsd/vfs.c +0
-0
fs/nfsd/vfs.c nfsd_permission(struct svc_cred *cred, struct svc_export *exp, · line 2870
Quoted 8 lines
fs/nfsd/vfs.c +2
-2@@ -2865,8 +2865,8 @@ nfsd_permission(struct svc_cred *cred, struct svc_export *exp,/* Allow read access to binaries even when mode 111 */ if (err == -EACCES &&S_ISREG (inode->i_mode) && - (acc == (NFSD_MAY_READ |NFSD_MAY_OWNER_OVERRIDE ) || - acc == (NFSD_MAY_READ |NFSD_MAY_READ_IF_EXEC ))) + (((acc &NFSD_MAY_MASK ) ==NFSD_MAY_READ ) && + (acc & (NFSD_MAY_OWNER_OVERRIDE |NFSD_MAY_READ_IF_EXEC )))) err =inode_permission (&nop_mnt_idmap, inode,MAY_EXEC );
The new code is cleaner and more correct - thanks.
NeilBrown
Quoted 6 lines
fs/nfsd/vfs.c +0
-0return err?nfserrno (err) :0 ;Signature · 1 line
2.51.0
Quoted 35 lines · NeilBrown
Quoted 23 lines · Scott Mayhew
Commit
abc02e5602f7addedNFSD_MAY_OWNER_OVERRIDEto the access flags passed fromnfsd4_layoutget()tofh_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 exactlyNFSD_MAY_READ
2. The "hints" portion of the access flags (the upper 26 bits) can contain any combination ofNFSD_MAY_OWNER_OVERRIDEandNFSD_MAY_READ_IF_EXECFixes abc02e5602f7 ("NFSD: Support write delegations in LAYOUTGET")Signed-off-by Scott Mayhew <[email protected]>--- fs/nfsd/vfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/nfsd/vfs.c +0
-0fs/nfsd/vfs.c nfsd_permission(struct svc_cred *cred, struct svc_export *exp, · line 2870
Quoted 8 lines
fs/nfsd/vfs.c +2
-2@@ -2865,8 +2865,8 @@ nfsd_permission(struct svc_cred *cred, struct svc_export *exp,/* Allow read access to binaries even when mode 111 */ if (err == -EACCES &&S_ISREG (inode->i_mode) && - (acc == (NFSD_MAY_READ |NFSD_MAY_OWNER_OVERRIDE ) || - acc == (NFSD_MAY_READ |NFSD_MAY_READ_IF_EXEC ))) + (((acc &NFSD_MAY_MASK ) ==NFSD_MAY_READ ) && + (acc & (NFSD_MAY_OWNER_OVERRIDE |NFSD_MAY_READ_IF_EXEC )))) err =inode_permission (&nop_mnt_idmap, inode,MAY_EXEC );Reviewed-by NeilBrown <[email protected]>
Quoted 3 lines
The new code is cleaner and more correct - thanks.
NeilBrown
Agreed.
Chuck Lever
maintainerFrom: Chuck Lever <[email protected]>
Quoted 5 lines · Scott Mayhew
Commit
abc02e5602f7addedNFSD_MAY_OWNER_OVERRIDEto the access flags passed fromnfsd4_layoutget()tofh_verify(). This causes LAYOUTGET to fail for executable-only files, and causes xfstests generic/126 to fail on pNFS SCSI.
Quoted 8 lines
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 exactlyNFSD_MAY_READ
2. The "hints" portion of the access flags (the upper 26 bits) can contain any combination ofNFSD_MAY_OWNER_OVERRIDEandNFSD_MAY_READ_IF_EXEC[...]
Applied to nfsd-testing, thanks!
[1/1] NFSD: Fix permission check for read access to executable-only files
commit: 2341758268d9bdc099c48fde624fee6d3754bb84
--
Chuck Lever