mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, NeilBrown <neil@brown.name>,
	 Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>,  Tom Talpey <tom@talpey.com>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Jeff Layton <jlayton@kernel.org>
Subject: [PATCH 2/4] nfsd: use empty string for directory name in NOTIFY4_CHANGE_DIR_ATTRS
Date: Sat, 23 May 2026 12:17:35 -0400	[thread overview]
Message-ID: <20260523-dir-deleg-fixes-v1-2-142c884f85ce@kernel.org> (raw)
In-Reply-To: <20260523-dir-deleg-fixes-v1-0-142c884f85ce@kernel.org>

RFC 8881 Section 10.4.3 specifies that for NOTIFY4_CHANGE_DIR_ATTRS
events, the ne_file component name must be a zero-length string. The
code was incorrectly using the directory's own dentry name, which
could leak the local namespace to the client and cause cache
confusion.

Pass an empty string and zero length instead, and remove the
now-unnecessary name_snapshot.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfsd/nfs4xdr.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 2f8d26601581..c6c50c376b23 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -4404,17 +4404,15 @@ u8 *nfsd4_encode_dir_attr_change(struct xdr_stream *xdr, struct nfs4_delegation
 {
 	struct dentry *dentry = nf->nf_file->f_path.dentry;
 	struct notify_attr4 na = { };
-	struct name_snapshot n;
 	bool ret;
 	u8 *p = NULL;
 
 	if (!(dp->dl_notify_mask & BIT(NOTIFY4_CHANGE_DIR_ATTRS)))
 		return NULL;
 
-	take_dentry_name_snapshot(&n, dentry);
+	/* RFC 8881 s10.4.3: ne_file must be a zero-length string for dir attrs */
 	ret = nfsd4_setup_notify_entry4(&na.na_changed_entry, xdr,
-					dentry, dp, nf, (char *)n.name.name,
-					n.name.len);
+					dentry, dp, nf, "", 0);
 
 	/* Don't bother with the event if we're not encoding attrs */
 	if (ret && na.na_changed_entry.ne_attrs.attr_vals.len) {
@@ -4422,7 +4420,6 @@ u8 *nfsd4_encode_dir_attr_change(struct xdr_stream *xdr, struct nfs4_delegation
 		if (!xdrgen_encode_notify_attr4(xdr, &na))
 			p = NULL;
 	}
-	release_dentry_name_snapshot(&n);
 	return p;
 }
 

-- 
2.54.0


  parent reply	other threads:[~2026-05-23 16:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23 16:17 [PATCH 0/4] nfsd: follow-on fixes for directory delegations Jeff Layton
2026-05-23 16:17 ` [PATCH 1/4] nfsd: check for FILEID_INVALID in setup_notify_fhandle Jeff Layton
2026-05-23 16:17 ` Jeff Layton [this message]
2026-05-23 16:17 ` [PATCH 3/4] nfsd: check delegation status in nfsd4_cb_notify_done Jeff Layton
2026-05-23 16:17 ` [PATCH 4/4] nfsd: fix ino_t format specifier in nfsd_handle_dir_event tracepoint Jeff Layton
2026-05-24 12:09   ` Jeff Layton
2026-05-24 17:44     ` Chuck Lever
2026-05-23 17:00 ` [PATCH 0/4] nfsd: follow-on fixes for directory delegations Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260523-dir-deleg-fixes-v1-2-142c884f85ce@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome