mirror_zfs/module
Tomohiro Kusumi 9abbee4912 Don't enter zvol's rangelock for read bio with size 0
The SCST driver (SCSI target driver implementation) and possibly
others may issue read bio's with a length of zero bytes. Although
this is unusual, such bio's issued under certain condition can cause
kernel oops, due to how rangelock is implemented.

rangelock_add_reader() is not made to handle overlap of two (or more)
ranges from read bio's with the same offset when one of them has size
of 0, even though they conceptually overlap. Allowing them to enter
rangelock results in kernel oops by dereferencing invalid pointer,
or assertion failure on AVL tree manipulation with debug enabled
kernel module.

For example, this happens when read bio whose (offset, size) is
(0, 0) enters rangelock followed by another read bio with (0, 4096)
when (0, 0) rangelock is still locked, when there are no pending
write bio's. It can also happen with reverse order, which is (0, N)
followed by (0, 0) when (0, N) is still locked. More details
mentioned in #8379.

Kernel Oops on ->make_request_fn() of ZFS volume
https://github.com/zfsonlinux/zfs/issues/8379

Prevent this by returning bio with size 0 as success without entering
rangelock. This has been done for write bio after checking flusher
bio case (though not for the same reason), but not for read bio.

Reviewed-by: Alek Pinchuk <apinchuk@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
Closes #8379 
Closes #8401
2019-02-20 10:14:36 -08:00
..
avl Update build system and packaging 2018-05-29 16:00:33 -07:00
icp Fedora 28: Fix misc bounds check compiler warnings 2018-08-26 12:55:44 -07:00
lua Update build system and packaging 2018-05-29 16:00:33 -07:00
nvpair Add new fnvlist_lookup_* functions 2018-10-03 15:30:55 -07:00
spl OpenZFS 9284 - arc_reclaim_thread has 2 jobs 2018-12-26 13:22:28 -08:00
unicode Update build system and packaging 2018-05-29 16:00:33 -07:00
zcommon Linux 5.0 compat: access_ok() drops 'type' parameter 2019-01-28 10:11:10 -08:00
zfs Don't enter zvol's rangelock for read bio with size 0 2019-02-20 10:14:36 -08:00
.gitignore Prepare SPL repo to merge with ZFS repo 2018-05-29 14:51:39 -07:00
Makefile.in Linux 5.0 compat: Fix SUBDIRs 2019-01-28 10:11:45 -08:00