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=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 99884C433E0 for ; Mon, 3 Aug 2020 10:14:53 +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 6402C20678 for ; Mon, 3 Aug 2020 10:14:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="1oN7eKU2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6402C20678 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+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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tz58kyLe6SVVPXmhG+ZOMhyYMFgkwlFL/0VBoN2j9HI=; b=1oN7eKU2lAlWN7c6aV5qpspih Bn/FlXi8KQAfqZ0dA4tRfqtF/jliMdHC+BUnnhuSRDfmTwTwOXzfKwCKdVqIPiVsiuUDmBtgMpi32 zSCsMNN7pUtFfIGDvPBahaeRw1VWalOt9H5/iAt22a1yJO07GgjGSz8eC8/OoKvAaj0Vx9dmlgyIk mQB9eO7WQ0JCeUDTDRdWB9R23SS5g0T3ZJK0+ENUuM7UaPezqhJe8/YD9VrSF1gEHeE+VMf62cepU rYpE+ffwzWMXnNV7tv7BNiui8R65E3u+vB5NDxLfuXfMCN9KrOdhjmcF/o5GbFXJXcP39UnO7liff oJblQ8/4g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2XT9-0006dj-NZ; Mon, 03 Aug 2020 10:13:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2XT7-0006av-Vp for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2020 10:13:23 +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 9652330E; Mon, 3 Aug 2020 03:13:13 -0700 (PDT) Received: from [10.57.2.218] (unknown [10.57.2.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D55603F6CF; Mon, 3 Aug 2020 03:13:10 -0700 (PDT) Subject: Re: [PATCH v4 1/4] arm64: ptrauth: add Armv8.3 pointer authentication enhanced features To: Dave Martin References: <1594368010-4419-1-git-send-email-amit.kachhap@arm.com> <1594368010-4419-2-git-send-email-amit.kachhap@arm.com> <20200729110703.GF21941@arm.com> From: Amit Kachhap Message-ID: <2e5f8551-d301-6282-bfec-c3f71d27335e@arm.com> Date: Mon, 3 Aug 2020 15:43:14 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200729110703.GF21941@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200803_061322_119581_CD40E2F8 X-CRM114-Status: GOOD ( 37.45 ) 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 , Kees Cook , Suzuki K Poulose , Catalin Marinas , Mark Brown , James Morse , Vincenzo Frascino , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On 7/29/20 4:37 PM, Dave Martin wrote: > On Fri, Jul 10, 2020 at 01:30:07PM +0530, Amit Daniel Kachhap wrote: >> Some Armv8.3 Pointer Authentication enhancements have been introduced >> which are mandatory for Armv8.6 and optional for ARMv8.3. These features >> are, >> >> * ARMv8.3-PAuth2 - An enhanced PAC generation logic is added which hardens >> finding the correct PAC value of the authenticated pointer. >> >> * ARMv8.3-FPAC - Fault is generated now when the ptrauth authentication >> instruction fails in authenticating the PAC present in the address. >> This is different from earlier case when such failures just adds an >> error code in the top byte and waits for subsequent load/store to abort. >> The ptrauth instructions which may cause this fault are autiasp, retaa >> etc. > > Did we add anything for armv8.5 EnhancedPAC? > > I think that just changes some detail of the signing/authentication > algorithms, rather than adding new insns or exceptions. So maybe there > was nothing to add anyway. Yes agreed. There are only small stuffs added here, cpufeature configurations and new exception class code. I will change commit log to reflect this. > > >> The above features are now represented by additional configurations >> for the Address Authentication cpufeature. >> >> The userspace fault received in the kernel due to ARMv8.3-FPAC is treated >> as Illegal instruction and hence signal SIGILL is injected with ILL_ILLOPN >> as the signal code. Note that this is different from earlier ARMv8.3 >> ptrauth where signal SIGSEGV is issued due to Pointer authentication >> failures. The in-kernel PAC fault causes kernel to crash. > > Presumably this breaks code that checks pointers using AUT* but doesn't > attempt to dereference them if the check fails, perhaps calling some > userspace callback to handle it or throwing an exception. Should we worry about it? EPAC is essentially added to not make the intermediate result of authenticate made available as it will impact the security of key or PAC algorithm. > > Since the point of the architecture though is that you don't need to do > an explicit check, maybe code doesn't do this in practice. Checking > codesearch.debian.net or similar for explicit AUT* instructions could be > good idea. I will check if I can find any. > > If this is a concern we might have to stop reporting HWCAP_PACA and > HWCAP_PACG, and define new hwcaps. That seems brutal, though. ok. > >> >> Signed-off-by: Amit Daniel Kachhap >> --- >> Changes since v3: >> * Removed ptrauth fault handler from 32 bit compat layer handler. >> * Added a comment for in-kernel PAC fault kernel crash. >> * Commit logs cleanup. >> >> arch/arm64/include/asm/esr.h | 4 +++- >> arch/arm64/include/asm/exception.h | 1 + >> arch/arm64/include/asm/sysreg.h | 24 ++++++++++++++++-------- >> arch/arm64/kernel/entry-common.c | 21 +++++++++++++++++++++ >> arch/arm64/kernel/traps.c | 10 ++++++++++ >> 5 files changed, 51 insertions(+), 9 deletions(-) >> default: >> el0_inv(regs, esr); >> } >> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c >> index 47f651df781c..0f1e587393a0 100644 >> --- a/arch/arm64/kernel/traps.c >> +++ b/arch/arm64/kernel/traps.c >> @@ -479,6 +479,15 @@ void do_bti(struct pt_regs *regs) >> } >> NOKPROBE_SYMBOL(do_bti); >> >> +void do_ptrauth_fault(struct pt_regs *regs, unsigned long esr) >> +{ >> + /* In-kernel Pointer authentication fault causes kernel crash */ > > Doesn't arm64_notify_die() already dump a backtrace and kill the task? > I wonder whether force_signal_inject() is a reasonable thing to use > here. This is used in some similar places such as do_undefinstr(), > do_bti() etc. Ok i will make it similar to do_bti(). It will be clear that way. > > force_signal_inject() might need some minor tweaking to handle this > case. > >> + BUG_ON(!user_mode(regs)); > > We need to kill the thread, but doesn't arm64_notify_die() already do > that? Yes some other caller of arm64_notify_die do not use BUG_ON for kernel. Thanks, Amit > > (Don't take my word for it though...) > >> + arm64_notify_die("pointer authentication fault", regs, SIGILL, >> + ILL_ILLOPN, (void __user *)regs->pc, esr); >> +} >> +NOKPROBE_SYMBOL(do_ptrauth_fault); >> + >> #define __user_cache_maint(insn, address, res) \ >> if (address >= user_addr_max()) { \ >> res = -EFAULT; \ >> @@ -775,6 +784,7 @@ static const char *esr_class_str[] = { >> [ESR_ELx_EC_SYS64] = "MSR/MRS (AArch64)", >> [ESR_ELx_EC_SVE] = "SVE", >> [ESR_ELx_EC_ERET] = "ERET/ERETAA/ERETAB", >> + [ESR_ELx_EC_FPAC] = "FPAC", >> [ESR_ELx_EC_IMP_DEF] = "EL3 IMP DEF", >> [ESR_ELx_EC_IABT_LOW] = "IABT (lower EL)", >> [ESR_ELx_EC_IABT_CUR] = "IABT (current EL)", >> -- >> 2.17.1 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel