From: Michail Andreas Michalopoulos <mike.michalo@gmail.com>
To: linkinjeon@kernel.org, stfrench@microsoft.com
Cc: icb@fastmail.org, senozhatsky@chromium.org, tom@talpey.com,
chenxiaosong@chenxiaosong.com, ematsumiya@suse.de,
lsahlber@redhat.com, hyc.lee@gmail.com,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
Michail Andreas Michalopoulos <mike.michalo@gmail.com>
Subject: [PATCH v3 0/6] ksmbd: verify session setup requests before signing with their key
Date: Tue, 10 Nov 2026 02:41:38 +0700 [thread overview]
Message-ID: <20261109194144.22814-1-mike.michalo@gmail.com> (raw)
In-Reply-To: <CAKYAXd-Jo-ObBDs-AdGfaM+QmDsot3gj1g0oJiyDKczoUDg2TA@mail.gmail.com>
ksmbd signs some SESSION_SETUP and error responses with a session's key
without having verified the request, which lets a peer that does not hold
the key obtain signatures made with it. This series fixes those cases,
makes ksmbd sign with the SMB 3.1.1 signing algorithm it negotiated, and
fixes three related problems found in review of v2.
1/6 verifies multichannel binding requests with the session signing key
(MS-SMB2 3.3.5.2.4), as reported by Ian Bridges.
2/6 keeps the negotiated SMB 3.1.1 signing algorithm instead of always
using AES-CMAC, and signs each key with its own algorithm.
3/6 verifies signed reauthentication requests and uses the channel key
for session setup on a bound channel. A reauthentication with a
forged signature used to get a response signed with the session key.
4/6 checks the MessageId and signature of a request before signing
STATUS_NETWORK_SESSION_EXPIRED, also reported by Ian Bridges.
5/6 makes the signing decision in a compound follow each command's own
header instead of the first command's.
6/6 consumes the MessageId of a request on an unknown, invalid or
expired session, which the error path skipped.
Changes since v2, following Sashiko's review of v2:
- 1/6: correct a missing negation on the multichannel flag, so an SMB 3.x
binding request received while multichannel is disabled is verified
and rejected in the non-multichannel branch instead of falling through
to the reauthentication path.
- 3/6: also refuse an unsigned, unencrypted reauthentication when the
session requires signing or encryption. Negotiating encryption clears
sess->sign even when the connection required signing, so the v2 check
let such a reauthentication through. Merely having negotiated
encryption is not treated as a requirement, since clients routinely
negotiate it and then send unsigned, unencrypted requests.
- 5/6 is new. With signing not required, a signed later command was
processed without its signature being checked, a correctly signed one
got an unsigned response, and an unsigned one after a signed first
command was refused. It also decides whether to sign each response
before moving on to the next command of the compound.
- 6/6 is new. Only a signed request on an expired session had its
MessageId checked (by 4/6); any other failed-session request left it
unconsumed, pinning the command sequence window and letting a replayed
MessageId be answered again. 4/6's own check moves to the common path,
so the MessageId is consumed exactly once.
Testing, on a KASAN/lockdep UML kernel with ksmbd-tools:
- forged and replayed binding, reauthentication and expired-session
requests, also inside compounds, get unsigned refusals with AES-CMAC
and HMAC-SHA256;
- new targeted tests for 3/6, 5/6 and 6/6, each failing on the kernel
without the fix and passing with it (5/6: each response of a compound
mixing signed and unsigned commands is signed exactly when its request
is). The 3/6 test uses an SMB 3.1.1 client with AES-128-GCM
encryption: an unsigned reauthentication is allowed when the session
requires neither signing nor encryption, refused when the client
required signing, and an encrypted one is allowed;
- randomized requests against these paths, and 8- and 16-thread
bind/reauth/logoff stress (about 130,000 operations), found no signed
response to an unverified request and no KASAN or lockdep report;
- the Linux cifs client works with SMB 2.1 to 3.1.1, signed and
encrypted, and recovers after its session expires;
- smbtorture's session, signing, I/O, compound, lock, oplock, lease,
notify and ioctl suites give the same results as without the series.
With multichannel disabled, the session tests also pass and fail as
without the series; six binding tests that fail either way (the d and
s variants of bind_negative_smb2to3, smb3to3 and smb3encGtoC) now get
STATUS_ACCESS_DENIED or STATUS_REQUEST_NOT_ACCEPTED instead of
STATUS_USER_SESSION_DELETED (they expect STATUS_INVALID_PARAMETER),
since 1/6 now rejects such a binding request in the binding branch;
Ian Bridges also tested an earlier revision with his own probes and
smbtorture. Not tested: Windows clients, and Kerberos expiry with a real
KDC (it was emulated with a test-only change).
An AI assistant was used to draft the patches and as an independent
reviewer.
Michail Andreas Michalopoulos (6):
ksmbd: verify the signature of session binding requests
ksmbd: sign with the negotiated SMB 3.1.1 signing algorithm
ksmbd: use the channel signing key for session setup on a bound
channel
ksmbd: check a request before signing STATUS_NETWORK_SESSION_EXPIRED
ksmbd: use the current command's header for signing in a compound
ksmbd: consume the sequence number of a request on a failed session
fs/smb/server/auth.c | 14 ++-
fs/smb/server/auth.h | 4 +-
fs/smb/server/mgmt/user_session.c | 1 +
fs/smb/server/mgmt/user_session.h | 2 +
fs/smb/server/server.c | 80 +++++++++++++++--
fs/smb/server/smb2ops.c | 4 +-
fs/smb/server/smb2pdu.c | 145 ++++++++++++++++++++++++++----
7 files changed, 221 insertions(+), 29 deletions(-)
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b
--
2.43.0
next prev parent reply other threads:[~2026-11-09 19:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 11:14 [PATCH 0/2] ksmbd: AES-GMAC signing support Michail Andreas Michalopoulos
2026-11-03 11:14 ` [PATCH 1/2] ksmbd: sign with the negotiated SMB 3.1.1 signing algorithm Michail Andreas Michalopoulos
2026-11-03 11:14 ` [PATCH 2/2] ksmbd: add AES-GMAC signing support Michail Andreas Michalopoulos
2026-11-03 17:17 ` Ian Bridges
2026-11-03 17:57 ` mixalhs
2026-11-04 4:30 ` Namjae Jeon
2026-11-06 19:06 ` [PATCH v2 0/4] ksmbd: verify session setup requests before signing with their key Michail Andreas Michalopoulos
2026-11-06 19:06 ` [PATCH v2 1/4] ksmbd: verify the signature of session binding requests Michail Andreas Michalopoulos
2026-11-06 19:06 ` [PATCH v2 2/4] ksmbd: sign with the negotiated SMB 3.1.1 signing algorithm Michail Andreas Michalopoulos
2026-11-06 19:06 ` [PATCH v2 3/4] ksmbd: use the channel signing key for session setup on a bound channel Michail Andreas Michalopoulos
2026-11-06 19:06 ` [PATCH v2 4/4] ksmbd: check a request before signing STATUS_NETWORK_SESSION_EXPIRED Michail Andreas Michalopoulos
2026-11-07 1:30 ` [PATCH v2 0/4] ksmbd: verify session setup requests before signing with their key Namjae Jeon
2026-11-09 19:41 ` Michail Andreas Michalopoulos [this message]
2026-11-09 19:41 ` [PATCH v3 1/6] ksmbd: verify the signature of session binding requests Michail Andreas Michalopoulos
2026-11-09 19:41 ` [PATCH v3 2/6] ksmbd: sign with the negotiated SMB 3.1.1 signing algorithm Michail Andreas Michalopoulos
2026-11-09 19:41 ` [PATCH v3 3/6] ksmbd: use the channel signing key for session setup on a bound channel Michail Andreas Michalopoulos
2026-11-09 19:41 ` [PATCH v3 4/6] ksmbd: check a request before signing STATUS_NETWORK_SESSION_EXPIRED Michail Andreas Michalopoulos
2026-11-09 19:41 ` [PATCH v3 5/6] ksmbd: use the current command's header for signing in a compound Michail Andreas Michalopoulos
2026-11-09 19:41 ` [PATCH v3 6/6] ksmbd: consume the sequence number of a request on a failed session Michail Andreas Michalopoulos
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=20261109194144.22814-1-mike.michalo@gmail.com \
--to=mike.michalo@gmail.com \
--cc=chenxiaosong@chenxiaosong.com \
--cc=ematsumiya@suse.de \
--cc=hyc.lee@gmail.com \
--cc=icb@fastmail.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lsahlber@redhat.com \
--cc=senozhatsky@chromium.org \
--cc=stfrench@microsoft.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
all inboxes | Powered by JetHome®