diff options
| author | Sarthak Sharma <sarthak.sharma@arm.com> | 2026-09-15 15:55:24 +0530 |
|---|---|---|
| committer | David Hildenbrand (Arm) <david@kernel.org> | 2026-09-16 11:50:10 +0000 |
| commit | 44817a536aaa5bfac0d316242e93e489d0a69d5f (patch) | |
| tree | 6958f2baa1ad0d59692c85b594b7c9d6c2a3d18f /tools/lib/python/kdoc/python_version.py | |
| parent | 535613dda557c1bfb9d300e1513c8ddf627d31bf (diff) | |
| download | linux-next-44817a536aaa5bfac0d316242e93e489d0a69d5f.tar.gz linux-next-44817a536aaa5bfac0d316242e93e489d0a69d5f.zip | |
mm/gup_test: safely calculate GUP batch size
__gup_test_ioctl() calculates the end of a GUP batch using:
next = addr + nr * PAGE_SIZE;
If nr is too large, it can cause next to overflow and wrap around.
If it wraps, the next > end check is bypassed and a large value
of nr is passed to the GUP call, even though the pages array was
allocated according to gup->size. This can lead to out of bounds writes.
Also, when fewer than PAGE_SIZE bytes remain, the calculated batch
contains zero pages. The code still calls GUP functions with pages + i,
which can point past the allocated array.
Calculate nr by taking the minimum of the number of pages per call and
the pages remaining in the address range. Reject zero sized and non
page aligned gup->size values and zero nr_pages_per_call value.
Fixes: 64c349f4ae78 ("mm: add infrastructure for get_user_pages_fast() benchmarking")
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Sarthak Sharma <sarthak.sharma@arm.com>
Link: https://patch.msgid.link/20260915102524.125758-1-sarthak.sharma@arm.com
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc/python_version.py')
0 files changed, 0 insertions, 0 deletions
