From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, 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 3/3] nfsd: recall deleg if a requested dir attr change can't be encoded
Date: Wed, 17 Jun 2026 14:12:31 -0400 [thread overview]
Message-ID: <20260617-dir-deleg-fixes-v1-3-32b85b366c29@kernel.org> (raw)
In-Reply-To: <20260617-dir-deleg-fixes-v1-0-32b85b366c29@kernel.org>
When the client requested NOTIFY4_CHANGE_DIR_ATTRS,
nfsd4_cb_notify_prepare() tried to append the dir attribute change to the
CB_NOTIFY, but silently dropped it if the attrmask space reservation
failed or nfsd4_encode_dir_attr_change() returned NULL (out of buffer
space, encode error, or no attributes to send). It then returned true
and transmitted a CB_NOTIFY lacking the requested notification, leaving
the client's cached directory attributes stale with no indication.
RFC 8881 s10.4 requires the server to recall the delegation when it
cannot deliver a requested notification. Treat a failure to encode the
dir attribute change like the per-event encode failures already handled
in the loop above: set error and fall through to out_recall.
Fixes: fd0d6dde2a57 ("nfsd: add support to CB_NOTIFY for dir attribute changes")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfsd/nfs4state.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b830aed7ae39..82125937dde2 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3598,23 +3598,30 @@ nfsd4_cb_notify_prepare(struct nfsd4_callback *cb)
put_event:
nfsd_notify_event_put(nne);
}
- if (!error) {
- if (dp->dl_notify_mask & BIT(NOTIFY4_CHANGE_DIR_ATTRS)) {
- u32 *maskp = (u32 *)xdr_reserve_space(&stream, sizeof(*maskp));
+ if (!error && (dp->dl_notify_mask & BIT(NOTIFY4_CHANGE_DIR_ATTRS))) {
+ u32 *maskp = (u32 *)xdr_reserve_space(&stream, sizeof(*maskp));
+ u8 *p = NULL;
- if (maskp) {
- u8 *p = nfsd4_encode_dir_attr_change(&stream, dp, nf);
-
- if (p) {
- *maskp = BIT(NOTIFY4_CHANGE_DIR_ATTRS);
- ncn->ncn_nf[count].notify_mask.count = 1;
- ncn->ncn_nf[count].notify_mask.element = maskp;
- ncn->ncn_nf[count].notify_vals.data = p;
- ncn->ncn_nf[count].notify_vals.len = (u8 *)stream.p - p;
- ++count;
- }
- }
+ if (maskp)
+ p = nfsd4_encode_dir_attr_change(&stream, dp, nf);
+ if (!p) {
+ /*
+ * The client asked to be told about dir attr changes
+ * but we couldn't encode one. RFC 8881 s10.4 requires
+ * recalling the delegation rather than dropping a
+ * requested notification, so fall through to recall.
+ */
+ error = true;
+ } else {
+ *maskp = BIT(NOTIFY4_CHANGE_DIR_ATTRS);
+ ncn->ncn_nf[count].notify_mask.count = 1;
+ ncn->ncn_nf[count].notify_mask.element = maskp;
+ ncn->ncn_nf[count].notify_vals.data = p;
+ ncn->ncn_nf[count].notify_vals.len = (u8 *)stream.p - p;
+ ++count;
}
+ }
+ if (!error) {
ncn->ncn_nf_cnt = count;
nfsd_file_put(nf);
return true;
--
2.54.0
prev parent reply other threads:[~2026-06-17 18:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 18:12 [PATCH 0/3] nfsd: follow-on fixes for CB_NOTIFY support Jeff Layton
2026-06-17 18:12 ` [PATCH 1/3] nfsd: fix CB_NOTIFY workqueue loop when queue overflows Jeff Layton
2026-06-17 18:12 ` [PATCH 2/3] nfsd: fix NULL deref / UAF of sc_export in setup_notify_fhandle Jeff Layton
2026-06-17 18:12 ` Jeff Layton [this message]
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=20260617-dir-deleg-fixes-v1-3-32b85b366c29@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=cel@kernel.org \
--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