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=1796221548; b=d4L6O/3WA7b+XZ7Z57vc9x0SoeFAYecVrzkpj9720VvRT5nCNp9Wi6SVfOZeN9CUYjVn rdg1GHsNR0n75+2L+qgcs3Kmjfgjo2WZHgPRxYrXWeqrhT2bKL5cLGEb2n0DiDL3YYwIb Y7+7yRqw/tYw43LcurUQ5wx+tuItPWcZRDt1jZN/bqA9g9PX/QumYSR6r0neEJLJVJXaE QcA+BqycRHXH8EzEUXVjKxNDq9sA1W+ob0zxxbd/SRiteaGPumyuaRrwyLQFnu0ctyMrI t8nugzCkp2s4Z5+js2P9+tdjsIV94EODDcjnkl48oLFfG0psHT6ltU1qTAvY+ssxOyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221548; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=tpbresaYA/5CnV2kvDVrWieYIYH3mix4kh1MsRDU1O0=; b=hbVOix0Y7JsXJhxVuig+DIkIrcEMBKEcUAOgRx9Aa1Q8ld9Pnhs1a3hRmH8Uzccc4hVO J7F2dPM10LDPtxNefv5qvucH/dWuFSfcOGEsbstUGTp25ploHrdc9tinJJM7wiY4etyD8 msCQ8gYOajF4rCa3genEV+EDZRLcfwoPAlyo/kdh7skDycopUnbdZ10/IqD09zgP/at49 ZyGMYhX07rtB44OOAJIBcZQfRBYszLxLtShbV0i/msLH3ucyRe1G5yHTm9vajxLIaRHKh abRy0u2OtwjgGMvVLgTV6h3k8YALnx0sTIFZxb4iyWZp4PgsxOYMq1y0uGSK8UtYi4Q== 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=Tg8gckEw; 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 D15C4606A322 for ; Wed, 2 Dec 2026 14:25:48 +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=Tg8gckEw Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3EFC1F00893; Wed, 2 Dec 2026 14:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221548; bh=tpbresaYA/5CnV2kvDVrWieYIYH3mix4kh1MsRDU1O0=; h=Subject:To:Cc:From:Date; b=Tg8gckEwrloaSWEeA30PGecl+KkzrUWg++UBjtsXi95um6R9nA6VM3A3iwdj7DXTT X3rW1VjnezG5cR3RBiOQr45cc+KHviQjBydE76GGesU6rYC7aop0G7kmXxxk4/UUkW YTA5e4BhdgoprdtTn6YYpBp+BqJexnSATZa+2DIs= Subject: FAILED: patch "[PATCH] smb: client: don't use read data that failed signature" failed to apply to 6.12-stable tree To: stevewong@hust.edu.cn,kaixuan.li@ntu.edu.sg,pc@manguebit.org Cc: From: Date: Wed, 02 Dec 2026 14:55:21 +0100 Message-ID: <2026120221-vicinity-case-1ede@gregkh> 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-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x a1a0ef3ba8e802060bfc2b0ebf131a2cf98c3b71 # git commit -s git send-email --to '' --in-reply-to '2026120221-vicinity-case-1ede@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a1a0ef3ba8e802060bfc2b0ebf131a2cf98c3b71 Mon Sep 17 00:00:00 2001 From: Suyuan Wang Date: Thu, 19 Nov 2026 04:00:48 +0000 Subject: [PATCH] smb: client: don't use read data that failed signature verification When smb2_readv_callback() finds a bad signature, it sets the error in rdata->result but leaves rdata->got_bytes alone. Further down, a short read that reaches the remote EOF clears the error again: size_t trans = rdata->subreq.transferred + rdata->got_bytes; if (trans < rdata->subreq.len && rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) { rdata->result = 0; and got_bytes is then added to subreq.transferred. So the last part of a file, or all of a small one, is returned even though its signature is wrong. Clearing got_bytes is not enough on its own. If the read starts at or past the cached remote size, for example because the file has grown on the server since the size was last fetched, the check above still matches and the error turns into EOF, or into a zero-filled tail when NETFS_SREQ_CLEAR_TAIL is set. Clear got_bytes when the signature check fails, as the retry path in the same function already does, and only treat a short read as hitting the remote EOF when the read itself succeeded. That is what commit 1da29f2c39b6 ("netfs, cifs: Fix handling of short DIO read") describes: "clear the error if a short read occurred without error and the read-to file position is now at the remote inode size". Found with a static analysis tool and checked by hand. Fixes: 1da29f2c39b6 ("netfs, cifs: Fix handling of short DIO read") Cc: stable@vger.kernel.org Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Suyuan Wang Signed-off-by: Paulo Alcantara diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 2f05ba613f34..7b7d25364e20 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -4819,6 +4819,8 @@ smb2_readv_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid) rc); rdata->subreq.error = rc; rdata->result = rc; + /* the data can't be trusted, don't count it */ + rdata->got_bytes = 0; if (is_replayable_error(rc)) { trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_retry_needed); @@ -4898,9 +4900,8 @@ smb2_readv_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid) __set_bit(NETFS_SREQ_CLEAR_TAIL, &rdata->subreq.flags); } else { size_t trans = rdata->subreq.transferred + rdata->got_bytes; - if (trans < rdata->subreq.len && + if (!rdata->result && trans < rdata->subreq.len && rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) { - rdata->result = 0; if (rdata->subreq.start + trans >= i_size_read(inode)) __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); else