]> git.baikalelectronics.ru Git - kernel.git/commit
block: make sure that bvec length can't be overflow
authorMing Lei <ming.lei@redhat.com>
Wed, 17 Apr 2019 01:11:26 +0000 (09:11 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 19 Apr 2019 17:32:14 +0000 (11:32 -0600)
commit298da8e26f935914d6e147ffb778ae19870e20e6
treea34352d078072adaff40d3aff0851ea0a87c94a0
parentfd5924775140f2e8fbef1249351ec1f93913eaaf
block: make sure that bvec length can't be overflow

bvec->bv_offset may be bigger than PAGE_SIZE sometimes, such as,
when one bio is splitted in the middle of one bvec via bio_split(),
and bi_iter.bi_bvec_done is used to build offset of the 1st bvec of
remained bio. And the remained bio's bvec may be re-submitted to fs
layer via ITER_IBVEC, such as loop and nvme-loop.

So we have to make sure that every bvec's offset is less than
PAGE_SIZE from bio_for_each_segment_all() because some drivers(loop,
nvme-loop) passes the splitted bvec to fs layer via ITER_BVEC.

This patch fixes this issue reported by Zhang Yi When running nvme/011.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Yi Zhang <yi.zhang@redhat.com>
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Fixes: b3e229b9d9ee ("block: allow bio_for_each_segment_all() to iterate over multi-page bvec")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/bvec.h