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=1796388887; b=dMbmTkoj+8R4FIqb+HF9wBtbTIb7dMnGXNPzYSMGSeilTd+YDd1RAGJTRZ6sa1S/EPjR EghRmHKOssSKjrl7OF270upwrZiv/xuZyU79gPTZG02rsUH6W1zWQq8ELsRxNzX84+oa4 shYt3Kid0ha80zEHN6wohX1EvFZHPT2qjxFPlyeqYup6Wfrz6JhMXZDcUyXBMMLtEiIqe IwIhbxv1ZTUwzj2pPBK9OlqFpQMCx304LGD4BF7pnIkwARbkka1Ye+7+XkOO+GryL20ZR GzdqGklkOuESdUY2rAsE4TfggGZDTmiNTOPtTeWH9OhcwFEuk3Zu5roFu25K1NzGzJw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388887; 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=xosWX5CLqUVmiKxigl8RpMOWgk/VBgwuwxvrG+EsqEQ=; b=EGgX0rSSerOf0QBLc5oOquJTmACDLkuj8OWP/e3fWK1ReJkx+U2YeiytQe6zuJYbEPkS Eexh3NYfX994qpBNGOMHST9ZGdkek7zZvqfAoanWRqkZbDN0hUFvUNX3sS5hFqbYKAIMJ 0hLv4PY3M5NVkPrsoZQI0WNTzxoZJIjm60QsgvLuLnF0zMPD/EaNo2Oio5hFNoX9Er6c+ mKXVJPHpzlL1fR6/SZuy80PP58VzDs+BKBWMh2GxfQWpLnZ6OvfAJeKlT2FHLs1JX5t+d n8NQFYIEj7mlshecaAe5a1e7HQWqCk746ZOPCGusfthGy8wwhSILBuJ1bpqO08BF+VA== 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=tqUj+2nv; 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 99991606A330; Fri, 4 Dec 2026 12:54: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=tqUj+2nv Received: by smtp.kernel.org (Postfix) with ESMTPSA id C83EC1F0092C; Fri, 4 Dec 2026 12:54:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388887; bh=xosWX5CLqUVmiKxigl8RpMOWgk/VBgwuwxvrG+EsqEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tqUj+2nvy1KjAxTjMtyvvrJ+Nn0UA47MhcZ/yi1BypzvL5MrXk42rb3AriUG/UkPc qUuqoNqc+ex9A3EciH3nfX/ldn6YxCUGXNwLf9FcYu6SJpGgv/RrtLxHZYRitQQ/2A jp+qt4WJglkamPJEjrQ8vDx4k+Eq6RfbJFNcp9KQ= 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.1 0787/1059] ksmbd: sign the last response of a compound that ends early Date: Fri, 4 Dec 2026 19:05:18 +0900 Message-ID: <20261204100704.417233837@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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 f951c6047c16a..8501df4b0db54 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