From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: linkinjeon@kernel.org, pc@manguebit.org
Cc: ematsumiya@suse.de, sprasad@microsoft.com,
linux-cifs@vger.kernel.org, bharathsm@microsoft.com,
ronniesahlberg@gmail.com, samba-technical@lists.samba.org,
daniel.birtwhistle@gehealthcare.com,
linux-kernel@vger.kernel.org, smfrench@gmail.com,
dhowells@redhat.com, tom@talpey.com
Subject: [PATCH v2 2/2] smb: client: don't use read data that failed signature verification
Date: Mon, 16 Nov 2026 04:06:24 +0000 [thread overview]
Message-ID: <20261116-smb2-sign-v2-2-a823a90d0db4@gmail.com> (raw)
In-Reply-To: <20261116-smb2-sign-v2-0-a823a90d0db4@gmail.com>
From: Suyuan Wang <stevewong@hust.edu.cn>
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.
Clear got_bytes when the signature check fails, as the retry path in the
same function already does.
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>
---
fs/smb/client/smb2pdu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index f85595136ef8..1245572c022e 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -4723,6 +4723,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);
--
2.34.1
prev parent reply other threads:[~2026-11-16 4:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 4:06 [PATCH v2 0/2] smb: client: don't use SMB2 responses that fail " Suyuan Wang via B4 Relay
2026-11-16 4:06 ` [PATCH v2 1/2] smb: client: fail SMB2 responses with a bad signature Suyuan Wang via B4 Relay
2026-11-16 4:06 ` Suyuan Wang via B4 Relay [this message]
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=20261116-smb2-sign-v2-2-a823a90d0db4@gmail.com \
--to=devnull+shyckless.gmail.com@kernel.org \
--cc=bharathsm@microsoft.com \
--cc=daniel.birtwhistle@gehealthcare.com \
--cc=dhowells@redhat.com \
--cc=ematsumiya@suse.de \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=shyckless@gmail.com \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®