Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] mm/gup_test: prevent overflow and report actual pinned bytes
@ 2026-09-01  8:34 Sarthak Sharma
  2026-09-01  8:34 ` [PATCH v3 1/2] mm/gup_test: prevent overflow in GUP batch calculation Sarthak Sharma
  2026-09-01  8:34 ` [PATCH v3 2/2] mm/gup_test: report actual pinned bytes Sarthak Sharma
  0 siblings, 2 replies; 6+ messages in thread
From: Sarthak Sharma @ 2026-09-01  8:34 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Jason Gunthorpe, John Hubbard, Peter Xu, Kiryl Shutsemau,
	linux-mm, linux-kernel, Sarthak Sharma

__gup_test_ioctl() accepts the number of pages per call from userspace. Its
batch end calculation can overflow and wrap around, bypassing the existing
check. This can cause GUP to write beyond the allocated pages array. This
issue was reported by Sashiko.

Also, gup->size is calculated from address difference instead of the actual
pages pinned. This can report partial pages pinned as covering the whole
requested range.

Prevent overflow by clamping each batch before calculating next and
report the actual bytes pinned.

Changes in v3:
- Add a new patch to prevent overflow in GUP batch calculation

Changes in v2:
- Fix a typo in the commit message

Previous versions:
v2: https://lore.kernel.org/all/20260831101304.162867-1-sarthak.sharma@arm.com/
v1: https://lore.kernel.org/all/20260831064808.77768-1-sarthak.sharma@arm.com/

Sarthak Sharma (2):
  mm/gup_test: prevent overflow in GUP batch calculation
  mm/gup_test: report actual pinned bytes

 mm/gup_test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-01 13:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01  8:34 [PATCH v3 0/2] mm/gup_test: prevent overflow and report actual pinned bytes Sarthak Sharma
2026-09-01  8:34 ` [PATCH v3 1/2] mm/gup_test: prevent overflow in GUP batch calculation Sarthak Sharma
2026-09-01 10:35   ` Kiryl Shutsemau
2026-09-01 11:22     ` Sarthak Sharma
2026-09-01 13:25       ` Kiryl Shutsemau
2026-09-01  8:34 ` [PATCH v3 2/2] mm/gup_test: report actual pinned bytes Sarthak Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox