From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrey Konovalov Subject: Re: [PATCH v10 04/12] mm, arm64: untag user pointers passed to memory syscalls Date: Tue, 26 Feb 2019 15:41:26 +0100 Message-ID: References: <3875fa863b755d8cb43afa7bb0fe543e5fd05a5d.1550839937.git.andreyknvl@google.com> <81ea4e77-90a4-4fd9-2bc8-135e0da30044@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <81ea4e77-90a4-4fd9-2bc8-135e0da30044@intel.com> Sender: linux-kernel-owner@vger.kernel.org To: Dave Hansen Cc: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , Linux ARM , "open list:DOCUMENTATION" , Linux Memory Management List , linux-arch , "open list:KERNEL SELFTEST FRAMEWORK" List-Id: linux-arch.vger.kernel.org On Sat, Feb 23, 2019 at 12:07 AM Dave Hansen wrote: > > On 2/22/19 4:53 AM, Andrey Konovalov wrote: > > --- a/mm/mprotect.c > > +++ b/mm/mprotect.c > > @@ -578,6 +578,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, > > SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len, > > unsigned long, prot) > > { > > + start = untagged_addr(start); > > return do_mprotect_pkey(start, len, prot, -1); > > } > > > > @@ -586,6 +587,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len, > > SYSCALL_DEFINE4(pkey_mprotect, unsigned long, start, size_t, len, > > unsigned long, prot, int, pkey) > > { > > + start = untagged_addr(start); > > return do_mprotect_pkey(start, len, prot, pkey); > > } > > This seems to have taken the approach of going as close as possible to > the syscall boundary and untagging the pointer there. I guess that's > OK, but it does lead to more churn than necessary. For instance, why > not just do the untagging in do_mprotect_pkey()? I think that makes more sense, will do in the next version, thanks! > > I think that's an overall design question. I kinda asked the same thing > about patching call sites vs. VMA lookup functions. Replied in the other thread. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f195.google.com ([209.85.210.195]:39470 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbfBZOli (ORCPT ); Tue, 26 Feb 2019 09:41:38 -0500 Received: by mail-pf1-f195.google.com with SMTP id i20so6343866pfo.6 for ; Tue, 26 Feb 2019 06:41:38 -0800 (PST) MIME-Version: 1.0 References: <3875fa863b755d8cb43afa7bb0fe543e5fd05a5d.1550839937.git.andreyknvl@google.com> <81ea4e77-90a4-4fd9-2bc8-135e0da30044@intel.com> In-Reply-To: <81ea4e77-90a4-4fd9-2bc8-135e0da30044@intel.com> From: Andrey Konovalov Date: Tue, 26 Feb 2019 15:41:26 +0100 Message-ID: Subject: Re: [PATCH v10 04/12] mm, arm64: untag user pointers passed to memory syscalls Content-Type: text/plain; charset="UTF-8" Sender: linux-arch-owner@vger.kernel.org List-ID: To: Dave Hansen Cc: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , Linux ARM , "open list:DOCUMENTATION" , Linux Memory Management List , linux-arch , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy Message-ID: <20190226144126.rPLRwXeyHEJ9HJLSklJVog-taeWpdDp-3OqmdT68zmk@z> On Sat, Feb 23, 2019 at 12:07 AM Dave Hansen wrote: > > On 2/22/19 4:53 AM, Andrey Konovalov wrote: > > --- a/mm/mprotect.c > > +++ b/mm/mprotect.c > > @@ -578,6 +578,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, > > SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len, > > unsigned long, prot) > > { > > + start = untagged_addr(start); > > return do_mprotect_pkey(start, len, prot, -1); > > } > > > > @@ -586,6 +587,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len, > > SYSCALL_DEFINE4(pkey_mprotect, unsigned long, start, size_t, len, > > unsigned long, prot, int, pkey) > > { > > + start = untagged_addr(start); > > return do_mprotect_pkey(start, len, prot, pkey); > > } > > This seems to have taken the approach of going as close as possible to > the syscall boundary and untagging the pointer there. I guess that's > OK, but it does lead to more churn than necessary. For instance, why > not just do the untagging in do_mprotect_pkey()? I think that makes more sense, will do in the next version, thanks! > > I think that's an overall design question. I kinda asked the same thing > about patching call sites vs. VMA lookup functions. Replied in the other thread.