]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
netfs: Fix potential for tearing in ->remote_i_size and ->zero_point
authorDavid Howells <dhowells@redhat.com>
Tue, 12 May 2026 12:33:42 +0000 (13:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 12 May 2026 12:42:30 +0000 (14:42 +0200)
commit2c8f4742bb76117d735f92a3932d85239b16c494
tree71c62e508c53aba1ee80510dc739c659caa214e6
parent8a8c0cfdf4658fc5b295b7fc87be56e0d76741f4
netfs: Fix potential for tearing in ->remote_i_size and ->zero_point

Fix potential tearing in using ->remote_i_size and ->zero_point by copying
i_size_read() and i_size_write() and using the same seqcount as for i_size.

We need to make sure that netfslib and the filesystems that use it always
hold i_lock whilst updating any of the sizes to prevent i_size_seqcount
from getting corrupted.

Fixes: 4058f742105e ("netfs: Keep track of the actual remote file size")
Fixes: 100ccd18bb41 ("netfs: Optimise away reads above the point at which there can be no data")
Closes: https://sashiko.dev/#/patchset/20260414082004.3756080-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260512123404.719402-6-dhowells@redhat.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: Matthew Wilcox <willy@infradead.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
20 files changed:
fs/9p/v9fs_vfs.h
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c
fs/afs/file.c
fs/afs/inode.c
fs/afs/internal.h
fs/afs/write.c
fs/netfs/buffered_read.c
fs/netfs/buffered_write.c
fs/netfs/direct_write.c
fs/netfs/misc.c
fs/netfs/write_collect.c
fs/smb/client/cifsfs.c
fs/smb/client/cifssmb.c
fs/smb/client/file.c
fs/smb/client/inode.c
fs/smb/client/readdir.c
fs/smb/client/smb2ops.c
fs/smb/client/smb2pdu.c
include/linux/netfs.h