Re: [PATCH] smb: client: allocate the encryption AEAD before encrypting a request

From: Namjae Jeon

Date: Sat Dec 05 2026 - 02:21:09 EST


On Sat, Dec 5, 2026 at 1:31 PM Piyus Kedia <piyus@xxxxxxxxxxx> wrote:
>
> crypt_message() is handed server->secmech.enc for every request that is
> encrypted, and that AEAD is only allocated at negotiate time, by
> SMB2_negotiate(), when the server named a cipher:
>
> if (server->cipher_type && !rc)
> rc = smb3_crypto_aead_allocate(server);
>
> Whether a request is encrypted is decided separately, by
> smb3_encryption_required(), from the session's SessionFlags, the share's
> ShareFlags and the server's SMB2_GLOBAL_CAP_ENCRYPTION, all of which the
> server sets. A server that negotiates SMB 3.1.1 without an encryption
> context, so that no cipher is negotiated, and then sets
> SMB2_SESSION_FLAG_ENCRYPT_DATA in the final SESSION_SETUP response or
> SHI1005_FLAGS_ENCRYPT_DATA in a TREE_CONNECT response, or sets
> SMB2_GLOBAL_CAP_ENCRYPTION in the NEGOTIATE response for a "seal" mount,
> makes the client encrypt the next request with a NULL tfm:
>
> BUG: KASAN: null-ptr-deref in crypto_aead_setkey+0x2c/0x170
> Read of size 8 at addr 0000000000000020 by task poc/9466
> crypto_aead_setkey+0x2c/0x170 crypto/aead.c:47
> crypt_message+0x27b/0x1300 fs/smb/client/smb2ops.c:4876
> smb3_init_transform_rq+0x4bf/0x610 fs/smb/client/smb2ops.c:5003
> smb_send_rqst+0x187/0x300 fs/smb/client/transport.c:419
> compound_send_recv+0x89a/0x1fc0 fs/smb/client/transport.c:1014
> cifs_send_recv+0x43/0x60 fs/smb/client/transport.c:1197
> SMB2_tcon+0x42f/0x1080 fs/smb/client/smb2pdu.c:2252
> cifs_setup_ipc+0x276/0x600 fs/smb/client/connect.c:2099
> cifs_get_smb_ses+0x1070/0x14e0 fs/smb/client/connect.c:2565
>
> Until commit b0abcd65ec54 ("smb: client: fix UAF in async decryption")
> crypt_message() called smb3_crypto_aead_allocate() itself, for both
> directions. That commit moved the call into decrypt_raw_data(), for the
> receive side, and left the send side to rely on the allocation at
> negotiate time. Allocate in smb3_init_transform_rq() too, as the
> receive side does.
>
> We found this with a syzkaller-based fuzzing harness driven by an AI tool.
>
> Fixes: b0abcd65ec54 ("smb: client: fix UAF in async decryption")
> Closes: https://lore.kernel.org/linux-cifs/cifs-encrypt-without-cipher.20261205@xxxxxxxxxxx/
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Kapil Vaswani <kapil@xxxxxxxxxxxxxxx>
> Signed-off-by: Piyus Kedia <piyus@xxxxxxxxxxx>
Please check Sashiko's review comments.

https://sashiko.dev/#/patchset/20261205043142.4004783-1-piyus%40iiitd.ac.in

Thanks.