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=1796381436; b=3Tf5NH2ge27qo2zsjM3GkdUsDCGE98vg+gPLhyVSy2PzPxe5KdOVTT4jcRBgR29tv0c5 UC7Eu0XKpFTsigHxdZFt4UXbGRz9RJ20nGjM2m0/lXjTJVjLQOB2syEC0rb4HbIoXrF/N xEJ5o3FKH5/79XFx4CHRKoPFU2vOyiS3tonWAPArhCSbuSWBgMrZ1UZyY/zKHFcgPotjq UeibMIen/qQf3TA8wEeq2E2MwwBJIRsUmDZGRBEnAO3WnZAQhYqT45YoXfqclcyHIj7F/ U9aZD3yB+qbZDU8DS0Ens+t/FlNmS31zAXADi37frFXJxi36KI4VON6DnRphyf3gA8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381436; 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=gW+Q7Mz7cAyPrHA0EmldTztZMjX7b0zQQJbdBMWG+GE=; b=N0kCa5+2+bCsZbnT8akTWsgQDqzaeZzPk6mky7wUm/88skWTKNQOJz5qLYduVZ4QxqLt vApmAFbXVIVLX4AnxaJDfYM+5COfJPIPkGakasH4DLdO4W2ez7iqieljjLctoS9vc+2K1 wKTTjA7yn1qov1WdahnywQl1/FEEkpUmeQVBbTzk/u5XeLiFj2UPTOUiEN0HwXS975Few 1HbI6u0wruCGNeh+yEs905LMOMf9TJLuKCIE+zm0cHWaQ+gqbygXKeNXGWLgZ4UMAcXeu SZPp/UrcdRtpiT8j5fua/XnjfE5C1Qn3ICVZ1dxt01KfkLUPTBOi1TZ9jfJIYD8qJSA== 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=XRFnzY7G; 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 7ECE0606A330; Fri, 4 Dec 2026 10:50: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=XRFnzY7G Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC3181F00897; Fri, 4 Dec 2026 10:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381436; bh=gW+Q7Mz7cAyPrHA0EmldTztZMjX7b0zQQJbdBMWG+GE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XRFnzY7GdhdPn2bc4LqvoH57Eu5mpETZTaMzpTSU/Sx3AYYCK/e1DpdeH9cPQQge7 EE+/LqSnw2HpAZWJN//RQEr3Duez3hZ5s4rlAVKFet4cSdflcflnrcCIsos7n8ZRWH vzeZPIDpm0TpwMGAri4HM/IpMmQ8wymaV3LG5TjY= 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 7.3 663/742] smb: client: fail SMB2 responses with a bad signature Date: Fri, 4 Dec 2026 19:08:47 +0900 Message-ID: <20261204100652.686639979@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 @@ -712,9 +712,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 @@ -1082,6 +1082,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; }