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=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 67C55C1975A for ; Thu, 12 Mar 2020 15:05:52 +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 2D436206BE for ; Thu, 12 Mar 2020 15:05:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D0QrgPE6"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="CmzSDGy7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D436206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EpaSUl72Z1BFZr6xNGYxw6FD8wYOk3K1oAdVQEXFh0c=; b=D0QrgPE6FPXGFNaByJIDsL5/+ KbH0gEdtVn6fVCI3dmR7VL4+1AIAp1PujQVsALwI+0rOxftMWrRnF3XfkehQRoa++BuKqAD0SzCaY vYogLZMcdN2OmWpIUBzPeUV0cD+gcP/vBb5T4HGcDjJhknr/jaEX0HOyGLZFo6XxPIbxZUuCPAUY2 3BowmgI6LDKlPfhdJ6Eg6HZp37DC78NvFaKlauDF4pGnM/BMeLb0hWp+I4kcYHLBRjNBSmilsAjKE CFbt5Tu3w31JA5bwHd5JAcYo5b95V4zzCfHPVOkKCzWTXih1dHDk1sgMRNzwnFh8KJMZmTG3Pb9mt p87DBj32w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCPPB-0001fv-42; Thu, 12 Mar 2020 15:05:49 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCPP5-0001fZ-M2 for linux-arm-kernel@lists.infradead.org; Thu, 12 Mar 2020 15:05:46 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 A80AB2067C; Thu, 12 Mar 2020 15:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584025541; bh=8AcCGmwl34p9HgS/EGgx+kPmyH2l+KR7q9FPherSEL0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CmzSDGy7MntRdiUhHXizcL5qqzTv2vI1ETCcI4mwcnGxK4Rn8PQ0dC5He6955kQBO Km8GqsVkCasn25fExvCnNFUG8VeMj/ejVrBhat2K4d5xFgOTyRJsx4v/EitxhVlPsr uwaCP2jO0r7YWPZseHZoQmQiNCHljpUgKpBRrDAs= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jCPP1-00CFWM-Kq; Thu, 12 Mar 2020 15:05:39 +0000 MIME-Version: 1.0 Date: Thu, 12 Mar 2020 15:05:39 +0000 From: Marc Zyngier To: Amit Kachhap Subject: Re: [PATCH v6 00/18] arm64: return address signing In-Reply-To: <7ba381f0-095d-6994-bb6d-12b2665b4a8e@arm.com> References: <1583476525-13505-1-git-send-email-amit.kachhap@arm.com> <79a45ce2-a632-9821-986e-1f48cb0121c9@arm.com> <98ad6e44-7aef-9ad2-0398-d5d412d8bb23@arm.com> <7ba381f0-095d-6994-bb6d-12b2665b4a8e@arm.com> Message-ID: X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/1.3.10 X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: amit.kachhap@arm.com, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, keescook@chromium.org, ardb@kernel.org, catalin.marinas@arm.com, suzuki.poulose@arm.com, will@kernel.org, ramana.radhakrishnan@arm.com, kristina.martsenko@arm.com, Dave.Martin@arm.com, Vincenzo.Frascino@arm.com, broonie@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200312_080545_500817_D66A8BF2 X-CRM114-Status: GOOD ( 21.16 ) 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 , Kristina Martsenko , Dave Martin , Mark Brown , James Morse , Ramana Radhakrishnan , Vincenzo Frascino , Will Deacon , Ard Biesheuvel , 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+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org [Somehow I managed to butcher the subject line. no idea how...] On 2020-03-12 13:21, Amit Kachhap wrote: > Hi Marc, > > On 3/12/20 6:17 PM, Marc Zyngier wrote: >> Hi Amit, >> >> On 2020-03-12 08:06, Amit Kachhap wrote: >>> Hi James, >>> >>> On 3/12/20 12:23 PM, Amit Kachhap wrote: >>>> Hi James, >>>> >>>> On 3/11/20 2:58 PM, James Morse wrote: >>>>> Hi Amit, >>>>> >>>>> (CC: +Marc) >>>>> >>>>> On 3/6/20 6:35 AM, Amit Daniel Kachhap wrote: >>>>>> This series improves function return address protection for the >>>>>> arm64 kernel, by >>>>>> compiling the kernel with ARMv8.3 Pointer Authentication >>>>>> instructions (referred >>>>>> ptrauth hereafter). This should help protect the kernel against >>>>>> attacks using >>>>>> return-oriented programming. >>>>> >>>>> (as it looks like there may be another version of this:) >>>>> >>>>> Am I right in thinking that after your patch 10 changing >>>>> cpu_switch_to(), only the A key is live during kernel execution? >>>> >>>> Yes >>>> >>>>> >>>>> KVM is still save/restoring 4 extra keys around guest-entry/exit. >>>>> As you >>>>> restore all the keys on return to user-space, is this still >>>>> necessary? >>>> >>>> Yes Its a good optimization to skip 4 non-A keys. I was wondering >>>> whether to do it in this series or send it separately. >>> >>> I suppose we can only skip non-A keys save/restore for host context. >>> If >>> we skip non-A keys for guest context then guest with old >>> implementation >>> will break. Let me know your opinion. >> >> I don't think you can skip anything as far as the guest is concerned. >> But being able to skip the B keys (which is what I expect you call the >> non-A keys) on the host would certainly be useful. > > Thanks for the clarification. > >> >> I assume you have a way to hide them from userspace, though. > > You mean hide all the keys from userspace like below, > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 3e909b1..29cc74f 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -1023,7 +1023,7 @@ static bool trap_ptrauth(struct kvm_vcpu *vcpu, > static unsigned int ptrauth_visibility(const struct kvm_vcpu *vcpu, > const struct sys_reg_desc *rd) > { > - return vcpu_has_ptrauth(vcpu) ? 0 : REG_HIDDEN_USER | > REG_HIDDEN_GUEST; > + return vcpu_has_ptrauth(vcpu) ? REG_HIDDEN_USER : > REG_HIDDEN_USER | REG_HIDDEN_GUEST; > } > > #define __PTRAUTH_KEY(k) > > I don't remember why it was not done this way last time. No, that's not what I meant. What you're describing is preventing keys from being exposed to the VMM controlling the guest, and that'd be pretty bad (you need to be able to save/restore them for migration). But if KVM doesn't save/restore the host's B-keys in the world switch, then you must make sure that no host userspace can make use of them, as they would be the guest's keys. M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel