The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after rh8-4.18.0-305.3.1.vz8.7.15 ------> commit b1b5d89d9dcf95264873eb4408e8c9ae8406d254 Author: Kirill Tkhai <ktk...@virtuozzo.com> Date: Thu Sep 30 22:08:13 2021 +0300
cbt: Fix off-by-one in map_required_size() Instead of: return DIV_ROUND_UP(bit, 8) + page * PAGE_SIZE; we have to have: return DIV_ROUND_UP(bit, 8) + (page - 1) * PAGE_SIZE; But instead of that we fix @page to be enumerated from 0 in standard C way. Signed-off-by: Kirill Tkhai <ktk...@virtuozzo.com> --- block/blk-cbt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/blk-cbt.c b/block/blk-cbt.c index 1ccc393f1419..e8eee11a87ba 100644 --- a/block/blk-cbt.c +++ b/block/blk-cbt.c @@ -315,15 +315,14 @@ static unsigned long map_required_size(struct page **map, unsigned long block_ma { unsigned long bit, page, npages = NR_PAGES(block_max); - for (page = npages; page > 0; page--) { - if (map[page-1]) + for (page = npages - 1; page != ULONG_MAX; page--) { + if (map[page]) break; } - - if (page == 0) + if (page == ULONG_MAX) return 0; - bit = find_last_bit(page_address(map[page - 1]), PAGE_SIZE); + bit = find_last_bit(page_address(map[page]), PAGE_SIZE); if (bit >= PAGE_SIZE) bit = 0; /* Not found */ else _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel