Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7038588ybi; Thu, 13 Jun 2019 08:32:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGQSw+j/6G8v0XoTdNe98PTsm7/g6MLN/XyPa5ErvMZW4S5RT6BgNvyzHeLzp7e1MtW64s X-Received: by 2002:a17:902:6ac6:: with SMTP id i6mr74677641plt.233.1560439957670; Thu, 13 Jun 2019 08:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560439957; cv=none; d=google.com; s=arc-20160816; b=Kq2Hh0VFSAHsLBoXrUmgPLqKR6KDOd1fpuxcgAW1fFoy4QwnmlBqTbeu+TDYOKmHxm 38JyvQ7rr+ZNOsuIQPbIkudmUEHzxmPn1sXtRzaj+tGRrcIae8xaXhCVk9qORzzuUYgc YKMH6NFpP67FqqoYhUDj/EuhSLtFAIyNx6J6tSgPHcfMAnNBXEEcOl19/7lYU5M8Ifra SGDwdgOtnVq+hmNgKww8V9lhBigQmRm8Fkmeoj7wXjzwD9cCHA+TG4xL+M60GbE/FwZO H2L64xCDdKG1zDQCRN0ERQr4i6J2HQPkZOqtdqOeaig3wOBdRAbAP4PITmV7y2cO6ePB AdUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=fNf7W0XDjfuqlv8Ucd7/kRA78LegGdT3pa40skvVgGo=; b=xKcp6CkIXsEtEDJpvFIeFgf8Jnr9a31IpmCWgCmvrFRvV+mUAPVakWjZiAgqYk4mOH 84E+QtmSD2zeYKeCroG7eBk66G9waRUSBSdENi0PjapMrHWR8lm8h/yK6Ptpzy5lA4nt 3KUp6w1s4I1ZN1uzeUyezKBGLOcFSBWRYGgufD3gGTnln50QNAI7/rttmSQ3PgR+94hU i2/0trCK4rOxhcamDw+RMMVccL56EExSLXJojDrDU+3tZDisgl+yezT7JmGwLbdBvFjy xY7YJjO0DbLZxTuGwYZ+yd01fq4tytqAW/qObj6d0sKKUI9ND++fqVVH9DGL939iduBn yfyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si3213185pll.377.2019.06.13.08.32.21; Thu, 13 Jun 2019 08:32:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731977AbfFMPaI (ORCPT + 99 others); Thu, 13 Jun 2019 11:30:08 -0400 Received: from foss.arm.com ([217.140.110.172]:38318 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728816AbfFMLRH (ORCPT ); Thu, 13 Jun 2019 07:17:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68C33367; Thu, 13 Jun 2019 04:17:06 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 11EDF3F694; Thu, 13 Jun 2019 04:18:44 -0700 (PDT) Date: Thu, 13 Jun 2019 12:16:59 +0100 From: Dave Martin To: Andrey Konovalov Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Mark Rutland , Szabolcs Nagy , Catalin Marinas , Will Deacon , Kostya Serebryany , Khalid Aziz , Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , Christoph Hellwig , Jason Gunthorpe , Evgeniy Stepanov , Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Ramana Radhakrishnan , Alex Williamson , Mauro Carvalho Chehab , Dmitry Vyukov , Greg Kroah-Hartman , Yishai Hadas , Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Subject: Re: [PATCH v17 03/15] arm64: Introduce prctl() options to control the tagged user addresses ABI Message-ID: <20190613111659.GX28398@e103592.cambridge.arm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 12, 2019 at 01:43:20PM +0200, Andrey Konovalov wrote: > From: Catalin Marinas > > It is not desirable to relax the ABI to allow tagged user addresses into > the kernel indiscriminately. This patch introduces a prctl() interface > for enabling or disabling the tagged ABI with a global sysctl control > for preventing applications from enabling the relaxed ABI (meant for > testing user-space prctl() return error checking without reconfiguring > the kernel). The ABI properties are inherited by threads of the same > application and fork()'ed children but cleared on execve(). > > The PR_SET_TAGGED_ADDR_CTRL will be expanded in the future to handle > MTE-specific settings like imprecise vs precise exceptions. > > Signed-off-by: Catalin Marinas > --- > arch/arm64/include/asm/processor.h | 6 +++ > arch/arm64/include/asm/thread_info.h | 1 + > arch/arm64/include/asm/uaccess.h | 3 +- > arch/arm64/kernel/process.c | 67 ++++++++++++++++++++++++++++ > include/uapi/linux/prctl.h | 5 +++ > kernel/sys.c | 16 +++++++ > 6 files changed, 97 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h > index fcd0e691b1ea..fee457456aa8 100644 > --- a/arch/arm64/include/asm/processor.h > +++ b/arch/arm64/include/asm/processor.h > @@ -307,6 +307,12 @@ extern void __init minsigstksz_setup(void); > /* PR_PAC_RESET_KEYS prctl */ > #define PAC_RESET_KEYS(tsk, arg) ptrauth_prctl_reset_keys(tsk, arg) > > +/* PR_TAGGED_ADDR prctl */ (A couple of comments I missed in my last reply:) Name mismatch? > +long set_tagged_addr_ctrl(unsigned long arg); > +long get_tagged_addr_ctrl(void); > +#define SET_TAGGED_ADDR_CTRL(arg) set_tagged_addr_ctrl(arg) > +#define GET_TAGGED_ADDR_CTRL() get_tagged_addr_ctrl() > + [...] > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 3767fb21a5b8..69d0be1fc708 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -323,6 +324,7 @@ void flush_thread(void) > fpsimd_flush_thread(); > tls_thread_flush(); > flush_ptrace_hw_breakpoint(current); > + clear_thread_flag(TIF_TAGGED_ADDR); > } > > void release_thread(struct task_struct *dead_task) > @@ -552,3 +554,68 @@ void arch_setup_new_exec(void) > > ptrauth_thread_init_user(current); > } > + > +/* > + * Control the relaxed ABI allowing tagged user addresses into the kernel. > + */ > +static unsigned int tagged_addr_prctl_allowed = 1; > + > +long set_tagged_addr_ctrl(unsigned long arg) > +{ > + if (!tagged_addr_prctl_allowed) > + return -EINVAL; So, tagging can actually be locked on by having a process enable it and then some possibly unrelated process clearing tagged_addr_prctl_allowed. That feels a bit weird. Do we want to allow a process that has tagging on to be able to turn it off at all? Possibly things like CRIU might want to do that. > + if (is_compat_task()) > + return -EINVAL; > + if (arg & ~PR_TAGGED_ADDR_ENABLE) > + return -EINVAL; How do we expect this argument to be extended in the future? I'm wondering whether this is really a bitmask or an enum, or a mixture of the two. Maybe it doesn't matter. > + > + if (arg & PR_TAGGED_ADDR_ENABLE) > + set_thread_flag(TIF_TAGGED_ADDR); > + else > + clear_thread_flag(TIF_TAGGED_ADDR); I think update_thread_flag() could be used here. [...] Cheers ---Dave