From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796445102; b=BxjLa+jw/ezbEUD+r8BclI4TNn5p5w6p9e2XjhuH/Fnt/1rdmeE1QsRjjHeTgvr1wBRv /xHMmfUmg7u+ECh0lZha9lmKeRef5TinnJqRWWvQaTn1x2RfPh1TCfn3/lMJ5W9JckgDA sthRoaGcF/mvr4wi3L75YDlrLTWOq7yli6PIJJJCjP5NMkWmJKKvEqO04hpBVp1g/9qad pkJRFxOgLeLk0un2ZfyoQuyfE4PaRAh09WeycWFPtv5OCJInZ39iowcsd8wN0GJQO/tFg 1ODpygrcsnIvJVCzRA8q9nyj+ZGibyWkdaNvX+fB5pYnrWabMmm/OLLwtCQ2/Qmm9mA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796445102; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=A6I/s6c+XFN/Y/2DsY/5ChFSjyexmnkADDk9TOdand0=; b=oxFjX29Q05L5P5AiFpqlRTNIyGZQRiZdwi4cjGq9s8MHQWJ2wqMRUXD+BlD1gNGuDfxn oh/48yQCM5scOYFCzGOWS+ALLYo/AjJndbpPMx/Zn+h4poSoRJt8AW1tSDpShAAExg8KF xc7n5DiLMIrGrl/figB+X4sUE6I5OayWgp2/Ir4k23bbYqCswi9Y/WuwjPlEw7kxChuth Uoa1UPQrN0xbDhvxNHF2hlXYf8y1N+0XH2R68DaNhT9sx4Vp873wSlmC5Nh+mjCnk9UZa YcHkY06YVUJ82zj8Ti0yXAZXqVMWW3zOBbecM3onkRfxzRD7KmKQtjwyBXNzsxRNuuQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iiitd.ac.in; spf=pass smtp.mailfrom=iiitd.ac.in; dkim=pass header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b="FaJk/WRa"; arc=none smtp.remote-ip=74.125.82.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F175606A32D for ; Sat, 5 Dec 2026 04:31:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4F175606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=FaJk/WRa Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-3869f03af6aso2027011eec.1 for ; Fri, 04 Dec 2026 20:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1796445101; x=1797049901; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=A6I/s6c+XFN/Y/2DsY/5ChFSjyexmnkADDk9TOdand0=; b=FaJk/WRab+Au4HEnm96QaMs/2ZIH7Klhk3AxoBF7lkRp72qF1P7gIpf+yg19oRhxTE 7gDwBdpltQpCMOggjg2Wf5CMflPd4VSyBcb1kc7WtetL/XDW2Lk5/Te4SrSlPrmsAiL+ d5+pPz3owJUrDhiPe8t7NHD0XnKSSCUCV+1dM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796445101; x=1797049901; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=A6I/s6c+XFN/Y/2DsY/5ChFSjyexmnkADDk9TOdand0=; b=dCPaxHolJQEaV2+lxxipIpfqPv8AmSHg6ZBwhGfhOOYXgr5sA8DZx3vcTk7zvYaEvd RIqvmh+yQOCqsuf9I4AO6WycQBqupZLvax5vus/r0Nf+hKV6NF1EFnXOE5kaZw7DusEe omjRzUoWIn0HAaED8UE6vShJq8iTu4oYsB1ybCIP5wBl6gI/Q/2WXPwz0Cim9XKuJt6U vEwvME8eKiIKXCyDz7OelWsZ7NeZnHhBy7N47Lt4mQLlp/wDVUrC7Yr7mrjd5r2xX2s/ UrbxYeBDHCFSvM6GQCxX7FX9vo3jf/o77EEjOIIv3j8OjKilc0bmLo89G4mKoeg47+XL FVRw== X-Forwarded-Encrypted: i=1; AL+hErHqrf6NvDC1JDUE6zvgDWdlUOdI5VRU0r2emU8YDzfjWH2xo39/LXIBNnhlpDGbs9zX39jZCzIr60Hj@vger.kernel.org X-Gm-Message-State: APuU4Z/uSAvRTe65fZ59lqFPFO6dZV//X4ZRZ9I70n4+9mKP1O4vQS2g MFp0LT/eMRnCA0VDhpBXpcE+ZYCwRu7ZbkIjr9MwdH/ljONbgiakmUz/gRsE2bXFMbM= X-Gm-Gg: AZFdTZfoLmMzkaftxLmJ8FJp4DAB7mOkavIAvDnpsElTzhDFjA43E658Fv2n30iZOHJ 3ub11XOsURdQGolAcz8eJwZ+EdOW6P4VzID3iRH5o7S3vJQhf4HFuI4mC/QBiKAcBPBnMPSr2hk b3in2rgtbkIt7LmANaYPL/sTzMfxYJ/hJZY38wqOXBy51whcYKXsR7Igrd2K3HzJ3gQahLC9SE7 aS7xHjymYYku+2fIBtS8AW8OYvKnV0OdyKfKk9bI7FvI1MiJmW1OdL8oHSUE8lGHrevIMoyo6Se xPIS/6u2raAKOLhZgKC+SS+NgxzFKfJiWQaotMDGwbs6PtyP07wTWfUOPqwe5imOO3XAnfS0UtQ a6Re8y+KEElzzn3b8XkhjBjJebKdkelVpBOwNhfawmMHwGHelMyWXH3M74E6MSOXKUzD+7/1wVz mdupstHrYcidsxGn65u0oZA782DYEqZyRaydEq88UPsAF2jHjjktDpGdoVnO7v0/Q+02OkOxJp/ 3BZZpfQNaXWbeejel5e2klEPCKCt39d1AwhnNIOg4UZiG85oN1c6Dv2GXKdqGAkHKzn8QtPYYHb 8Sp8Njjko/EJ9ubM5WvIII0uVYuK/tcN68kKKuSHPUPV7id98ic8AA87OQU4Z+ZutOtIqmRVIv7 JR37kLeMLHt4wDRGl59alodRE4ts5z05zxqpAyE6VRsuomfCTQP4Abp4qO/R13/Ua X-Received: by 2002:a05:7300:881c:b0:387:174a:3905 with SMTP id 5a478bee46e88-38742cf7d3emr7138508eec.9.1796445101282; Fri, 04 Dec 2026 20:31:41 -0800 (PST) Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521bb368sm19111915eec.10.2026.12.04.20.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 20:31:40 -0800 (PST) From: Piyus Kedia To: Paulo Alcantara , Namjae Jeon , linux-cifs@vger.kernel.org Cc: Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, Kapil Vaswani Subject: [BUG] smb: client: NULL tfm in crypt_message() when the server requires encryption without a cipher Date: Sat, 5 Dec 2026 10:01:35 +0530 Message-Id: X-Mailer: git-send-email 2.34.1 X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, The client encrypts a request with server->secmech.enc whenever smb3_encryption_required() says the session or share needs it, but that AEAD is only allocated at negotiate time, and only when the server named a cipher: fs/smb/client/smb2pdu.c:1391 (SMB2_negotiate) if (server->cipher_type && !rc) rc = smb3_crypto_aead_allocate(server); smb3_encryption_required() (smb2pdu.c:77) decides from values the server sends: SMB2_SESSION_FLAG_ENCRYPT_DATA in the session flags, SHI1005_FLAGS_ENCRYPT_DATA in the share flags, and, for a "seal" mount, SMB2_GLOBAL_CAP_ENCRYPTION in the server capabilities. For SMB 3.1.1 a cipher is negotiated only through an encryption context, which a server can leave out of its NEGOTIATE response. The next request is then encrypted with a NULL tfm: fs/smb/client/smb2ops.c:5003 (smb3_init_transform_rq) rc = crypt_message(server, num_rqst, new_rq, 1, server->secmech.enc); 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 (include/linux/crypto.h:458 crypto/aead.c:47) crypt_message (fs/smb/client/smb2ops.c:4876) smb3_init_transform_rq (fs/smb/client/smb2ops.c:5003) smb_send_rqst (fs/smb/client/transport.c:419) compound_send_recv (fs/smb/client/transport.c:1014) cifs_send_recv (fs/smb/client/transport.c:1197) SMB2_tcon (fs/smb/client/smb2pdu.c:2252) cifs_setup_ipc (fs/smb/client/connect.c:2099) cifs_get_smb_ses (fs/smb/client/connect.c:2565) cifs_mount_get_session (fs/smb/client/connect.c:3660) dfs_mount_share (fs/smb/client/dfs.c:352) cifs_mount (fs/smb/client/connect.c:3942) cifs_smb3_do_mount (fs/smb/client/cifsfs.c:1132) smb3_get_tree (fs/smb/client/fs_context.c:917) vfs_get_tree (fs/super.c:1881) ... __x64_sys_mount (fs/namespace.c:4540) BUG: kernel NULL pointer dereference, address: 0000000000000020 How it is reached. The reproducer is a minimal SMB 3.1.1 server on loopback and a mount of it in the same program. Its NEGOTIATE response carries a preauth integrity context and no encryption context, so no cipher is negotiated, and any one of these then crashes the mount: 1. SHI1005_FLAGS_ENCRYPT_DATA in the TREE_CONNECT response's ShareFlags (SMB2_tcon() stores them unchecked, smb2pdu.c:2281); 2. SMB2_SESSION_FLAG_ENCRYPT_DATA in the final SESSION_SETUP response; the crash is then in the IPC tree connect, cifs_setup_ipc() -> SMB2_tcon(), as in the trace above; 3. SMB2_GLOBAL_CAP_ENCRYPTION in the NEGOTIATE Capabilities and the "seal" mount option. The check that refuses a seal mount on a server without encryption reads that capability bit, not whether a cipher was negotiated; without the bit the same mount fails cleanly with -EOPNOTSUPP. All three crashed the client on 7.4.0-rc5, where we found them, and each crashed it again on upstream (below). The receive side does not have the problem: decrypt_raw_data() allocates the AEAD itself when it is missing. Until b0abcd65ec54 ("smb: client: fix UAF in async decryption"), in v6.12, crypt_message() called smb3_crypto_aead_allocate() for both directions; that commit moved the call into decrypt_raw_data() and left the send side relying on the allocation in SMB2_negotiate(). Impact - who can trigger it: - The SMB server the client connects to. All three triggers are values in the server's own NEGOTIATE, SESSION_SETUP and TREE_CONNECT responses, so a malicious or compromised server can crash any client that mounts it, including one a DFS referral sends the client to. Our server accepted the client's NTLMSSP authentication without checking it, and the mount options were ordinary ones. - A local unprivileged user cannot trigger it directly: mount(2) of cifs needs CAP_SYS_ADMIN in the initial user namespace (the filesystem is not FS_USERNS_MOUNT). Where an administrator allows user mounts through mount.cifs, the server is the one the administrator configured; we have not tested that. - What happens: a read through a NULL pointer (address 0x20) in the task that sends the request - the mounting task in our runs. The kernel oopses and kills that task; on a system with panic_on_oops set it panics. It is a denial of service; nothing is written and nothing is read back to the server. Seen on 7.4.0-rc5 and REPRODUCED ON UPSTREAM: on ksmbd-for-next (d70570cf8003, 2026-12-04), whose fs/smb/client is identical to mainline (c3500c5ef648, 2026-12-04), with KASAN, each of the three triggers gave the report above in its run (the trace is trigger 2's). The code is the same in cifs-next (9b62aa64ed00, 2026-12-04), which changes fill_transform_hdr() beside the call but not the tfm passed to crypt_message(). A patch follows in reply to this mail. It allocates the AEAD in smb3_init_transform_rq() when it is missing, as decrypt_raw_data() does on the receive side. With it, same config and image and no other change to fs/smb/client, none of the three crashes: the client sends the request encrypted (with AES-128-CCM, since no cipher was negotiated, as it did before v6.12), our minimal server, which cannot decrypt it, closes the connection, and the mount fails with -EHOSTDOWN (trigger 1) or -EAGAIN (2 and 3). No KASAN report. Whether the client should refuse such a server outright - for example not accept SMB2_GLOBAL_CAP_ENCRYPTION from a 3.1.1 NEGOTIATE response that has no encryption context - is a separate question that we leave to you; the patch only restores the behaviour from before v6.12. This was found by AI-driven fuzzing built on top of syzkaller; its analysis was then checked by hand against the code and every claim above was reproduced. The reproducer is fuzzer-generated, runs a minimal SMB server and the mount in one program over loopback, and we are happy to send it on request. Kapil Vaswani Piyus Kedia