Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sarthak Sharma <sarthak.sharma@arm.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Kiryl Shutsemau <kas@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Sarthak Sharma <sarthak.sharma@arm.com>
Subject: [PATCH v3 0/2] mm/gup_test: prevent overflow and report actual pinned bytes
Date: Tue,  1 Sep 2026 14:04:50 +0530	[thread overview]
Message-ID: <20260901083452.115365-1-sarthak.sharma@arm.com> (raw)

__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



             reply	other threads:[~2026-09-01  8:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  8:34 Sarthak Sharma [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260901083452.115365-1-sarthak.sharma@arm.com \
    --to=sarthak.sharma@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=kas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox