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=1796386178; b=a+9wyOJI8Rr5oekmEkUXKDdtWBT8/bXvoxyY948ZRdlfVvPprJ0tcpoMQVDuWEE5Lfyu o8MfzNun3bDLsS3a7sIf/x+vGnA6BTTn9+Bj7jXTPtyVz5UASFVtZHnI1+BO0z5CjDp3V fs1IRolR2L82fpX5T9SL0QSQkPapcaBbwXPcEjoIu3z1hhn0jIYeXXE3dMB2bjdI1ojb9 ctHvHPcJb40pGY+oRDHWaa2BIOczzaL5f5zjt4DQDweCcIx03simcbWLk5peko2hJ64fj NpD9bgn9O7F1EsL2LdsCtEnGSD04nra96jmoEYlSplhyd/qGO2tv3pnAJblNPenN91A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386178; 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=tJ8HC7TIMujyGcsJ5h9/2Hcf6q10HIgmnLXqGEnh994=; b=aa3sajsgVZ6PshA6MusgsC8rS6ddSxYVD650s5rSugUqwIfqeD3u+9VuVppzG+rVqJSb mo66P0pf4iboNapuYAtaYzVD7BfybBT1BeYxRkTpUNUrMY9mH3nyFT8oglG8CLXgx36+3 0ww+fZAMua3AwUNKC6ZpAFYQS6wjP3nDq+rNsmbS0yVQ/8A9wiE7p2hCyAk1N84OvZux3 yBqJcid94NEd42Pywx/5eu/gRGyNsOPvANv5LwuTD4ksyVRJlPseQBYk2eKYF8LOOsQQ8 qaLIjJw2XozAfxh5FRn3wX7ECZf1f70kFlBRj1AnfsCbEY8FsS8CO54UWHvBMc4kHaA== 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="IrxidJ/g"; 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 42B6B606A32D; Fri, 4 Dec 2026 12:09:37 +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=IrxidJ/g Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A5971F000C2; Fri, 4 Dec 2026 12:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386177; bh=tJ8HC7TIMujyGcsJ5h9/2Hcf6q10HIgmnLXqGEnh994=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IrxidJ/gr7gtHmzqdUn5ANNomXG+Bl7l7JuBYF1YtCOn27jgggro0UUsBakv02P41 bKEfBECNUL1ORFnfwnoK4MTwmBRJuHVBNb5n0vwhsEcM58aBLlAXfTApAB04HH7582 EjEWw5Zx4CY7OXRmxfUs9aoLqfD9Ct0TuzxoMrsI= 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.6 0860/1167] ksmbd: sign the last response of a compound that ends early Date: Fri, 4 Dec 2026 19:04:47 +0900 Message-ID: <20261204100724.516890419@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: 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 e757741b0b62a..e8e259c2d66dd 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