lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <176042088276.1793333.12640300967459688183@noble.neil.brown.name>
Date: Tue, 14 Oct 2025 16:48:02 +1100
From: NeilBrown <neilb@...mail.net>
To: "Jeff Layton" <jlayton@...nel.org>
Cc: "Miklos Szeredi" <miklos@...redi.hu>,
 "Alexander Viro" <viro@...iv.linux.org.uk>,
 "Christian Brauner" <brauner@...nel.org>, "Jan Kara" <jack@...e.cz>,
 "Chuck Lever" <chuck.lever@...cle.com>,
 "Alexander Aring" <alex.aring@...il.com>,
 "Trond Myklebust" <trondmy@...nel.org>,
 "Anna Schumaker" <anna@...nel.org>, "Steve French" <sfrench@...ba.org>,
 "Paulo Alcantara" <pc@...guebit.org>,
 "Ronnie Sahlberg" <ronniesahlberg@...il.com>,
 "Shyam Prasad N" <sprasad@...rosoft.com>, "Tom Talpey" <tom@...pey.com>,
 "Bharath SM" <bharathsm@...rosoft.com>,
 "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
 "Rafael J. Wysocki" <rafael@...nel.org>,
 "Danilo Krummrich" <dakr@...nel.org>,
 "David Howells" <dhowells@...hat.com>, "Tyler Hicks" <code@...icks.com>,
 "Olga Kornievskaia" <okorniev@...hat.com>,
 "Dai Ngo" <Dai.Ngo@...cle.com>, "Amir Goldstein" <amir73il@...il.com>,
 "Namjae Jeon" <linkinjeon@...nel.org>,
 "Steve French" <smfrench@...il.com>,
 "Sergey Senozhatsky" <senozhatsky@...omium.org>,
 "Carlos Maiolino" <cem@...nel.org>,
 "Kuniyuki Iwashima" <kuniyu@...gle.com>,
 "David S. Miller" <davem@...emloft.net>,
 "Eric Dumazet" <edumazet@...gle.com>, "Jakub Kicinski" <kuba@...nel.org>,
 "Paolo Abeni" <pabeni@...hat.com>, "Simon Horman" <horms@...nel.org>,
 linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-nfs@...r.kernel.org, linux-cifs@...r.kernel.org,
 samba-technical@...ts.samba.org, netfs@...ts.linux.dev,
 ecryptfs@...r.kernel.org, linux-unionfs@...r.kernel.org,
 linux-xfs@...r.kernel.org, netdev@...r.kernel.org,
 "Jeff Layton" <jlayton@...nel.org>
Subject:
 Re: [PATCH 12/13] nfsd: check for delegation conflicts vs. the same client

On Tue, 14 Oct 2025, Jeff Layton wrote:
> RFC 8881 requires that the server reply with GDD_UNAVAIL when the client

GDD4_UNAVAIL.  Then "git grep" finds it for me.

NeilBrown


> requests a directory delegation that it already holds.
> 
> When setting a directory delegation, check that the client associated
> with the stateid doesn't match an existing delegation. If it does,
> reject the setlease attempt.
> 
> Signed-off-by: Jeff Layton <jlayton@...nel.org>
> ---
>  fs/nfsd/nfs4state.c | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index b06591f154aa372db710e071c69260f4639956d7..011e336dfd996daa82b706c3536628971369fb10 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -88,6 +88,7 @@ void nfsd4_end_grace(struct nfsd_net *nn);
>  static void _free_cpntf_state_locked(struct nfsd_net *nn, struct nfs4_cpntf_state *cps);
>  static void nfsd4_file_hash_remove(struct nfs4_file *fi);
>  static void deleg_reaper(struct nfsd_net *nn);
> +static bool nfsd_dir_may_setlease(struct file_lease *new, struct file_lease *old);
>  
>  /* Locking: */
>  
> @@ -5550,6 +5551,31 @@ static const struct lease_manager_operations nfsd_lease_mng_ops = {
>  	.lm_change = nfsd_change_deleg_cb,
>  };
>  
> +static const struct lease_manager_operations nfsd_dir_lease_mng_ops = {
> +	.lm_breaker_owns_lease = nfsd_breaker_owns_lease,
> +	.lm_break = nfsd_break_deleg_cb,
> +	.lm_change = nfsd_change_deleg_cb,
> +	.lm_may_setlease = nfsd_dir_may_setlease,
> +};
> +
> +static bool
> +nfsd_dir_may_setlease(struct file_lease *new, struct file_lease *old)
> +{
> +	struct nfs4_delegation *od, *nd;
> +
> +	/* Only conflicts with other nfsd dir delegs */
> +	if (old->fl_lmops != &nfsd_dir_lease_mng_ops)
> +		return true;
> +
> +	od = old->c.flc_owner;
> +	nd = new->c.flc_owner;
> +
> +	/* Are these for the same client? No bueno if so */
> +	if (od->dl_stid.sc_client == nd->dl_stid.sc_client)
> +		return false;
> +	return true;
> +}
> +
>  static __be32 nfsd4_check_seqid(struct nfsd4_compound_state *cstate, struct nfs4_stateowner *so, u32 seqid)
>  {
>  	if (nfsd4_has_session(cstate))
> @@ -5888,12 +5914,13 @@ static struct file_lease *nfs4_alloc_init_lease(struct nfs4_delegation *dp)
>  	fl = locks_alloc_lease();
>  	if (!fl)
>  		return NULL;
> -	fl->fl_lmops = &nfsd_lease_mng_ops;
>  	fl->c.flc_flags = FL_DELEG;
>  	fl->c.flc_type = deleg_is_read(dp->dl_type) ? F_RDLCK : F_WRLCK;
>  	fl->c.flc_owner = (fl_owner_t)dp;
>  	fl->c.flc_pid = current->tgid;
>  	fl->c.flc_file = dp->dl_stid.sc_file->fi_deleg_file->nf_file;
> +	fl->fl_lmops = S_ISDIR(file_inode(fl->c.flc_file)->i_mode) ?
> +				&nfsd_dir_lease_mng_ops : &nfsd_lease_mng_ops;
>  	return fl;
>  }
>  
> 
> -- 
> 2.51.0
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ