]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
block: Hold invalidate_lock in BLKZEROOUT ioctl
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 9 Nov 2021 10:47:23 +0000 (19:47 +0900)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 7 Dec 2021 06:33:43 +0000 (07:33 +0100)
commitfe180696b9128aec0903583a5b1f411e30f04f38
tree80dd3e73d492686fbc12ff854ebbaf2bb10f3c76
parent3388808065e6d54d5b19181ca3414ff4c1602d83
block: Hold invalidate_lock in BLKZEROOUT ioctl

BugLink: https://bugs.launchpad.net/bugs/1951822
commit 35e4c6c1a2fc2eb11b9306e95cda1fa06a511948 upstream.

When BLKZEROOUT 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 modified to call "blkdiscard -z" command
and repeated hundreds of times.

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

Fixes: 22dd6d356628 ("block: invalidate the page cache when issuing BLKZEROOUT")
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-3-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