Re: [RFC PATCH] NFSD: Replace use of NFSD_MAY_LOCK in nfsd4_lock()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2024-10-10 at 11:33 -0400, cel@xxxxxxxxxx wrote:
> From: Chuck Lever <chuck.lever@xxxxxxxxxx>
> 
> NFSv4 LOCK operations should not avoid the set of authorization
> checks that apply to all other NFSv4 operations. Also, the
> "no_auth_nlm" export option should apply only to NLM LOCK requests.
> It's not necessary or sensible to apply it to NFSv4 LOCK operations.
> 
> The replacement MAY bit mask,
> "NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE", comes from the access
> bits that are set in nfsd_permission() when the caller has set
> NFSD_MAY_LOCK.
> 
> Reported-by: NeilBrown <neilb@xxxxxxx>
> Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
> ---
>  fs/nfsd/nfs4state.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 9c2b1d251ab3..3f2c11414390 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -7967,11 +7967,10 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
>  	if (check_lock_length(lock->lk_offset, lock->lk_length))
>  		 return nfserr_inval;
>  
> -	if ((status = fh_verify(rqstp, &cstate->current_fh,
> -				S_IFREG, NFSD_MAY_LOCK))) {
> -		dprintk("NFSD: nfsd4_lock: permission denied!\n");
> +	status = fh_verify(rqstp, &cstate->current_fh, S_IFREG,
> +			   NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE);
> +	if (status != nfs_ok)
>  		return status;
> -	}
>  	sb = cstate->current_fh.fh_dentry->d_sb;
>  
>  	if (lock->lk_is_new) {

I would say this warrants a comment as to why you're not using
NFSD_MAY_LOCK here, but Neil's renaming patch takes care of that.

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux