All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Collingbourne <pcc@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	 Dave Martin <Dave.Martin@arm.com>, Will Deacon <will@kernel.org>,
	 Andrea Arcangeli <aarcange@redhat.com>,
	Alistair Delva <adelva@google.com>,
	 Lokesh Gidra <lokeshgidra@google.com>,
	William McVicker <willmcvicker@google.com>,
	 Evgenii Stepanov <eugenis@google.com>,
	Mitch Phillips <mitchp@google.com>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	 Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH] userfaultfd: preserve user-supplied address tag in struct uffd_msg
Date: Wed, 30 Jun 2021 16:29:38 -0700	[thread overview]
Message-ID: <CAMn1gO5sZPtBFM+E=2y58i6H7YXcMQqQW1OE_u4F_JwUjLn_2w@mail.gmail.com> (raw)
In-Reply-To: <20210630160831.cf30a5cfa1df524aed42f3bd@linux-foundation.org>

On Wed, Jun 30, 2021 at 4:08 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Mon, 28 Jun 2021 18:20:10 -0700 Peter Collingbourne <pcc@google.com> wrote:
>
> > 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.
> >
> > Fix this by remembering which tag was used to originally register the
> > userfaultfd and passing that tag back in fault.address. In a future
> > enhancement, we may want to pass back the original fault address,
> > but like SA_EXPOSE_TAGBITS, this should be guarded by a flag.
>
> Do we have a Fixes: for this?
>
> Is a -stable backport warranted?

Good point. I think this was an oversight in the original tagged
address ABI, so the appropriate Fixes would be the one that introduced
the prctl(). A stable backport seems reasonable, that's what we're
planning to do in our Android kernel branch anyway. Added the tags in
v2.

Peter


WARNING: multiple messages have this Message-ID (diff)
From: Peter Collingbourne <pcc@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	 Dave Martin <Dave.Martin@arm.com>, Will Deacon <will@kernel.org>,
	 Andrea Arcangeli <aarcange@redhat.com>,
	Alistair Delva <adelva@google.com>,
	 Lokesh Gidra <lokeshgidra@google.com>,
	William McVicker <willmcvicker@google.com>,
	 Evgenii Stepanov <eugenis@google.com>,
	Mitch Phillips <mitchp@google.com>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	 Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH] userfaultfd: preserve user-supplied address tag in struct uffd_msg
Date: Wed, 30 Jun 2021 16:29:38 -0700	[thread overview]
Message-ID: <CAMn1gO5sZPtBFM+E=2y58i6H7YXcMQqQW1OE_u4F_JwUjLn_2w@mail.gmail.com> (raw)
In-Reply-To: <20210630160831.cf30a5cfa1df524aed42f3bd@linux-foundation.org>

On Wed, Jun 30, 2021 at 4:08 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Mon, 28 Jun 2021 18:20:10 -0700 Peter Collingbourne <pcc@google.com> wrote:
>
> > 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.
> >
> > Fix this by remembering which tag was used to originally register the
> > userfaultfd and passing that tag back in fault.address. In a future
> > enhancement, we may want to pass back the original fault address,
> > but like SA_EXPOSE_TAGBITS, this should be guarded by a flag.
>
> Do we have a Fixes: for this?
>
> Is a -stable backport warranted?

Good point. I think this was an oversight in the original tagged
address ABI, so the appropriate Fixes would be the one that introduced
the prctl(). A stable backport seems reasonable, that's what we're
planning to do in our Android kernel branch anyway. Added the tags in
v2.

Peter

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-06-30 23:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29  1:20 [PATCH] userfaultfd: preserve user-supplied address tag in struct uffd_msg Peter Collingbourne
2021-06-29  1:20 ` Peter Collingbourne
2021-06-30 23:08 ` Andrew Morton
2021-06-30 23:08   ` Andrew Morton
2021-06-30 23:29   ` Peter Collingbourne [this message]
2021-06-30 23:29     ` Peter Collingbourne

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='CAMn1gO5sZPtBFM+E=2y58i6H7YXcMQqQW1OE_u4F_JwUjLn_2w@mail.gmail.com' \
    --to=pcc@google.com \
    --cc=Dave.Martin@arm.com \
    --cc=aarcange@redhat.com \
    --cc=adelva@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=eugenis@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=lokeshgidra@google.com \
    --cc=mitchp@google.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    --cc=willmcvicker@google.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 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.