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=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 6493CC63697 for ; Wed, 18 Nov 2020 13:38:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DA0924671 for ; Wed, 18 Nov 2020 13:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725822AbgKRNhx (ORCPT ); Wed, 18 Nov 2020 08:37:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:53258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbgKRNhx (ORCPT ); Wed, 18 Nov 2020 08:37:53 -0500 Received: from trantor (unknown [2.26.170.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 271312083E; Wed, 18 Nov 2020 13:37:50 +0000 (UTC) Date: Wed, 18 Nov 2020 13:37:47 +0000 From: Catalin Marinas To: Szabolcs Nagy Cc: Peter Collingbourne , Florian Weimer , libc-alpha@sourceware.org, Kevin Brodsky , Linux API , Kostya Serebryany , Evgenii Stepanov , Andrey Konovalov , Vincenzo Frascino , Will Deacon , Dave Martin , Linux ARM Subject: Re: [PATCH v2] arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS) Message-ID: References: <20201014055106.25164-1-pcc@google.com> <87blfv6fj3.fsf@mid.deneb.enyo.de> <20201117183911.GI15033@arm.com> <20201118133121.GA20578@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118133121.GA20578@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Wed, Nov 18, 2020 at 01:31:21PM +0000, Szabolcs Nagy wrote: > The 11/18/2020 12:33, Catalin Marinas wrote: > > On Tue, Nov 17, 2020 at 06:39:13PM +0000, Szabolcs Nagy wrote: > > > The 11/17/2020 10:17, Peter Collingbourne via Libc-alpha wrote: > > > > On Tue, Nov 17, 2020 at 9:48 AM Florian Weimer wrote: > > > > > > > > > > * Peter Collingbourne: > > > > > > > > > > > This prctl allows the user program to control which PAC keys are enabled > > > > > > in a particular task. The main reason why this is useful is to enable a > > > > > > userspace ABI that uses PAC to sign and authenticate function pointers > > > > > > and other pointers exposed outside of the function, while still allowing > > > > > > binaries conforming to the ABI to interoperate with legacy binaries that > > > > > > do not sign or authenticate pointers. > > > > > > > > > > > > The idea is that a dynamic loader or early startup code would issue > > > > > > this prctl very early after establishing that a process may load legacy > > > > > > binaries, but before executing any PAC instructions. > > > > > > > > > > I thought that the silicon did not support this? > > > > I think the past discussion we had was around enabling PAC for kernel > > while disabling it for user. The hardware doesn't give us separate bits, > > so Peter's patch toggles them on kernel entry/return, with some overhead > > given by the MSR+ISB (to be added). > > ah ok. i probably incorrectly thought that toggling that sys > register bit is too much overhead at kernel entry so assumed > we cannot have PAC off by default or set per process. I think Peter can rerun his benchmarks but with the ISB added after MSR. If they are not too bad, we can take this series. > (i think with the proposed prctl it's possible to disable PAC > at early ld.so startup and reenable it before calling into the > main exe entry code, if we ever need to disable PAC-RET.) > > i assume thread creation/fork inherits the setting but exec > does not (this is another point that may be worth adding to > the documentation). Yes, that's my understanding from the patch. It should be documented explicitly (I haven't read the doc updates, maybe it does this already). > if we run into issues in userspace with PAC then a prctl that > can be inherited across exec is a possible workaround (so PAC > can be disabled for an entire process tree). Can you do something similar to MTE with an environment variable forcing PAC off? -- Catalin 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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 75F63C63697 for ; Wed, 18 Nov 2020 13:39:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 F0F30221FC for ; Wed, 18 Nov 2020 13:39:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vDxlkn9K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0F30221FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.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=OJKjaInFcLCmPqFXCK+z4H4lX8S8MJmyUKSpxOmMffE=; b=vDxlkn9K2LE0jle7Pt0rToir1 N4RelqQz3rXcyM67NS8V23tC8XDKwH6H1sTt/5h0aF/KkJNj6PpxA9ULbO3Z4e+wdjJ5q9dXdWJW+ 1WRbgQvCw2tKj6UnT8oXFQJ0oae0LNc/lyb0gJg5J1zWqoUzprsxxPNZcPctlNhnXvLjWWWP+Rq4P OzQUwOpDvgPMdsnFZLzMd3+bQ2tLRPYtxe96OCEMlDERGJRSyuHBcwE1Q0rMo4U5ZpRgwu76SLDXn ahdnhAAQblIkEmyR1XliJ3/BskLKAZc5Wq9GtE9p8OXgjadvHVlmQGbgA89Ox8P6aZVAwqefdrrkD fSVCAPuPg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfNem-0007JN-VM; Wed, 18 Nov 2020 13:37:57 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfNej-0007I9-9b for linux-arm-kernel@lists.infradead.org; Wed, 18 Nov 2020 13:37:55 +0000 Received: from trantor (unknown [2.26.170.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 271312083E; Wed, 18 Nov 2020 13:37:50 +0000 (UTC) Date: Wed, 18 Nov 2020 13:37:47 +0000 From: Catalin Marinas To: Szabolcs Nagy Subject: Re: [PATCH v2] arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS) Message-ID: References: <20201014055106.25164-1-pcc@google.com> <87blfv6fj3.fsf@mid.deneb.enyo.de> <20201117183911.GI15033@arm.com> <20201118133121.GA20578@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201118133121.GA20578@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201118_083753_458659_337772ED X-CRM114-Status: GOOD ( 29.71 ) 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: libc-alpha@sourceware.org, Will Deacon , Linux API , Kevin Brodsky , Kostya Serebryany , Florian Weimer , Linux ARM , Andrey Konovalov , Vincenzo Frascino , Peter Collingbourne , Dave Martin , Evgenii Stepanov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Nov 18, 2020 at 01:31:21PM +0000, Szabolcs Nagy wrote: > The 11/18/2020 12:33, Catalin Marinas wrote: > > On Tue, Nov 17, 2020 at 06:39:13PM +0000, Szabolcs Nagy wrote: > > > The 11/17/2020 10:17, Peter Collingbourne via Libc-alpha wrote: > > > > On Tue, Nov 17, 2020 at 9:48 AM Florian Weimer wrote: > > > > > > > > > > * Peter Collingbourne: > > > > > > > > > > > This prctl allows the user program to control which PAC keys are enabled > > > > > > in a particular task. The main reason why this is useful is to enable a > > > > > > userspace ABI that uses PAC to sign and authenticate function pointers > > > > > > and other pointers exposed outside of the function, while still allowing > > > > > > binaries conforming to the ABI to interoperate with legacy binaries that > > > > > > do not sign or authenticate pointers. > > > > > > > > > > > > The idea is that a dynamic loader or early startup code would issue > > > > > > this prctl very early after establishing that a process may load legacy > > > > > > binaries, but before executing any PAC instructions. > > > > > > > > > > I thought that the silicon did not support this? > > > > I think the past discussion we had was around enabling PAC for kernel > > while disabling it for user. The hardware doesn't give us separate bits, > > so Peter's patch toggles them on kernel entry/return, with some overhead > > given by the MSR+ISB (to be added). > > ah ok. i probably incorrectly thought that toggling that sys > register bit is too much overhead at kernel entry so assumed > we cannot have PAC off by default or set per process. I think Peter can rerun his benchmarks but with the ISB added after MSR. If they are not too bad, we can take this series. > (i think with the proposed prctl it's possible to disable PAC > at early ld.so startup and reenable it before calling into the > main exe entry code, if we ever need to disable PAC-RET.) > > i assume thread creation/fork inherits the setting but exec > does not (this is another point that may be worth adding to > the documentation). Yes, that's my understanding from the patch. It should be documented explicitly (I haven't read the doc updates, maybe it does this already). > if we run into issues in userspace with PAC then a prctl that > can be inherited across exec is a possible workaround (so PAC > can be disabled for an entire process tree). Can you do something similar to MTE with an environment variable forcing PAC off? -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel