From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E57FC31E45 for ; Thu, 13 Jun 2019 15:36:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E1B4206BB for ; Thu, 13 Jun 2019 15:36:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PPFsqHoq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E1B4206BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MokESNrYoPdMjP8Z1gYqxbM4OBPBaLwp3SnJEPcs+NY=; b=PPFsqHoqg2uNzH N91mdSCboM/FVKJVkoF03WuhFWxMNM69I4P2GErtHY6F6DlLAVZdaqiK0w/belIR0gTirUJhxqkNt 0sKp76TrH1M22Sb6pRd6VqGAIvmlCW9OlGy7iPp2yTqPmfHLDeNJlAk5kAhLMjke3Frmo2wlMo09Q GvrxJiERGDG+LarQftPVQQACOYT3kZhkLKWfn5B7NDTv7XFZA8Kx5X482LFADvDxcD4dAhfmNKgig DuqaPD/cVmcVtaVLE+uutk08qwTmuPbSagzk04KJjMOTqWQxWQ6UVIzvsXLe14gM33lRmqWgj+QYT SDZF3hlJdrnLpCKQIU7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbRlf-0007HS-T0; Thu, 13 Jun 2019 15:35:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbRlC-0006xp-LQ for linux-arm-kernel@lists.infradead.org; Thu, 13 Jun 2019 15:35:32 +0000 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 BF6F23EF; Thu, 13 Jun 2019 08:35:29 -0700 (PDT) Received: from C02TF0J2HF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE4553F718; Thu, 13 Jun 2019 08:35:11 -0700 (PDT) Date: Thu, 13 Jun 2019 16:35:07 +0100 From: Catalin Marinas To: Dave Martin Subject: Re: [PATCH v17 03/15] arm64: Introduce prctl() options to control the tagged user addresses ABI Message-ID: <20190613153505.GU28951@C02TF0J2HF1T.local> References: <20190613111659.GX28398@e103592.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190613111659.GX28398@e103592.cambridge.arm.com> User-Agent: Mutt/1.11.2 (2019-01-07) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190613_083530_791190_1FF818A0 X-CRM114-Status: GOOD ( 29.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Christian Koenig , Szabolcs Nagy , Will Deacon , dri-devel@lists.freedesktop.org, Kostya Serebryany , Khalid Aziz , Lee Smith , linux-kselftest@vger.kernel.org, Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Jason Gunthorpe , Dmitry Vyukov , Evgeniy Stepanov , linux-media@vger.kernel.org, Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Kevin Brodsky , Alex Williamson , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Greg Kroah-Hartman , Felix Kuehling , linux-kernel@vger.kernel.org, Jens Wiklander , Ramana Radhakrishnan , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Yishai Hadas , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jun 13, 2019 at 12:16:59PM +0100, Dave P Martin wrote: > 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? Yeah, it went through several names but it seems that I didn't update all places. > > +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. The problem is that if you disable the ABI globally, lots of applications would crash. This sysctl is meant as a way to disable the opt-in to the TBI ABI. Another option would be a kernel command line option (I'm not keen on a Kconfig option). > 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. I left it in for symmetry but I don't expect it to be used. A potential use-case is doing it per subsequent threads in an application. > > + 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? Yes, for MTE. That's why I wouldn't allow random bits here. > I'm wondering whether this is really a bitmask or an enum, or a mixture > of the two. Maybe it doesn't matter. User may want to set PR_TAGGED_ADDR_ENABLE | PR_MTE_PRECISE in a single call. > > + 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. Yes. I forgot you added this. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel