Skip to content

smb: server: fix the nonce of encrypted responses and a listener leak

Stefan Metzmacher linux-cifs stable 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2smb: server: use a counter for the nonce of encrypted responsesfs/smb/server/auth.c fs/smb/server/auth.h fs/smb/server/mgmt/user_session.c +2 more+66 -100 replies
2/2smb: server: don't leak the smbdirect listener socket on errorsfs/smb/server/transport_rdma.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] smb: server: fix the nonce of encrypted responses and a listener leak

Hi Namjae,

these are fixes for ksmbd:

- The nonce of encrypted responses and of the payload of encrypted RDMA reads 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_direct_listen() leaked the smbdirect socket if binding or listening failed, e.g. with -EADDRINUSE (reported by Sashiko).

The client got the same nonce fix in the urgent client series, the urgent smbdirect fixes are posted separately as well, they are all independent of each other.

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, smbdirect and ksmbd series together:

- encrypted (seal) mounts over TCP and over RDMA (RoCE with mlx5 and irdma) with AES128-GCM and data verification
- ksmbd started while the RDMA port 445 is already in use, smbdirect_socket_bind() fails, no warnings and ksmbd starts again afterwards
- the RDMA tests of the urgent smbdirect series, including 10 ksmbd restarts per device while I/O is running

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, both 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 client and smbdirect series, and build on both merged.

Stefan Metzmacher (2):
smb: server: use a counter for the nonce of encrypted responses
smb: server: don't leak the smbdirect listener socket on errors

 fs/smb/server/auth.c              | 43 +++++++++++++++++++++++++++++++
 fs/smb/server/auth.h              |  4 +++
 fs/smb/server/mgmt/user_session.c |  1 +
 fs/smb/server/mgmt/user_session.h |  3 +++
 fs/smb/server/smb2pdu.c           | 25 +++++++++++-------
 fs/smb/server/transport_rdma.c    |  2 +-
 6 files changed, 67 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.0