]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
smb: client: detect short folioq copy in cifs_copy_folioq_to_iter()
authorJeremy Erazo <mendozayt13@gmail.com>
Wed, 20 May 2026 18:23:31 +0000 (18:23 +0000)
committerSteve French <stfrench@microsoft.com>
Wed, 27 May 2026 22:15:24 +0000 (17:15 -0500)
commit426a35d7530722ffa2d89d759c39f5157e0e500d
tree4c69a025bedfde8e69e8c9b8af154a97bdb35331
parente7ae89a0c97ce2b68b0983cd01eda67cf373517d
smb: client: detect short folioq copy in cifs_copy_folioq_to_iter()

cifs_copy_folioq_to_iter() copies a requested number of bytes from
a folio queue into the destination iterator.  Since the encrypted
SMB2 READ path was changed to pass the server-declared payload
length (data_len) instead of the larger folioq buffer length, the
caller can ask for fewer bytes than the folio queue holds.

In that case the helper continues walking the remaining folios after
data_size has reached zero and calls copy_folio_to_iter() with
len = 0, which is unnecessary work.

The helper also returns 0 (success) when the folio queue is
exhausted before data_size bytes have been copied.  The caller has
no way to distinguish that from a full copy and the reported
transfer count ends up larger than the amount of data placed in the
iterator.

Add an early exit when data_size reaches zero, and return an error
when the folio queue is exhausted before all requested bytes have
been copied.

Signed-off-by: Jeremy Erazo <mendozayt13@gmail.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smb2ops.c