From: Olga Kornievskaia <okorniev@redhat.com>
To: trondmy@kernel.org, anna@kernel.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v3 4/4] NFSv4.1: protect destroying and nullifying bc_serv structure
Date: Mon, 3 Nov 2025 17:13:39 -0500 [thread overview]
Message-ID: <20251103221339.45145-5-okorniev@redhat.com> (raw)
In-Reply-To: <20251103221339.45145-1-okorniev@redhat.com>
When we are shutting down the client, we free the callback
server structure and then at a later pointer we free the
transport used by the client. Yet, it's possible that after
the callback server is freed, the transport receives a
backchannel request at which point we can dereferene freed
memory. Instead, do the freeing the bc server and nullying
bc_serv under the lock.
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
---
fs/nfs/callback.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 8b674ee093a6..58e865bba03f 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -270,7 +270,10 @@ void nfs_callback_down(int minorversion, struct net *net, struct rpc_xprt *xprt)
if (cb_info->users == 0) {
svc_set_num_threads(serv, NULL, 0);
dprintk("nfs_callback_down: service destroyed\n");
- svc_destroy(&cb_info->serv);
+ if (!minorversion)
+ svc_destroy(&cb_info->serv);
+ else
+ xprt_svc_destroy_nullify_bc(xprt, &cb_info->serv);
}
mutex_unlock(&nfs_callback_mutex);
}
--
2.47.1
next prev parent reply other threads:[~2025-11-03 22:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 22:13 [PATCH v3 0/4] protect access to bc_serv Olga Kornievskaia
2025-11-03 22:13 ` [PATCH v3 1/4] NFSv4.1: pass transport for callback shutdown Olga Kornievskaia
2025-11-03 22:13 ` [PATCH v3 2/4] SUNRPC: cleanup common code in backchannel request Olga Kornievskaia
2025-11-03 22:13 ` [PATCH v3 3/4] SUNRPC: new helper function for stopping backchannel server Olga Kornievskaia
2025-11-04 16:52 ` kernel test robot
2025-11-04 20:17 ` Anna Schumaker
2025-11-03 22:13 ` Olga Kornievskaia [this message]
2025-11-04 20:45 ` [PATCH v3 4/4] NFSv4.1: protect destroying and nullifying bc_serv structure Anna Schumaker
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=20251103221339.45145-5-okorniev@redhat.com \
--to=okorniev@redhat.com \
--cc=anna@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).