]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
smb: client: fix race with fallocate(2) and AIO+DIO
authorPaulo Alcantara <pc@manguebit.org>
Tue, 7 Oct 2025 19:23:25 +0000 (16:23 -0300)
committerSteve French <stfrench@microsoft.com>
Thu, 9 Oct 2025 15:42:14 +0000 (10:42 -0500)
commitdba9f997c9d9a1cade05d006ed0429a63a4eed32
tree86d8f892d8cf78fd74cf262bf9dddcda6fe6280b
parentb95cd1bdf5aa9221c98fc9259014b8bb8d1829d7
smb: client: fix race with fallocate(2) and AIO+DIO

AIO+DIO may extend the file size, hence we need to make sure ->i_size
is stable across the entire fallocate(2) operation, otherwise it would
become a truncate and then inode size reduced back down when it
finishes.

Fix this by calling netfs_wait_for_outstanding_io() right after
acquiring ->i_rwsem exclusively in cifs_fallocate() and then guarantee
a stable ->i_size across fallocate(2).

Also call netfs_wait_for_outstanding_io() after truncating pagecache
to avoid any potential races with writeback.

Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Fixes: 210627b0aca9 ("smb: client: fix missing timestamp updates with O_TRUNC")
Cc: Frank Sorenson <sorenson@redhat.com>
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsfs.c
fs/smb/client/inode.c
fs/smb/client/smb2ops.c