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=1796380007; b=wQ/AYRFTJbjK1+ZEWoVMlUtKALiFuxQFaqY0YY9BK2QXIooJ1neuxy+EO7hzc98B5lQP Bbri23SFfDPFwHV+S8epVk6bgs1krOpp2hTYnE3Ly4KxOYK2xb/r0fAw+JEBqM3Y98AwT RnoGpbhFolRZLEkRKWFDtCPfXP/UyRCreIZqDTNL6Qy5s+xkbPxJGOwPnuUY0btKZpLbw Bse7wFVK6k9abW903fhYYA/R/QXlVgtAYYUsEw4fLsGUfAJDhB8cGvCH0BfEGazZSPR/R bunjuSkqYRY04SmLVqPpjd08jiF0S4DwVyk9aIluW6Yl6zqVLP1tybVgzoA2SsvcGRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380007; 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=oPHeEtQcocvSMkQZz1oLcmCj8dw90Av/V2xKVPbG+yo=; b=c1bmM660Czb79Npa9g8k83iNbWXQxVNxb+picjk4ntUGnNr++sPeM2K7Hj3e2zSvLzxb Xbh+wm/DQ3UEujmxkLBT6dVHNz9EJl7fdfq72zYMLeo86syYEdn98vt/sLRjkLoFlWxfQ FOnGZTr/FFavN51dpPlShC/aDsGK1HTpElhcGUZUiZZ3DNkyeCzL+Pmc3XU6u3+io9fVM LIzpB38+Nlcn5uQ15tKN3CWtUeYgft1meqQxVCjIORjrfibM09hvI+W6Aa9omsgxdei40 yqIJ19AVJCfPvfb4QGsHHm3SgxH4oyzy1w965tJGz7JjmgYH9nE29AqUDz+evkm3RyQ== 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=N6I7MvnA; 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 5B55B606A322; Fri, 4 Dec 2026 10:26:47 +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=N6I7MvnA Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE5B71F000C2; Fri, 4 Dec 2026 10:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380007; bh=oPHeEtQcocvSMkQZz1oLcmCj8dw90Av/V2xKVPbG+yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N6I7MvnAx/FJctkFNeYfD4NOJyEOwvQ27ca/qAwOgYFhM9sGM9Cch4eac0RyDHHqE ARhRCacvMWeqgTut2h2gtbmIG6NS1eBheKdWQL3/aB51LsDvTmcDy060wVvnLGy6Gk 3mvZyx6iKs0J6xGsbeACFjSlLK2RT329pbjSVF+E= 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 7.3 086/742] ksmbd: sign the last response of a compound that ends early Date: Fri, 4 Dec 2026 18:59:10 +0900 Message-ID: <20261204100637.395849716@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: 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 7.3-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 c8e87c7c8bc21..213310bc41a18 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -702,7 +702,7 @@ 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; } /* @@ -719,16 +719,21 @@ bool is_chained_smb2_message(struct ksmbd_work *work) if ((u64)ALIGN(get_rfc1002_len(work->response_buf), 8) + next_rsp_sz > 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