]> git.baikalelectronics.ru Git - kernel.git/commit
block: fix .bi_size overflow
authorMing Lei <ming.lei@redhat.com>
Mon, 1 Jul 2019 07:14:46 +0000 (15:14 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 1 Jul 2019 14:18:54 +0000 (08:18 -0600)
commitc2abc3693b2c4e0f7fb64426687001f6bcccca12
tree9394c85b2fa7022176c9bcfad49fa809dc6a15aa
parent0b87bb8b1c87e0faa4625be0c9d9b794d808b75e
block: fix .bi_size overflow

'bio->bi_iter.bi_size' is 'unsigned int', which at most hold 4G - 1
bytes.

Before 8b6e6b8a207f ("block: enable multipage bvecs"), one bio can
include very limited pages, and usually at most 256, so the fs bio
size won't be bigger than 1M bytes most of times.

Since we support multi-page bvec, in theory one fs bio really can
be added > 1M pages, especially in case of hugepage, or big writeback
with too many dirty pages. Then there is chance in which .bi_size
is overflowed.

Fixes this issue by using bio_full() to check if the added segment may
overflow .bi_size.

Cc: Liu Yiding <liuyd.fnst@cn.fujitsu.com>
Cc: kernel test robot <rong.a.chen@intel.com>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: stable@vger.kernel.org
Fixes: 8b6e6b8a207f ("block: enable multipage bvecs")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c
fs/iomap.c
fs/xfs/xfs_aops.c
include/linux/bio.h