]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
block: Hold invalidate_lock in BLKDISCARD ioctl
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 9 Nov 2021 10:47:22 +0000 (19:47 +0900)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:48:39 +0000 (09:48 +0100)
commit380621e72f17f16d26472473caaadcdb162cb117
tree5e52c60443aad08546561993c30962eaba7a256b
parentb3744239e9ac899dea1c2128c7487116905d4415
block: Hold invalidate_lock in BLKDISCARD ioctl

BugLink: https://bugs.launchpad.net/bugs/1951822
commit 7607c44c157d343223510c8ffdf7206fdd2a6213 upstream.

When BLKDISCARD ioctl and data read race, the data read leaves stale
page cache. To avoid the stale page cache, hold invalidate_lock of the
block device file mapping. The stale page cache is observed when
blktests test case block/009 is repeated hundreds of times.

This patch can be applied back to the stable kernel version v5.15.y
with slight patch edit. Rework is required for older stable kernels.

Fixes: 351499a172c0 ("block: Invalidate cache on discard v2")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: stable@vger.kernel.org # v5.15
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20211109104723.835533-2-shinichiro.kawasaki@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
block/ioctl.c