]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
cifs: Fix race between hole punch and page fault
authorJan Kara <jack@suse.cz>
Thu, 22 Apr 2021 14:52:32 +0000 (16:52 +0200)
committerJan Kara <jack@suse.cz>
Tue, 13 Jul 2021 12:29:01 +0000 (14:29 +0200)
commitb092b3efc7cb239b6f33bb97da0f8812680e1046
treed61a3007db3005aae514814d3d67721432418fda
parent057ba5b24532aca202cb1ae8c246bde27de12763
cifs: Fix race between hole punch and page fault

Cifs has a following race between hole punching and page fault:

CPU1                                            CPU2
smb3_fallocate()
  smb3_punch_hole()
    truncate_pagecache_range()
                                                filemap_fault()
                                                  - loads old data into the
                                                    page cache
    SMB2_ioctl(..., FSCTL_SET_ZERO_DATA, ...)

And now we have stale data in the page cache. Fix the problem by locking
out faults (as well as reads) using mapping->invalidate_lock while hole
punch is running.

CC: Steve French <sfrench@samba.org>
CC: linux-cifs@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
fs/cifs/smb2ops.c