From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52CB436AB4B; Fri, 12 Jun 2026 18:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781287746; cv=none; b=ndyiDZyaUNLRj/STOB7+cxvJ3y6AciiWr5VOWtoEevWn3sY3oK2saRK9O/Sjz6zgSCkgI56pumS/jK8qwvz/4x5tKYG1nA+oWjaE0tAdBwHCdXVSoTYgU5Q4Y9l/Xb2xT03zhz2RaDH9Ncd7gLVBPmoNxsxPhKwOQFhoitUt5jk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781287746; c=relaxed/simple; bh=XdFHiaYZarqAKmkJa+iYPf/j0N0krP2g2DDOH6NN7Ps=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=bqSt7AlP9LMDrqLnRAsdSTcF6+ZMSZHCeMDynoNAffL2m7c4aSNzq4JCObg58B7yG9sOoB2iZMa8HHekyojnMkZn4czojbJLJ8+mwjStYiOy5aGcU9wvmwdnmRXlpArGhPRujwwwYbDAQVf+s9Fh6yW5LQnGXzmzG//5GdqvX3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZzvCtgqA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZzvCtgqA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 890BA1F00A3A; Fri, 12 Jun 2026 18:09:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781287745; bh=zvTL2w1yOSiSnSotjK2o1/0Kkp/uJrKD7/9wya/Zpzw=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=ZzvCtgqAbzBY+ouZlRzFOTfn4ei0rcj3oJ1jhfacHBB+CE835OXU9wE6Ns4JUdLDs Ju1LwhrjdNGczdq+dBPGYt2rqlTpsE7FxYs7zDAAl8kqXwZE2EILCNEm/y2iqH9CV6 gNzrph5iyCHrov9fhCypKKKkA36LF241H6ZEgcSAahy9C6MJfqK8E4YdQtt0okDvBV afsGGxfDLXtF5t/Pm1dE43YR3IheRZ4jnhu5hPielErRv/2GgIXxru30KCdG/MX/GA luTQpKP+p8Z4dfORWfKYl6GAZSuz26IauUxPcoQ5l8h9i0SdwW240jO/DsaUafC/2Q lGZ0emO7nlBVg== Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfauth.phl.internal (Postfix) with ESMTP id BBE0CF4006B; Fri, 12 Jun 2026 14:09:03 -0400 (EDT) Received: from phl-imap-15 ([10.202.2.104]) by phl-compute-10.internal (MEProxy); Fri, 12 Jun 2026 14:09:03 -0400 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTEQVELxuIX5+6rKVVQ926Wl5DU2GmSvdAPFG/0Ke+QSAVWRvCR1IXSq1KOzPMNRMb VFMkRhugKoRNkb6sMdPc5nqoFzXrGDRQoGJmktwH0eB8gaE4e6Jaaxh7gf4JGEpNwHfq2v Ge4thWzB9KFn20yURN++icHqDtZ+TRmFIB991ERKcNJd4BQvyW+SDZZ85qmnq/kGRCjqY8 Z336i0BsnjMb27pibMWFB11HQaO/h4mPZYvLWTGgM+NJz955s0GywV6O2KBwnGEUzAOCx3 fZzxSN6LgHJfp/tCw7y1PEFhPgBlTnZoFFeYFC/UwigEyQFq/Xd3ZcxZEmvDpGKcdn2Zjw 4OXmsbOa0ZPvp8iNCmn40/gDLJigkZC0gJRKLGdFnoeulDTkjtkRI+WFJeHa4sdCySk3rf f4hPCbHGbp9E30wbH6ny/uLVo82qHh8m/NF3Q18q04gTiRlahWXw9FjY495Hgg7aqxPPRL fhx6TZKlt9hduP7DhU6SZP91P9xPFWcdA4MAQagYpTHsPOx2NDR+GW7ez6UsySrT8VSr60 Wlh0oYychgOjCOd4nuUo5uX9i5E5DVdYMDy66Kh1MeNVkkQacmV6O3sJJWT5dp9UnXGZP4 Ghq9yMTvUxWds+SuTAE47uBdegaF9VewcXWRH5n2M1Az095plC8GlhNiPFIA X-ME-Proxy: Feedback-ID: ifa6e4810:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 91C83780070; Fri, 12 Jun 2026 14:09:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: AcMjPYD26Dvc Date: Fri, 12 Jun 2026 14:08:42 -0400 From: "Chuck Lever" To: "Jeff Layton" , NeilBrown , "Olga Kornievskaia" , "Dai Ngo" , "Tom Talpey" , "Trond Myklebust" , "Anna Schumaker" , "Jonathan Corbet" , "Shuah Khan" Cc: "Steven Rostedt" , "Alexander Aring" , "Amir Goldstein" , "Jan Kara" , "Alexander Viro" , "Christian Brauner" , "Calum Mackay" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-nfs@vger.kernel.org Message-Id: In-Reply-To: <20260611-dir-deleg-v6-17-4c45080e5f3f@kernel.org> References: <20260611-dir-deleg-v6-0-4c45080e5f3f@kernel.org> <20260611-dir-deleg-v6-17-4c45080e5f3f@kernel.org> Subject: Re: [PATCH v6 17/20] nfsd: add the filehandle to returned attributes in CB_NOTIFY Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, Jun 11, 2026, at 1:50 PM, Jeff Layton wrote: > nfsd's usual fh_compose routine requires a svc_export and fills out a > svc_fh. In the context of a CB_NOTIFY there is no such export to > consult. > > Add a new routine that composes a filehandle with only a parent > filehandle and nfs4_file. Use that to fill out the fhandle field in the > nfsd4_fattr_args. > > Signed-off-by: Jeff Layton > --- > fs/nfsd/nfs4xdr.c | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index 7b19248b1503..15ccd54ffdb6 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -4197,6 +4197,39 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, > struct xdr_stream *xdr, > goto out; > } > > +static bool > +setup_notify_fhandle(struct dentry *dentry, struct nfs4_file *fi, > + struct nfsd_file *nf, struct nfsd4_fattr_args *args) > +{ > + int fileid_type, fsid_len, maxsize, flags = 0; > + struct knfsd_fh *fhp = &args->fhandle; > + struct inode *inode = d_inode(dentry); > + struct inode *parent = NULL; > + struct fid *fid; > + > + fsid_len = key_len(fi->fi_fhandle.fh_fsid_type); > + fhp->fh_size = 4 + fsid_len; > + > + /* Copy first 4 bytes + fsid */ > + memcpy(&fhp->fh_raw, &fi->fi_fhandle.fh_raw, fhp->fh_size); > + > + fid = (struct fid *)(fh_fsid(fhp) + fsid_len/4); > + maxsize = (NFS4_FHSIZE - fhp->fh_size)/4; > + > + if (fi->fi_connectable && !S_ISDIR(inode->i_mode)) { > + parent = d_inode(nf->nf_file->f_path.dentry); > + flags = EXPORT_FH_CONNECTABLE; > + } > + > + fileid_type = exportfs_encode_inode_fh(inode, fid, &maxsize, parent, > flags); > + if (fileid_type < 0 || fileid_type == FILEID_INVALID) > + return false; > + > + fhp->fh_fileid_type = fileid_type; > + fhp->fh_size += maxsize * 4; > + return true; > +} > + > #define CB_NOTIFY_STATX_REQUEST_MASK (STATX_BASIC_STATS | \ > STATX_BTIME | \ > STATX_CHANGE_COOKIE) > @@ -4206,6 +4239,7 @@ nfsd4_setup_notify_entry4(struct notify_entry4 > *ne, struct xdr_stream *xdr, > struct dentry *dentry, struct nfs4_delegation *dp, > struct nfsd_file *nf, char *name, u32 namelen) > { > + struct nfs4_file *fi = dp->dl_stid.sc_file; > struct path path = { .mnt = nf->nf_file->f_path.mnt, > .dentry = dentry }; > struct nfsd4_fattr_args args = { }; > @@ -4244,6 +4278,9 @@ nfsd4_setup_notify_entry4(struct notify_entry4 > *ne, struct xdr_stream *xdr, > FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_MODIFY; > attrmask[2] = 0; > > + if (setup_notify_fhandle(dentry, fi, nf, &args)) > + attrmask[0] |= FATTR4_WORD0_FILEHANDLE; > + > if (args.stat.result_mask & STATX_BTIME) > attrmask[1] |= FATTR4_WORD1_TIME_CREATE; > Codex flagged setup_notify_fhandle() for constructing a child FILEHANDLE attribute without calling fh_append_mac(): for exports with sign_fh, fh_compose() appends a MAC, and nfsd_set_fh_dentry() rejects every non-root signed-export handle whose MAC is absent or mismatched, so a client using the CB_NOTIFY filehandle gets a stale/bad handle. It recommends signing the constructed handle or suppressing the attribute when the export requires signed filehandles. A client that does not receive the FH falls back to a LOOKUP, so suppression degrades gracefully. -- Chuck Lever