mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Thomas Gleixner <tglx@kernel.org>, Nam Cao <namcao@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	linux-mm@kvack.org, Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>
Subject: Re: [PATCH v3 0/6] vdso/datastore: Allow prefaulting by mlockall()
Date: Wed, 3 Jun 2026 13:35:19 +0200	[thread overview]
Message-ID: <10274d6e-0af2-4f9c-9788-2896065ec16a@kernel.org> (raw)
In-Reply-To: <20260603114217-9eaaa386-a766-4336-8930-250c2ff91d19@linutronix.de>

On 6/3/26 12:10, Thomas Weißschuh wrote:
> On Tue, Jun 02, 2026 at 08:41:31PM +0200, David Hildenbrand (Arm) wrote:
>> On 5/18/26 11:49, Thomas Weißschuh wrote:
>>> While mlockall() is meant to lock page *memory*, effectively it will
>>> also create and lock the corresponding page table entries.
>>> Latency-sensitive applications expect not to experience any pagefaults
>>> after calling mlockall(). However mlockall() ignores VM_IO mappings,
>>> which is used by the generic vDSO datastore.
>>> While the fault handler itself is very fast, going through the full
>>> pagefault exception handling is much slower, on the order of 20us in a
>>> test machine.
>>>
>>> Since the memory behind the datastore mappings is always present and
>>> accessible it is not necessary to use VM_IO for them.
>>
>> GUP also refuses VM_IO, so this change unlocks GUP'ing these pages and using
>> them for DIRECT_IO etc.
>>
>> Well, I assume that GUP-fast (no VMA available) would be able to GUP them
>> already. But mechanisms that don't use GUP-fast would get reliably blocked for now.
> 
> I am not sure about all of the side-effects of GUP.
> Userspace is allowed to read this data in any way it wants.

Ok, good!

> It is *not* allowed
> to interpret it however, which is obviously not enforcable anyways.
> *All* writes from userspace need to be rejected. But those are forbidden via
> VMA flags which as far as I can see are respected by GUP.

Yes, even for FOLL_FORCE (see below).

> 
>> I've been wondering for a while, whether the VM_IO for GUP is still required.
> 
> If that restriction goes away, mlockall() would work automatically for the vDSO
> data pages, no?

Yes. But I guess there is this "debugger should not read/write memory with
side-effects thing.

Again, the GUP-fast interaction is a bit confusing, because that should still
succeed.

But debuggers don't use that. So the VM_IO protects that for now.

> 
>> IIRC, we want to disallow read/write access that could have side effects through
>> ptrace, including process_vm_*(). For memory-mapped I/O that might certainly the
>> case.
> 
> There are no side-effects, this is just global shared memory.
> (But as mentioned before, writes can not be allowed)
> Accesses from other tasks need to be prevented, which is what
> patch 4 tries to do based on FAULT_FLAG_REMOTE.
> 
> The only data in these pages which is not globally shared and accessible
> are the time namespace offsets. But /proc/$PID/timens_offsets is
> world-readable anyways.
> 
>> With your change, you'd also unlock get_dump_page() on vdso pages.
> 
> We use VM_DONTDUMP on the VMA, shouldn't that prevent dumping?
> Dumping these pages is not a (security) issue, just pointless.

Ah, right.

So we still have

VM_READ | VM_MAYREAD | VM_DONTDUMP | VM_MIXEDMAP ...

So even FOLL_FORCE cannot write to it.

It might be good to document the change (pages can not be GUP'ed, including
being read by ptrace etc). But I agree that it should likely be fine.

-- 
Cheers,

David

  reply	other threads:[~2026-06-03 11:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18  9:49 Thomas Weißschuh
2026-05-18  9:49 ` [PATCH v3 1/6] vdso/datastore: Rename data pages variable Thomas Weißschuh
2026-05-18  9:49 ` [PATCH v3 2/6] vdso/datastore: Map pages in terms of the faults pgoff Thomas Weißschuh
2026-05-18  9:49 ` [PATCH v3 3/6] vdso/datastore: Map zeroed pages for unavailable data Thomas Weißschuh
2026-05-18  9:49 ` [PATCH v3 4/6] vdso/datastore: Explicitly prevent remote access to timens vvar page Thomas Weißschuh
2026-05-18  9:49 ` [PATCH v3 5/6] vdso/datastore: Allow prefaulting by mlockall() Thomas Weißschuh
2026-05-18  9:49 ` [PATCH v3 6/6] vdso/datastore: Simplify the mapping logic for VDSO_TIME_PAGE_OFFSET Thomas Weißschuh
2026-06-02 18:41 ` [PATCH v3 0/6] vdso/datastore: Allow prefaulting by mlockall() David Hildenbrand (Arm)
2026-06-03 10:10   ` Thomas Weißschuh
2026-06-03 11:35     ` David Hildenbrand (Arm) [this message]
2026-06-03 12:47       ` Thomas Weißschuh
2026-06-03 12:57         ` David Hildenbrand (Arm)

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=10274d6e-0af2-4f9c-9788-2896065ec16a@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=anna-maria@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=luto@kernel.org \
    --cc=mhocko@suse.com \
    --cc=namcao@linutronix.de \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=tglx@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=vbabka@kernel.org \
    --cc=vincenzo.frascino@arm.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

all inboxes | Powered by JetHome®