[PATCH v3 0/2] smb: client: Spec-compliance fixes for Kerberos key derivation
Piyush Sachdeva <[email protected]> Thu, 07 May 2026 22:22:12 +0530
| Newsgroups | gmane.linux.kernel.stable,gmane.linux.kernel.cifs,gmane.network.samba.internals,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
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. Link: https://lore.kernel.org/linux-cifs/[email protected]/ 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(). Signed-off-by: Piyush Sachdeva <[email protected]> Signed-off-by: Piyush Sachdeva <[email protected]> --- 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, -- Piyush Sachdeva <[email protected]>