commit 5be5bdda5863 ("smb: client: reject out-of-bounds DataOffset in CIFSSMBRead()") rejects any reply whose DataOffset points inside the READ_ANDX header, including a DataOffset of 0. Windows sends a DataOffset of 0 for a read at or beyond EOF, which cifs_readv_receive() and SMB2_read() both accept by treating the data as starting right after the header. Handle it the same way in CIFSSMBRead() rather than rejecting it, and keep the check that DataOffset + DataLength lies within the received response. Fixes: 5be5bdda5863 ("smb: client: reject out-of-bounds DataOffset in CIFSSMBRead()") Cc: stable@vger.kernel.org # 6.19.x Signed-off-by: Mark Bundschuh --- Found while backporting 5be5bdda5863 to older kernels that still read through CIFSSMBRead() in ->read_folio. Against a Windows Server 2025 SMB1 share, reading a file whose size is a multiple of the page size then fails with EIO at the read past EOF. On current kernels the SFU and mfsymlinks parsers are the remaining callers of CIFSSMBRead(). A READ response with a DataOffset of 0, which cifs_readv_receive() and SMB2_read() already accept, makes those lookups fail with EIO instead of being parsed. fs/smb/client/cifssmb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c index 68f05a52605f..5059967b274b 100644 --- a/fs/smb/client/cifssmb.c +++ b/fs/smb/client/cifssmb.c @@ -1728,6 +1728,9 @@ CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms, data_length += le16_to_cpu(pSMBr->DataLength); *nbytes = data_length; + if (data_offset < sizeof(*pSMBr)) + data_offset = sizeof(*pSMBr); + /*check that DataLength would not go beyond end of SMB */ if ((data_length > CIFSMaxBufSize) || (data_length > count)) { @@ -1736,8 +1739,7 @@ CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms, rc = smb_EIO2(smb_eio_trace_read_overlarge, data_length, count); *nbytes = 0; - } else if (data_offset < sizeof(*pSMBr) || - (size_t)data_offset + data_length > rsp_iov.iov_len) { + } else if ((size_t)data_offset + data_length > rsp_iov.iov_len) { /* check that the data lies within the received response */ cifs_dbg(FYI, "%s: bad data offset %u length %u for response of %zu\n", __func__, data_offset, data_length, rsp_iov.iov_len); base-commit: 7ccb044c27720d48175577080b851f047ddcfd1c -- 2.50.1