All of lore.kernel.org
 help / color / mirror / Atom feed
From: <gregkh@linuxfoundation.org>
To: stevewong@hust.edu.cn,kaixuan.li@ntu.edu.sg,pc@manguebit.org
Cc: <stable@vger.kernel.org>
Subject: FAILED: patch "[PATCH] smb: client: don't use read data that failed signature" failed to apply to 6.12-stable tree
Date: Wed, 02 Dec 2026 14:55:21 +0100	[thread overview]
Message-ID: <2026120221-vicinity-case-1ede@gregkh> (raw)


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 <stable@vger.kernel.org>.

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
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --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 <stevewong@hust.edu.cn>
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 <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>

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


                 reply	other threads:[~2026-12-02 14:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026120221-vicinity-case-1ede@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=kaixuan.li@ntu.edu.sg \
    --cc=pc@manguebit.org \
    --cc=stable@vger.kernel.org \
    --cc=stevewong@hust.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.