From: Stefan Metzmacher <metze@samba.org>
To: Paulo Alcantara <pc@manguebit.org>
Cc: metze@samba.org, Namjae Jeon <linkinjeon@kernel.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
stable@vger.kernel.org
Subject: [PATCH 0/8] smb: client: fix use-after-free of server->smbd_conn and the encryption nonce
Date: Fri, 27 Nov 2026 13:41:33 +0100 [thread overview]
Message-ID: <cover.1795782695.git.metze@samba.org> (raw)
Hi Paulo,
these are client fixes reported by Sashiko:
- smbd_get_parameters(), smbd_register_mr() and
smbd_debug_proc_show() used server->smbd_conn without any
locking, while cifs_abort_connection() can destroy it at any
time (use-after-free). server->smbd_conn is now only changed
under srv_lock and only used with a reference on its socket
(the new smbdirect_socket_get()/put()) or under the lock.
- smb3_negotiate_wsize() and smb3_negotiate_rsize() used the zero
limits of a missing connection during a reconnect, with signing
the header sizes were subtracted from 0, which underflows, so the
RDMA limit was lost.
- smbd_get_connection() returns the real error instead of -ENOENT,
the following patches depend on that.
- The nonce of encrypted messages is a 64-bit counter of the
session followed by random bits of the session, like Samba does,
instead of random bytes, which only made a reuse unlikely. With
AES-GCM a reused nonce reveals the authentication key.
"smb: smbdirect: add smbdirect_socket_get() and smbdirect_socket_put()"
touches fs/smb/smbdirect, it's only used by the client changes.
Reports fixed by this series:
- https://sashiko.dev/#/patchset/cover.1791225453.git.metze%40samba.org
smb: client: don't use server->smbd_conn without a reference or lock
- https://sashiko.dev/#/bug/linux-211bb822-8907-4243-9dd3-da2595595552
smb: client: don't use server->smbd_conn without a reference or lock
- https://sashiko.dev/#/bug/linux-d40006cd-d7c3-4ea8-8ebb-1bf2b55b0db0
smb: client: don't use zero RDMA limits without a connection
The other urgent fixes for fs/smb/smbdirect and ksmbd (including
the same nonce fix for the server) are posted separately, they are
independent of these, the remaining smbdirect fixes follow on top of
all of them.
This also covers the problem addressed by "[PATCH v3] smb: client:
protect server->smbd_conn with RCU and refcounting" from Qican Ma
(https://lore.kernel.org/all/179570959875.92741.4311009098248753929@gmail.com/),
without waiting for references in smbd_destroy(), which is called
with cifs_server_lock() held.
These patches were developed with the help of Claude (Anthropic),
which was used for code analysis, writing parts of the code and the
commit messages. I reviewed all changes and take full responsibility
for them.
Testing: on real hardware, client and server running the urgent
client and smbdirect series together, over RoCE with mlx5 (ConnectX),
irdma (Intel E810) and rxe:
- xfstests (59 tests of the cifs and generic groups) and O_DIRECT
reads/writes with data verification
- removing the local address or setting the link down while a
connection is established, the umount finishes in time
- 2x10 ksmbd restarts while I/O is running and
/proc/fs/cifs/DebugData is read in a loop, each restart reconnects
- mounts killed by a signal while their RDMA connect is pending
(the syzbot case), no tasks in D state and no warnings
Note I didn't test with iWarp as there are existing problems with it,
I have patches to fix iWarp, but I'll post them later, as they
also rely on some rdma-core changes.
As we are already late in the 7.4 cycle, I leave it up to you to
decide if they should still go into 7.4 or into the next merge
window, all of them are marked for stable.
Base: v7.4-rc4, like the other smb series. The patches also apply
cleanly (git am) on cifs-next (61c581ea62ee), on ksmbd-for-next
(3c31349456c5) and on both merged, with or without the urgent smbdirect
series, and build on both merged.
Stefan Metzmacher (8):
smb: smbdirect: add smbdirect_socket_get() and smbdirect_socket_put()
smb: client: return the real error from smbd_get_connection()
smb: client: change server->smbd_conn only under server->srv_lock
smb: client: pass server to smbd_get_parameters()
smb: client: pass server to smbd_register_mr()
smb: client: don't use server->smbd_conn without a reference or lock
smb: client: don't use zero RDMA limits without a connection
smb: client: use a counter for the nonce of encrypted messages
fs/smb/client/cifsglob.h | 3 +
fs/smb/client/connect.c | 18 ++--
fs/smb/client/file.c | 12 +--
fs/smb/client/misc.c | 2 +
fs/smb/client/smb2ops.c | 111 ++++++++++++++++++++-----
fs/smb/client/smb2pdu.c | 4 +-
fs/smb/client/smbdirect.c | 170 ++++++++++++++++++++++++++++++--------
fs/smb/client/smbdirect.h | 11 ++-
fs/smb/smbdirect/socket.c | 27 ++++++
include/linux/smbdirect.h | 3 +
10 files changed, 291 insertions(+), 70 deletions(-)
--
2.43.0
next reply other threads:[~2026-11-27 12:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 12:41 Stefan Metzmacher [this message]
2026-11-27 12:41 ` [PATCH 1/8] smb: smbdirect: add smbdirect_socket_get() and smbdirect_socket_put() Stefan Metzmacher
2026-11-27 12:41 ` [PATCH 2/8] smb: client: return the real error from smbd_get_connection() Stefan Metzmacher
2026-11-27 12:41 ` [PATCH 3/8] smb: client: change server->smbd_conn only under server->srv_lock Stefan Metzmacher
2026-11-27 12:41 ` [PATCH 4/8] smb: client: pass server to smbd_get_parameters() Stefan Metzmacher
2026-11-27 12:41 ` [PATCH 5/8] smb: client: pass server to smbd_register_mr() Stefan Metzmacher
2026-11-27 12:41 ` [PATCH 6/8] smb: client: don't use server->smbd_conn without a reference or lock Stefan Metzmacher
2026-11-27 12:41 ` [PATCH 7/8] smb: client: don't use zero RDMA limits without a connection Stefan Metzmacher
2026-11-27 12:41 ` [PATCH 8/8] smb: client: use a counter for the nonce of encrypted messages Stefan Metzmacher
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=cover.1795782695.git.metze@samba.org \
--to=metze@samba.org \
--cc=bharathsm@microsoft.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sprasad@microsoft.com \
--cc=stable@vger.kernel.org \
--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