Skip to contentSkip to conversation

Patch "cifs: Fix handling of a beyond-EOF DIO/unbuffered read over SMB1" has been added to the 6.12-stable tree

PATCH [email protected] 1 participant 1 message Oct 7

Subsystems (2)
lore
Share & tools
lore

[email protected]

author Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

cifs: Fix handling of a beyond-EOF DIO/unbuffered read over SMB1

to the 6.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
cifs-fix-handling-of-a-beyond-eof-dio-unbuffered-read-over-smb1.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From 9d85ac939d52e93d80efb01a299c6f0bedb30487 Mon Sep 17 00:00:00 2001
From: David Howells <[email protected]>
Date: Tue, 2 Dec 2025 16:24:53 +0000
Subject: cifs: Fix handling of a beyond-EOF DIO/unbuffered read over SMB1

From: David Howells <[email protected]>

commit 9d85ac939d52e93d80efb01a299c6f0bedb30487 upstream.

If a DIO read or an unbuffered read request extends beyond the EOF, the server will return a short read and a status code indicating that EOF was hit, which gets translated to -ENODATA. Note that the client does not cap the request at i_size, but asks for the amount requested in case there's a race on the server with a third party.

Now, on the client side, the request will get split into multiple subrequests if rsize is smaller than the full request size. A subrequest that starts before or at the EOF and returns short data up to the EOF will be correctly handled, with the NETFS_SREQ_HIT_EOF flag being set, indicating to netfslib that we can't read more.

If a subrequest, however, starts after the EOF and not at it, HIT_EOF will not be flagged, its error will be set to -ENODATA and it will be abandoned. This will cause the request as a whole to fail with -ENODATA.

Fix this by setting NETFS_SREQ_HIT_EOF on any subrequest that lies beyond the EOF marker.

This can be reproduced by mounting with "cache=none,sign,vers=1.0" and doing a read of a file that's significantly bigger than the size of the file (e.g. attempting to read 64KiB from a 16KiB file).

Fixes a68c74865f51 ("cifs: Fix SMB1 readv/writev callback in the same way as SMB2/3")
cc Shyam Prasad N <[email protected]>
[Mikhail Mirkin: Adopted for 6.12]
---
 fs/smb/client/cifssmb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifssmb.c +1 -1
@@ -1321,7 +1321,7 @@ cifs_readv_callback(struct mid_q_entry *
 	} else {
 		size_t trans = rdata->subreq.transferred + rdata->got_bytes;
 		if (trans < rdata->subreq.len &&
-		    rdata->subreq.start + trans == ictx->remote_i_size) {
+		    rdata->subreq.start + trans >= ictx->remote_i_size) {
 			__set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags);
 			rdata->result = 0;
 		}

Patches currently in stable-queue which might be from [email protected] are

queue-6.12/smb-client-discard-post-eof-pagecache-when-extending-a-file-via-copy-range.patch queue-6.12/smb-client-discard-post-eof-pagecache-when-extending-a-file-via-zero-range.patch queue-6.12/cifs-fix-handling-of-a-beyond-eof-dio-unbuffered-read-over-smb1.patch queue-6.12/netfs-clear-post-eof-pagecache-when-extending-a-file.patch