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=1796381780; b=kxlSGlLtxeyTdORuY3CDvVD81MreMwoo6JaTtkIrEeXxEQVvBSUjU2afVzP3C8AsemQi zMjjfFp1rlD/d4HSY5RywFXv+w10VbXnHm/ikRkYH51yfilOMkHWCfEQpFRO13Hs8/+/G T29YDrSyL3ggvEWJCtdhNAVCx2OkExqH7yuf88xB8BYhWjMEym5OSNGaMjJOD9I44ef1q XQIUwEnsraRxglz79nIJ37HOU+YKRkHqRBorgOFPfxyfYAL6ddcUy/RKni/qHKEMo6VNK lzKAdIW4QxBnEAz1rDI6+XI/sVm31kyop/10bjkk3NmWj5FK4nr/BDPCDg27xmExDgQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381780; 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=Oe2E+1G+tUjA1ZeEUv+5vt5ikM8h08PBKMKyOpF1fw0=; b=LsJZV5JNUDE2OodtPps7MyTr1fxa9KeE6/EOJe4Da3gCwKlMSFFGSmyxD+kiim3hI4ku htvPSt0PWniAi34gyZAlBwaUKi2GZLJyVUYlbBe4r99VvXPlVtmC3YR7dTnGQFrGUPgOw tysyQCUzzoUkWWi/8bleZN9RJyuZlq59ApJvEQdu1a3GI4JrXCiG6x/FOcfJ/uVaac2Kl G9b+NyNmMEyQhPDUa81uTyi+jNtss05i7v+8yUKwWghLy7DMu6L5P2LL1/WLyBzoqurtL QOsUO3L0qLoEU5aofYWnYKY4h0y0GRt8pLTGGFzj9HPf2bz2vStljstyAL8FDDiiHZQ== 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=STUsAyLF; 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 5CCB6606A32C; Fri, 4 Dec 2026 10:56:20 +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=STUsAyLF Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4F6D1F000CE; Fri, 4 Dec 2026 10:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381780; bh=Oe2E+1G+tUjA1ZeEUv+5vt5ikM8h08PBKMKyOpF1fw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=STUsAyLFP9YUFd6qzQzo1cncmX/774aEuk/KAsOB1M6O29z/S5zN6voZmoX8HFPe1 03VXeVjJ+FEN0Ss5W366EWPw1QMGVamAm5AzgCOfrNJ0x2yNCfaB8zlrpLKQIgSzSy CdoK39wDrHQQ8Rdz01qzkEBC5qP3V+hF33xvekhI= 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.18 143/703] ksmbd: sign the last response of a compound that ends early Date: Fri, 4 Dec 2026 19:00:42 +0900 Message-ID: <20261204100631.691892742@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: 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 2fd2d52eca00c..49c4354b18053 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -469,22 +469,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