All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] userfaultfd: do not untag user pointers
@ 2021-07-07 18:43 ` Peter Collingbourne
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Collingbourne @ 2021-07-07 18:43 UTC (permalink / raw)
  To: Catalin Marinas, Vincenzo Frascino, Dave Martin, Will Deacon,
	Andrew Morton, Andrea Arcangeli
  Cc: Peter Collingbourne, Alistair Delva, Lokesh Gidra,
	William McVicker, Evgenii Stepanov, Mitch Phillips, Linux ARM,
	linux-mm, Andrey Konovalov

If a user program uses userfaultfd on ranges of heap memory, it may
end up passing a tagged pointer to the kernel in the range.start
field of the UFFDIO_REGISTER ioctl. This can happen when using an
MTE-capable allocator, or on Android if using the Tagged Pointers
feature for MTE readiness [1].

When a fault subsequently occurs, the tag is stripped from the fault
address returned to the application in the fault.address field
of struct uffd_msg. However, from the application's perspective,
the tagged address *is* the memory address, so if the application
is unaware of memory tags, it may get confused by receiving an
address that is, from its point of view, outside of the bounds of the
allocation. We observed this behavior in the kselftest for userfaultfd
[2] but other applications could have the same problem.

Address this by not untagging pointers passed to the userfaultfd
ioctls. Instead, let the system call fail. Also change the kselftest
to use mmap so that it doesn't encounter this problem.

[1] https://source.android.com/devices/tech/debug/tagged-pointers
[2] tools/testing/selftests/vm/userfaultfd.c

Peter Collingbourne (2):
  userfaultfd: do not untag user pointers
  selftest: use mmap instead of posix_memalign to allocate memory

 Documentation/arm64/tagged-address-abi.rst | 26 +++++++++++++++-------
 fs/userfaultfd.c                           | 26 ++++++++++------------
 tools/testing/selftests/vm/userfaultfd.c   |  6 +++--
 3 files changed, 34 insertions(+), 24 deletions(-)

-- 
2.32.0.93.g670b81a890-goog



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

end of thread, other threads:[~2021-07-09 23:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 18:43 [PATCH v4 0/2] userfaultfd: do not untag user pointers Peter Collingbourne
2021-07-07 18:43 ` Peter Collingbourne
2021-07-07 18:43 ` [PATCH v4 1/2] " Peter Collingbourne
2021-07-07 18:43   ` Peter Collingbourne
2021-07-07 18:43   ` Peter Collingbourne
2021-07-08 12:58   ` Catalin Marinas
2021-07-08 12:58     ` Catalin Marinas
2021-07-07 18:43 ` [PATCH v4 2/2] selftest: use mmap instead of posix_memalign to allocate memory Peter Collingbourne
2021-07-07 18:43   ` Peter Collingbourne
2021-07-07 18:43   ` Peter Collingbourne
2021-07-08 12:59   ` Catalin Marinas
2021-07-08 12:59     ` Catalin Marinas
2021-07-09 23:27   ` Andrew Morton
2021-07-09 23:27     ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.