cifs: fix data corruption in read after invalidate
authorSteve French <stfrench@microsoft.com>
Wed, 15 May 2024 21:59:01 +0000 (16:59 -0500)
committerSteve French <stfrench@microsoft.com>
Wed, 15 May 2024 22:22:59 +0000 (17:22 -0500)
commita395726cf823fe8f62f1b8c3829010e5652ce98c
treeeea9d5f3fa217a1e6e5766880b4c9e0484f071f9
parent1ab1bd2f6a5fd876d1980d6ade74ce5f83807baf
cifs: fix data corruption in read after invalidate

When invalidating a file as part of breaking a lease, the folios holding
the file data are disposed of, and truncate calls ->invalidate_folio()
to get rid of them rather than calling ->release_folio().  This means
that the netfs_inode::zero_point value didn't get updated in current
upstream code to reflect the point after which we can assume that the
server will only return zeroes, and future reads will then return blocks
of zeroes if the file got extended for any region beyond the old zero
point.

Fix this by updating zero_point before invalidating the inode in
cifs_revalidate_mapping().

Suggested-by: David Howells <dhowells@redhat.com>
Fixes: 3ee1a1fc3981 ("cifs: Cut over to using netfslib")
Reviewed-by: David Howells <dhowell@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/inode.c