Commit ff7d1fc3 authored by Ming Lei's avatar Ming Lei Committed by Cheng Jian
Browse files

virtio_blk: fix handling single range discard request

mainline inclusion
from mainline-5.14-rc7
commit af822aa6
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I47ITN


CVE: NA

-------------------------------------------------

1f23816b ("virtio_blk: add discard and write zeroes support") starts
to support multi-range discard for virtio-blk. However, the virtio-blk
disk may report max discard segment as 1, at least that is exactly what
qemu is doing.

So far, block layer switches to normal request merge if max discard
segment
limit is 1, and multiple bios can be merged to single segment. This way
may
cause memory corruption in virtblk_setup_discard_write_zeroes().

Fix the issue by handling single max discard segment in straightforward
way.

Fixes: 1f23816b ("virtio_blk: add discard and write zeroes support")
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Changpeng Liu <changpeng.liu@intel.com>
Cc: Daniel Verkamp <dverkamp@chromium.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: xuliqun <xuliqun@huayun.com>		# openEuler_contributor
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
parent b3f8fce9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment