From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384749; b=KDApc5v3HolUSDU+DZEL2by4EKX1LdN7Fjgi1hW5oZulzF9chdSUCpmu7HrW8JFGllFk IJdI3Hivy7ucqTnzIU+Kl+MydIkq0EG1+igRatMT5EYcH5plRvfOt4KCR2zX2nDmRGR57 bK5fM7EJLGeivanMT1zjiNs2egMNkTb8ogWvSftf370Gfh08IpNWFBw515fUwrHfv/nAJ jPPY0NtdBvTmcnvue4q+Y6jxdPNgk3WsR0smDTYkib0G6nJL3BcatEbcjHBoRpxMrLxvc To5wkN7tTc7xgwlEP/7eog/sua9Rw5DWe3+zlwM9jUBCpu09MQ48djLBquhnKiOOTfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384749; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Rmk8FVhEu+2YQYJDJse1+wN3hisJwFe4GuM7TDZhn/I=; b=3PGPF0sfnc8FASm/bg0rDU+ZY7M6TXGWwv2VlJVeIX56Jikb1VNzvpQWg+mb6HC+bbQa ElMHjhaJDkTKx34/fTayN9iAtPQEzN9tsfKyE7vHnPaO2Jx6eWhiesa2/mRlxoKuFeYAT gZWaYDxmQB8/IpRe38sr42FQthhsMLyyv4Ms3MlibPVtbopVZ9x1Ivcbsn8ynN5XvcntG YFL33XHqovG50x36DeLNf2JrU6bMQXz380DBh3JBdqb8M07jY9IeTQmWdxclIJZ5Nq4fZ pC95jOqan5J50cV/FfDyh0TekmaA82gA0/qUo1/+7jNGDqdawMmpS4po+IXnTtzj7cg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=D1TR6Ym5; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42E05606A322; Fri, 4 Dec 2026 11:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=D1TR6Ym5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE6A91F000C2; Fri, 4 Dec 2026 11:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384749; bh=Rmk8FVhEu+2YQYJDJse1+wN3hisJwFe4GuM7TDZhn/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D1TR6Ym5e3+oHTmKnfkkoYSyKNcfrzigoB4OV8JefMEvQkLkWYOQzD31cYLupOF5E wqvctFHZo8yWTqcpmkhZ3TWU2P5sUgTwBcPyIPibXns0BgyOijp0piWhPt4liiaOfO nqsgIxmN83+WZgr/lRbJRGkI7colXMpbQ6DN5iFI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Abdifatah Suruur , Namjae Jeon , Paulo Alcantara , Sasha Levin Subject: [PATCH 6.6 0275/1167] smb: client: reject short SESSION_SETUP responses Date: Fri, 4 Dec 2026 18:55:02 +0900 Message-ID: <20261204100709.215930194@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Abdifatah Suruur [ Upstream commit 4d8930afa3446041358a7db33e7b23a0bb9459b5 ] smb2_check_message() accepts frames shorter than struct smb2_pdu when the SMB2 status is non-zero, before the minimum-PDU check added by b4694f269e66d. A 64-byte STATUS_MORE_PROCESSING_REQUIRED SESSION_SETUP response is therefore accepted even though it cannot contain the SecurityBufferOffset and SecurityBufferLength fields. The parser then reads those fields from stale bytes left in the reused receive buffer by an earlier frame. With a long stale SecurityBufferLength, decode_ntlmssp_challenge() copies up to about 64 KB from beyond the receive object and sends the data back to the server in the NTLMv2 AUTHENTICATE target info. Reject short MPR SESSION_SETUP responses before the short-error path, and validate SecurityBufferOffset + SecurityBufferLength against the received response length before decoding the challenge. The ordering bypass is not new: the short-error early return predates b4694f269e66d, and the unvalidated SecurityBufferLength read predates the 2016 raw NTLMSSP split in 166cea4dc3a4, so all supported stable trees are affected. Reproduced on 6.6.87.2; the path is unchanged on mainline. Fixes: 5478f9ba9a34 ("CIFS: Add session setup/logoff capability for SMB2") Cc: stable@vger.kernel.org Signed-off-by: Abdifatah Suruur Reviewed-by: Namjae Jeon Signed-off-by: Paulo Alcantara [ sashal: Replaced the missing min-PDU-length table lookup with sizeof(struct smb2_sess_setup_rsp) and adapted the offset/length check in the rawntlmssp negotiate path to the tree's older code without boff or smb_EIO1. ] Signed-off-by: Sasha Levin --- fs/smb/client/smb2misc.c | 15 +++++++++++++++ fs/smb/client/smb2pdu.c | 12 ++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c index 23320b794b177..7be338ad755b1 100644 --- a/fs/smb/client/smb2misc.c +++ b/fs/smb/client/smb2misc.c @@ -193,6 +193,21 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *server) return 1; } + /* + * A SESSION_SETUP response that asks for more processing carries a + * security blob and is parsed as a normal reply. Do not let the + * short-error path below accept a frame that cannot hold the fixed + * response fields. + */ + if (command == SMB2_SESSION_SETUP_HE && + shdr->Status == STATUS_MORE_PROCESSING_REQUIRED && + len < sizeof(struct smb2_sess_setup_rsp)) { + cifs_server_dbg(VFS, + "%s: session setup response too short: %u < %zu\n", + __func__, len, sizeof(struct smb2_sess_setup_rsp)); + return 1; + } + if (len < pdu_size) { if ((len >= hdr_size) && (shdr->Status != 0)) { diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index a93421b8c3828..24863ba8a0926 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -1764,6 +1764,8 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data) if (rc) goto out; + u16 blen = le16_to_cpu(rsp->SecurityBufferLength); + if (offsetof(struct smb2_sess_setup_rsp, Buffer) != le16_to_cpu(rsp->SecurityBufferOffset)) { cifs_dbg(VFS, "Invalid security buffer offset %d\n", @@ -1771,8 +1773,14 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data) rc = -EIO; goto out; } - rc = decode_ntlmssp_challenge(rsp->Buffer, - le16_to_cpu(rsp->SecurityBufferLength), ses); + if ((u32)le16_to_cpu(rsp->SecurityBufferOffset) + blen > + sess_data->iov[0].iov_len) { + cifs_dbg(VFS, "%s: invalid security buffer length: %u\n", + __func__, blen); + rc = -EINVAL; + goto out; + } + rc = decode_ntlmssp_challenge(rsp->Buffer, blen, ses); if (rc) goto out; -- 2.53.0