Skip to content

smb: client: Spec-compliance fixes for Kerberos key derivation

Piyush Sachdeva linux-cifs lkml stable 3 versions – New

Get series with b4
b4 am [email protected] change-id 20260429-kerbmi-dc0853cd29fc

Versions newest first

  1. v3 Latest2 patches 0 repliesNew
  2. v22 patches 2 repliesSuperseded inferred link
  3. v11 patch 2 repliesSuperseded

Changes in v3 from the cover letter

- Patch 1/2: cast ses->auth_key.len to int when used as field width for "%*ph" in the CONFIG_CIFS_DEBUG_DUMP_KEYS dump, fixing a -Wformat warning. Reported by Sashiko.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2smb: client: Use FullSessionKey for AES-256 encryption key derivationfs/smb/client/ioctl.c fs/smb/client/smb2transport.c+27 -100 replies
2/2smb: client: Zero-pad short GSS session keys per MS-SMB2fs/smb/client/smb2pdu.c+18 -50 replies

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH v3 0/2] smb: client: Spec-compliance fixes for Kerberos key derivation

This series fixes two MS-SMB2 section 3.2.5.3 spec violations in the Kerberos session key handling path of fs/smb/client.

Patch 1/2 (resend of v1 with a small cleanup folded in) fixes the AES-256 mount failure with sec=krb5: encryption and decryption key derivation must use Session.FullSessionKey (the full Kerberos session key, typically 32 bytes for the aes256-cts-hmac-sha1-96 enctype) instead of Session.SessionKey (the first 16 bytes).

Patch 2/2 closes the related corner case in the same section of the
spec: when the GSS protocol returns a session key shorter than 16 bytes, the buffer must be right-padded with zero bytes. The current code copies the GSS key verbatim, which causes generate_key() to read past the end of the allocated buffer and derive keys that do not match the server. The trigger is deprecated short-key Kerberos enctypes (e.g. single-DES, 8-byte session key); modern KDCs disable these by default, so this is a latent issue rather than a reachable one, but it is still a kernel slab over-read and a literal spec violation.

Verified against Azure Files (AES-256-GCM + Kerberos aes256-cts) which previously failed to mount with EAGAIN; the dmesg "Session Key" trace under CONFIG_CIFS_DEBUG_DUMP_KEYS now shows the full 32-byte session key being used for encryption/decryption KDF input.

Changes since v2:
- Patch 1/2: cast ses->auth_key.len to int when used as field width for "%*ph" in the CONFIG_CIFS_DEBUG_DUMP_KEYS dump, fixing a -Wformat warning. Reported by Sashiko.

Changes since v1:
- Patch 1/2: initialize full_key_size at declaration to silence -Wmaybe-uninitialized on some toolchains, and drop the now- redundant else branch (self-review).
- Patch 1/2: tighten the FullSessionKey condition to also require

    Connection.Dialect == "3.1.1", matching MS-SMB2 3.2.5.3.1 verbatim.

- New patch 2/2: zero-pad short GSS session keys per MS-SMB2 3.2.5.3, eliminating a latent slab over-read in generate_key().

---
To: Steve French <[email protected]>
To: Paulo Alcantara <[email protected]>
To: Ronnie Sahlberg <[email protected]>
To: Shyam Prasad N <[email protected]>
To: Tom Talpey <[email protected]>
To: Bharath SM <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Piyush Sachdeva (2):
smb: client: Use FullSessionKey for AES-256 encryption key derivation
smb: client: Zero-pad short GSS session keys per MS-SMB2

 fs/smb/client/ioctl.c         |  2 +-
 fs/smb/client/smb2pdu.c       | 23 ++++++++++++++++++-----
 fs/smb/client/smb2transport.c | 35 ++++++++++++++++++++++++++---------
 3 files changed, 45 insertions(+), 15 deletions(-)

---
base-commit: 0cbc300257d9b399491909806777f504ec687c1d
change-id: 20260429-kerbmi-dc0853cd29fc

Best regards,

Signature · 1 line
Piyush Sachdeva <[email protected]>