diff options
| author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2025-06-12 17:42:53 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-06-19 16:28:44 +0300 |
| commit | c9a2e81583d9f55fe6e0e899dd5760cfe6bd99bc (patch) | |
| tree | 41508b0b6eb797c043f1235d9b87eb8545933a67 /include/linux | |
| parent | 9e263d94593b733b0fc4cb123c31027b37ab5e37 (diff) | |
| download | linux-c9a2e81583d9f55fe6e0e899dd5760cfe6bd99bc.tar.xz | |
block: Fix bvec_set_folio() for very large folios
[ Upstream commit 5e223e06ee7c6d8f630041a0645ac90e39a42cc6 ]
Similarly to 26064d3e2b4d ("block: fix adding folio to bio"), if
we attempt to add a folio that is larger than 4GB, we'll silently
truncate the offset and len. Widen the parameters to size_t, assert
that the length is less than 4GB and set the first page that contains
the interesting data rather than the first page of the folio.
Fixes: 26db5ee15851 (block: add a bvec_set_folio helper)
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20250612144255.2850278-1-willy@infradead.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/bvec.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/bvec.h b/include/linux/bvec.h index bd1e361b351c..99ab7b2bba27 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -57,9 +57,12 @@ static inline void bvec_set_page(struct bio_vec *bv, struct page *page, * @offset: offset into the folio */ static inline void bvec_set_folio(struct bio_vec *bv, struct folio *folio, - unsigned int len, unsigned int offset) + size_t len, size_t offset) { - bvec_set_page(bv, &folio->page, len, offset); + unsigned long nr = offset / PAGE_SIZE; + + WARN_ON_ONCE(len > UINT_MAX); + bvec_set_page(bv, folio_page(folio, nr), len, offset % PAGE_SIZE); } /** |
