LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Catalin Marinas <firstname.lastname@example.org>
To: Andrey Konovalov <email@example.com>
Cc: "Kirill A. Shutemov" <firstname.lastname@example.org>,
Mark Rutland <email@example.com>,
Kate Stewart <firstname.lastname@example.org>,
Thomas Gleixner <email@example.com>,
firstname.lastname@example.org, Will Deacon <email@example.com>,
Linux Memory Management List <firstname.lastname@example.org>,
Ingo Molnar <email@example.com>,
Jacob Bramley <Jacob.Bramley@arm.com>,
Jonathan Corbet <firstname.lastname@example.org>,
Dmitry Vyukov <email@example.com>,
Bart Van Assche <firstname.lastname@example.org>,
Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
Evgeniy Stepanov <email@example.com>,
Kees Cook <firstname.lastname@example.org>,
Ruben Ayrapetyan <Ruben.Ayrapetyan@arm.com>,
Lee Smith <Lee.Smith@arm.com>,
Robin Murphy <email@example.com>,
Al Viro <firstname.lastname@example.org>,
Dan Williams <email@example.com>,
Linux ARM <firstname.lastname@example.org>,
Kostya Serebryany <email@example.com>,
Greg Kroah-Hartman <firstname.lastname@example.org>,
James Morse <email@example.com>,
"Aneesh Kumar K . V" <firstname.lastname@example.org>,
Philippe Ombredanne <email@example.com>,
Andrew Morton <firstname.lastname@example.org>,
Zi Yan <email@example.com>,
"Kirill A . Shutemov" <firstname.lastname@example.org>
Subject: Re: [PATCH 0/6] arm64: untag user pointers passed to the kernel
Date: Thu, 26 Apr 2018 18:56:53 +0100 [thread overview]
Message-ID: <email@example.com> (raw)
On Wed, Apr 25, 2018 at 04:45:37PM +0200, Andrey Konovalov wrote:
> On Thu, Apr 19, 2018 at 11:33 AM, Kirill A. Shutemov
> <firstname.lastname@example.org> wrote:
> > On Wed, Apr 18, 2018 at 08:53:09PM +0200, Andrey Konovalov wrote:
> >> arm64 has a feature called Top Byte Ignore, which allows to embed pointer
> >> tags into the top byte of each pointer. Userspace programs (such as
> >> HWASan, a memory debugging tool ) might use this feature and pass
> >> tagged user pointers to the kernel through syscalls or other interfaces.
> >> This patch makes a few of the kernel interfaces accept tagged user
> >> pointers. The kernel is already able to handle user faults with tagged
> >> pointers and has the untagged_addr macro, which this patchset reuses.
> >> We're not trying to cover all possible ways the kernel accepts user
> >> pointers in one patchset, so this one should be considered as a start.
> > How many changes do you anticipate?
> > This patchset looks small and reasonable, but I see a potential to become a
> > boilerplate. Would we need to change every driver which implements ioctl()
> > to strip these bits?
> I've replied to somewhat similar question in one of the previous
> versions of the patchset.
> There are two different approaches to untagging the user pointers that I see:
> 1. Untag user pointers right after they are passed to the kernel.
> While this might be possible for pointers that are passed to syscalls
> as arguments (Catalin's "hack"), this leaves user pointers, that are
> embedded into for example structs that are passed to the kernel. Since
> there's no specification of the interface between user space and the
> kernel, different kernel parts handle user pointers differently and I
> don't see an easy way to cover them all.
> 2. Untag user pointers where they are used in the kernel.
> Although there's no specification on the interface between the user
> space and the kernel, the kernel still has to use one of a few
> specific ways to access user data (copy_from_user, etc.). So the idea
> here is to add untagging into them. This patchset mostly takes this
> approach (with the exception of memory subsystem syscalls).
> If there's a better approach, I'm open to suggestions.
> So if we go with the first way, we'll need to go through every syscall
> and ioctl handler, which doesn't seem feasible.
I agree with you that (1) isn't feasible. My hack is sufficient for the
pointer arguments but doesn't help with pointers in user structures
passed to the kernel.
Now, since the hardware allows access to user pointers with non-zero top
8-bit, the kernel uaccess routines can also use such pointers directly.
What's needed, as per your patches, is the access_ok() macro and
whatever ends up calling find_vma() (at a first look, there may be other
cases). I don't think drivers need changing as long as the in-kernel API
they use performs the untagging (e.g. get_user_pages()).
prev parent reply other threads:[~2018-04-26 17:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 18:53 Andrey Konovalov
2018-04-18 18:53 ` [PATCH 1/6] arm64: add type casts to untagged_addr macro Andrey Konovalov
2018-04-18 18:53 ` [PATCH 2/6] uaccess: add untagged_addr definition for other arches Andrey Konovalov
2018-04-18 18:53 ` [PATCH 3/6] arm64: untag user addresses in copy_from_user and others Andrey Konovalov
2018-04-26 15:47 ` Catalin Marinas
2018-05-02 15:29 ` Andrey Konovalov
2018-04-18 18:53 ` [PATCH 4/6] mm, arm64: untag user addresses in mm/gup.c Andrey Konovalov
2018-04-26 17:47 ` Catalin Marinas
2018-05-02 14:38 ` Andrey Konovalov
2018-05-02 15:36 ` Kirill A. Shutemov
2018-05-02 17:25 ` Andrey Konovalov
2018-05-03 14:09 ` Andrey Konovalov
2018-05-03 15:24 ` Kirill A. Shutemov
2018-05-03 16:51 ` Andrey Konovalov
2018-05-08 15:11 ` Catalin Marinas
2018-05-11 12:36 ` Andrey Konovalov
2018-04-18 18:53 ` [PATCH 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Andrey Konovalov
2018-04-18 18:53 ` [PATCH 6/6] arm64: update Documentation/arm64/tagged-pointers.txt Andrey Konovalov
2018-04-19 9:33 ` [PATCH 0/6] arm64: untag user pointers passed to the kernel Kirill A. Shutemov
2018-04-25 14:45 ` Andrey Konovalov
2018-04-26 17:56 ` Catalin Marinas [this message]
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--subject='Re: [PATCH 0/6] arm64: untag user pointers passed to the kernel' \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).