From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796445102; b=25hQVeIqyUxoSVDCO+9ay2+R0SOEoHBygXyAO4JyWlVhfHdWuz1i7Qt8DF5AMWx3u1aX I20IVGzDn7Lsrl7wpP4y0AYXC4KokkenMjrve6pD7U0Hlt10HazmhvxZgp9gp0tkqqTul VykUjfsAkPq4HfCegvOVHujiKL081qTFP51l4/BNryK+xmr67GE6pWufACtKlbJUC1Cdu IoyVRm0mU4ml/zwf87SkPBemu5NMvPBMFn8HaD7Wed0C3HMTBxdYioKWDQVBC/ydVxcX5 ZELWH6vWTlNvZVgW2tQHoCcH0nWZU4au7g3DUby6z+D1KLV468buqsEOSxeaH5u/MYg== 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=zyq/invwu5AFMvcgkXw1yG/Fy+eXYgrOqigcKq8GUrPhNz+udCSDDkq3VjlytaXWjSM9 65a/6q0+5464W4SPbN3BCA/X3F8NVjnDnPfaU8S5JcEzjIT+F7z3kF5nCdOz1VqxesK3K s1+nAli/BFRBCGC8oIJ6YID1zqe3e5HdEngPi1lCxPkNOaJIhHGuu0o7iYeOa//HNjcyy UrcDwdLknlMN074055vi3NYNG+fl9ph+OBbk0eR8gfThDsJNTbv4AxMhzz7zJ/gItQeOW aYGocKa1lXyrrzuaIiA43jV2Q5tEOkk2A+8rZjUSVly77HUSy8Yx1tLnz0VQm4mAa/A== 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.170 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (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 41FE5606A322 for ; Sat, 5 Dec 2026 04:31:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 41FE5606A322 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-f170.google.com with SMTP id 5a478bee46e88-386d1859e1cso1587877eec.0 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=ajsXLDDIUMWwUylogQNQ69pYCNgZTSE1RCN2aTaE1eHnv3BfkEDuFNXAF9NEoAyOd2 brD3l8K0sijTnyU+hrFjwmIWGyS0iORQ8ak5vR0G2Cc3UgPMGxsysIF1HMTDzPgH2YVU La0y8bMbIamufLtq3z0732Y6yPjJB/eNezvXfobYgD4ckLMZKC58v1IKyJPjdVd4USn1 IzNfeTyrwbbauFI/w02c4OizozUxfr1wCfMaBXsYgimcP0RlJYC65MceOcW33TgtgJh0 Y0Iv6yg55Vghf76RDkNs5PnVMk1Dglkknu3tdYP9YCWAWTtczUtJXFruQU+npVwa2Uqk EOew== X-Forwarded-Encrypted: i=1; AL+hErFi0CtQ5Gx6VrwSeSk/e2Dsg0/d1iptSS+ENWUEzNjOIBqozTb5DxDvERF1KP3lhPMUmca+napp/Wbbc7A=@vger.kernel.org X-Gm-Message-State: APuU4Z/ShX7m0eRsyib95jmRevPS+rR2u8eGBeEv3wr5+bz16I+2R16x vGr3M0zavBQX5rtNyIUG5CZtkwXIPWqTGlE5BF2SY2fvI8u0xJLWsy48p6IKqJstchM= X-Gm-Gg: AZFdTZdD/MfU/giOnTVrDl2S9fmTRB/HUfW/7JCGDzIMe5i2Px2rTfrXGQvbbjqGKAP PuMDhVzOnMqvDNTXWQd2ublLujHU9Gem6F3ASRd4z0ep9ihWjeKDXWCskmSyAwJ/SbMP4cVHh0j pCJbDXgweacIMleOnzh1w4gC3d8Jr+OLSTItut+N0bUSM0D5oT0ln7fvTDMVgTlvZCKeb0/fuiN LUXYjUj1Q1iFcHdpjeYjzcnTbKK1vhI4j02jXtesd80HTYlZ+fUKFl17SyWxO79MY5aNwRpiysh qBbFZ0EGeBKCnAuyXCaibJYqp88GcqpTHXaRQh0mvavv+ioKq0s81ZXfKiPNAtObrNn95BIIPsI btxxdwvdVSh+Y2yQ0bMG8veUCFcGQBmyDlK9w0mIxQ2h8RHQ4dsO0tEhHv/2+JzPks0IElLWC29 e62xcsC3S06geXeOrch3LWquf0a+gJQ8tHJEG68JQ4urB/fhLoiWAfD27Xhx7SbTQGvIlHH8uby Sw5gC2vU9lOkuMsKxvivVmBoZm7jrgcgygaRnTxdpwl0FAiJN2UYnYM//W6J48eRHSEms169Lsg 02TCUdGXny+tgp4ux+JsBM0ld5TY4b4+Uw3jptNySyNDFdexaZW03CUeCptMHZKsCgKS+/QPqxY 3Q/BYlq+2ijiItBjxr98SGUzjzd1eVwsrHeWb4kgGtmGRllgxA6TDAn6OGsTzZBmN 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-kernel@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