]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: verify all pages in multi-page bvec fall within registered range
authorMing Lei <tom.leiming@gmail.com>
Thu, 9 Apr 2026 13:30:14 +0000 (21:30 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 10 Apr 2026 01:08:35 +0000 (19:08 -0600)
commit211ff1602b67e26125977f8b2f369d7c2847628c
treed7376474d7fc27ddd9f5bdc6767f80f919b3db2c
parent23b3b6f0b584b70a427d5bb826d320151890d7da
ublk: verify all pages in multi-page bvec fall within registered range

rq_for_each_bvec() yields multi-page bvecs where bv_page is only the
first page. ublk_try_buf_match() only validated the start PFN against
the maple tree, but a bvec can span multiple pages past the end of a
registered range.

Use mas_walk() instead of mtree_load() to obtain the range boundaries
stored in the maple tree, and check that the bvec's end PFN does not
exceed the range. Also remove base_pfn from struct ublk_buf_range
since mas.index already provides the range start PFN.

Reported-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20260409133020.3780098-3-tom.leiming@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c