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=1796383295; b=0vL2aju8DQZ829una4jNgZvATCKuOWfYf188WFsiTbEITuNaLhqS7ki+QNFNaKn1bDbr LSodtqGptBXQ5ebYBlVvN6PlilocM639CW3aS0L7uSKWguZ7/unEnPOD4kA73BexXQlCQ DYSy20N6zbwD9tfDkbhYEcuLHJC58eRjatPUcPiNLyisVgR/xBS2u1c522LNvkYSYg1Y2 bcqZR5W2OnSuHVxOhB1NWTytEqv/auTanJbqosCU+JNXzEt2lZvgy2CfwLH/MSip8VBfC L1aCidE/eOFZ7FpmYw0qP/0PvlvZmqrZdCp8Wbzf6CEjvszUMCV5Gg0cDsPvbl5qVqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383295; 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=3K9S0PDWFfqNuwQw58j90F2kOg7gnDdRvP7kKxxxvxE=; b=W89UCevY7ROgStD9xlBBLDLCFeNv62ImZskmEUi4NGeK2F4Lx/o/Tn9RqSpxuyu081My ByY5e8VhMe/NzKH53Y2fCo/u7QlOUYCwqd+HxTI7o0eto84olVlqq+btuQHWfoChU98sE 42gdAigel08EDj1axGi1vCc69p0FAxqZ+yvxr+WApgzmLgahQmOwa2qrNPZAOrxq+Fggu /byJxUXYKzHX9Vx4geeglkFXAybYOtipOds1gSzUrym5+ijqJUXn74NasKIYf0K5pxJpH j0vL4UVO7BANqFgL4uQRoDj7H8Z1j26q1S5UbEhmzxGiL0i7uKlUMDxt4ZvPOW1RNlA== 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=O21Uma8p; 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 B96F5606A32F; Fri, 4 Dec 2026 11:21:35 +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=O21Uma8p Received: by smtp.kernel.org (Postfix) with ESMTPSA id 344C81F000C2; Fri, 4 Dec 2026 11:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383295; bh=3K9S0PDWFfqNuwQw58j90F2kOg7gnDdRvP7kKxxxvxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=O21Uma8pAC7C+LOE72qUOMt8d3H1S+j1wJFFaotw2NantvwBesTw0l30oDBl0ql65 V+MgQAjkSWS4eyMt9JMlRECSLurSRzt+bwD2Yo2WD9YaqcG2Y3+qBVYqZnoYY9wMrO tOjV68nVgUAmLjV0wRjYsKRL4XHs2ij8uiqg6Lag= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michail Andreas Michalopoulos , Ian Bridges , Namjae Jeon , Sasha Levin Subject: [PATCH 6.12 164/555] ksmbd: sign the last response of a compound that ends early Date: Fri, 4 Dec 2026 19:03:27 +0900 Message-ID: <20261204100614.469596202@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michail Andreas Michalopoulos [ Upstream commit 3d322b98b56628ee69e4528a52cc1f445880fa17 ] is_chained_smb2_message() ends a compound early when the next command does not fit in the request, or its response would not fit in the response buffer. Since commit e2b76ab8b5c9 ("ksmbd: add support for read compound"), __handle_ksmbd_work() then signs ksmbd_resp_buf_curr(), which is_chained_smb2_message() only moves to the response of the command just processed when it chains to the next command or reaches the last one. On an early end it returns without moving it, so for a command after the first, the previous command's response was signed again, over the iovecs of both responses, and the response of this command was left unsigned. Neither signature verifies at the client. Handle an early end as the end of the compound: pad the response to 8 bytes and make it the current one. smb2_allocate_rsp_buf() leaves room for that padding in the response buffer of a compound. Only a compound whose NextCommand points past the end of the message, or whose responses fill the response buffer, takes this path. Sashiko pointed it out in its review of an unrelated series. An AI assistant was used to draft the patch and as an independent reviewer. Fixes: e2b76ab8b5c9 ("ksmbd: add support for read compound") Signed-off-by: Michail Andreas Michalopoulos Reviewed-by: Ian Bridges Tested-by: Ian Bridges Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin --- fs/smb/server/smb2pdu.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index d919dd0333624..05eaa59f4750c 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -468,22 +468,27 @@ bool is_chained_smb2_message(struct ksmbd_work *work) get_rfc1002_len(work->request_buf)) { pr_err("next command(%u) offset exceeds smb msg size\n", next_cmd); - return false; + goto last_rsp; } if ((u64)get_rfc1002_len(work->response_buf) + MAX_CIFS_SMALL_BUFFER_SIZE > work->response_sz) { pr_err("next response offset exceeds response buffer size\n"); - return false; + goto last_rsp; } ksmbd_debug(SMB, "got SMB2 chained command\n"); init_chained_smb2_rsp(work); return true; - } else if (work->next_smb2_rcv_hdr_off) { + } + +last_rsp: + if (work->next_smb2_rcv_hdr_off) { /* - * This is last request in chained command, - * align response to 8 byte + * This is the last response of a compound, also when the + * compound ends early because the next command does not fit. + * Align it to 8 bytes and make it the current response, which + * is the one the caller signs. */ len = ALIGN(get_rfc1002_len(work->response_buf), 8); len = len - get_rfc1002_len(work->response_buf); -- 2.53.0