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=1796382876; b=zApvm/I9CL5XYm8Zt4r+C/R4KVh19L5IeeMya5R9+dkWBkiNJAvFNzqwUNEk/57gzW1b Z25lXdMC6I0N1hLAAp+bG3/oA65oyWj8qEM677STQBKxqrGcoSw3fsJI07WhFU8+gVnCs LjsniWnXfV1bJOG/b/ivv1jxe39DbV90+hnkWnzWrjr+4BoIZsY771dkghC+JQTqWqcBG hpeEoXkTBIdjvZdj9ZIkoATkPPESzkpdQ0liwlOyuNyohPDWlK5pXVZsWNh+LzgB9j5Ld tf39zu93Oq61coI4fBX6lFRcLquz8c1yaShxutKuP/kCG52NAZ5QwEtrPV4tz5OjLeA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382876; 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=JvlRwf51Yz8rxty5tmN5FwHtjdxP6pr033ck3P0iep0=; b=0nft9KF5XHWvNX23QfJGd+Heh68quBr31W0ZLN9UgSrgdfatgROTJnPE7pVht2z9YE3Q aRre4+YMCsfrJGdD22aMotRzrv+K7vIsb/80v/FKDF3uq6/2wG9jR0Qhlz/HtKRYkCdHs VTt6fICsIOnovj+VDyzn/okp6HBdICfAJUGWqU0PiBN5V6hahLcfKJuNg0IQMtDBDPAnC ukw3ObXN6CTqRLVsYlvTHDL62nDOf4tN2hH7CO6KB/EqoN/etbBanBPneHzXMcTgge7kX M6XJ8sprXwK/+D5qF65dfziz/S+BMEyj+Xmy1kP/1KwgnJLFYW9oBmd0Fc+P4c4wsiA== 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=nhrbgkDU; 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 24BBF606A333; Fri, 4 Dec 2026 11:14:36 +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=nhrbgkDU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7801E1F00897; Fri, 4 Dec 2026 11:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382875; bh=JvlRwf51Yz8rxty5tmN5FwHtjdxP6pr033ck3P0iep0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nhrbgkDUy/lJ3To/jeA0epjgDiHPmIJKYWE0YJ7QN9lVb28a4dojmulvkX5AtiSoh OZ4q/caermmNUEz1OaAfvod7dZxhgobTL4OIomgRcBMG5OjpEj2L/dK2MC3t3zxLjg WRCavq5EsBWVlD3s9wjo1RSnjf1wIf0Y/C7xVxz8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daniel Birtwhistle , Kaixuan Li , Suyuan Wang , Paulo Alcantara Subject: [PATCH 6.18 581/703] smb: client: fail SMB2 responses with a bad signature Date: Fri, 4 Dec 2026 19:08:00 +0900 Message-ID: <20261204100643.213598416@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Suyuan Wang commit 2a5bd7a2bbb787483cd69ecf099e2b591e3633b2 upstream. smb2_check_receive() checks the response signature when signing is on, but a failed check is only logged: rc = smb2_verify_signature(&rqst, server); if (rc) cifs_server_dbg(VFS, "SMB signature verification returned ...", rc); ... return map_smb2_to_linux_error(mid->resp_buf, log_error); The status from the response is returned as usual, and the caller goes on to use a response whose signature is wrong. This is the path for synchronous and compound requests and for smb2_writev_callback(). On a signed but unencrypted connection, anyone who can modify the traffic can change e.g. a directory listing or file attributes, and the client accepts it. Return the verification error instead. That alone is not enough for compound_send_recv(), which still hands the response buffer to the caller after check_receive() fails. smb2_compound_op() then maps the status from that buffer again and copies the payload out, and other callers look at the buffer on error too, e.g. smb2_open_file() parses a symlink target out of a STATUS_STOPPED_ON_SYMLINK response. So also mark the mid MID_RESPONSE_MALFORMED, and have compound_send_recv() handle it like a mid in a bad state: mark the earlier mids cancelled, so that a CREATE which did succeed gets its handle closed, and don't pass any response on. Unlike the SMB1 fix in commit dc96f01d54cc ("smb: client: terminate session upon failed client required signing"), don't reconnect: this runs in the thread that sent the request, and only cifsd should call cifs_reconnect(). And fail the request whichever side required signing, since a response with a bad signature can't be trusted either way. Found with a static analysis tool and checked by hand. Reported-by: Daniel Birtwhistle Closes: https://lore.kernel.org/linux-cifs/SN4PR22MB28883DAF57E0B4D4BFB1C22AEEC42@SN4PR22MB2888.namprd22.prod.outlook.com/ Fixes: 3c1bf7e48e9e ("CIFS: Enable signing in SMB2") Cc: stable@vger.kernel.org Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Suyuan Wang Signed-off-by: Paulo Alcantara Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/smb2transport.c | 7 +++++-- fs/smb/client/transport.c | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) --- a/fs/smb/client/smb2transport.c +++ b/fs/smb/client/smb2transport.c @@ -773,9 +773,12 @@ smb2_check_receive(struct mid_q_entry *m int rc; rc = smb2_verify_signature(&rqst, server); - if (rc) + if (rc) { cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n", - rc); + rc); + mid->mid_state = MID_RESPONSE_MALFORMED; + return rc; + } } return map_smb2_to_linux_error(mid->resp_buf, log_error); --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -1076,6 +1076,11 @@ compound_send_recv(const unsigned int xi rc = server->ops->check_receive(mid[i], server, flags & CIFS_LOG_ERROR); + if (mid[i]->mid_state != MID_RESPONSE_READY) { + cifs_mark_compound_mids_cancelled(mid, i); + num_processed = 0; + goto out; + } num_processed = i + 1; }