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=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 BCCD6C1975A for ; Thu, 12 Mar 2020 17:31:43 +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 8AFBB20724 for ; Thu, 12 Mar 2020 17:31:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sFoVgIVb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="N6zT3pYz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AFBB20724 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=sKZzLqcNUoqlytR6FkcisLnedxemVrbnAuWKq2VNO9c=; b=sFoVgIVbFO3Ld+5hMOkW7BI/f Lh0NORkGVz6m/HuSSzjrE9vWbvs3OGhIaCjVR9L8FFYyOyMs8jHBfCtGGn9HSeSUso0A2YCUHSOgc y5CinjlSVwaVhPfTPCkbDHxINhZDmPU5Dp75zecdYctUfBNm3PLgsMMrU/Y65/qgf9MsYQmMpaXOj 7wWs6DiRLlBYU7T5iZoFp+HfP0tEePVAJaw2PZA55lkZCA8aOYjS5Isqh2RUh4wPzVBrHEdMll2K4 FcOkcjxggNKDzjNNRHxN49dLTla5xORy0/CjE0pGSYvU7cZcxADGfN6PvX/FisxWxmJFEbm3bqSZP ezq08a3fA==; 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 1jCRgN-0000oi-2p; Thu, 12 Mar 2020 17:31:43 +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 1jCRgI-0000nV-NK for linux-arm-kernel@lists.infradead.org; Thu, 12 Mar 2020 17:31:41 +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 3AAF1206B1; Thu, 12 Mar 2020 17:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584034298; bh=n2Pp5AcyDGEum+ApqygaXC11A3ogD+//DnqxMAEod+o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=N6zT3pYzkxJpncsdAy7gAI+9sua6GeYm6byJ0XGapzdkXB5DET1uSCvM9sgZ8FSTD UxUvFzoJIVCFxMwvuvTMyACSryE2cEDxCcswX5C7GcZs2Gw3XVyQjeEEax3LvSTJfq y1Lq0cQZuSVgrZRLH5ZH/3Rd6uFNFIcLxeVNy3gg= 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 1jCRgG-00CHUT-JL; Thu, 12 Mar 2020 17:31:36 +0000 MIME-Version: 1.0 Date: Thu, 12 Mar 2020 17:31:36 +0000 From: Marc Zyngier To: James Morse Subject: Re: [PATCH v6 00/18] arm64: return address signing In-Reply-To: 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: <87945e6110511caaceeb3f1294b6f88f@kernel.org> 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: james.morse@arm.com, amit.kachhap@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_103138_799807_BC8FB6EA X-CRM114-Status: GOOD ( 20.18 ) 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 , Ramana Radhakrishnan , Amit Kachhap , 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 Hi James, On 2020-03-12 17:26, James Morse wrote: > Hi Amit, Marc, > > On 12/03/2020 15:05, Marc Zyngier wrote: >> On 2020-03-12 13:21, Amit Kachhap wrote: >>> On 3/12/20 6:17 PM, Marc Zyngier wrote: >>>> On 2020-03-12 08:06, Amit Kachhap wrote: >>>>> On 3/12/20 12:23 PM, Amit Kachhap wrote: >>>>>> On 3/11/20 2:58 PM, James Morse wrote: >>>>>>> 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. > >> 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. > > Yes, the arch code entry.S changes cover this with > ptrauth_keys_install_user. It restores > 4 keys, and the generic key. > > > We always need to save/restore all the guest keys (as we do today). > But when ptrauth_restore_state restores the host keys, it only needs > to restore the one > the kernel uses. (possibly using the same macro's so it stays up to > date?!) > > If we return to user-space, the arch code's entry code does the right > thing. > KVM's user-space peeking at the keys will see the saved values. > > > My original question was more around: do we need to do this now, or > can we clean it up in > a later kernel version? > > (and a sanity check that it doesn't lead to a correctness problem) I think what we have now is sane, and doesn't seem to lead to any issue (at least that I can see). We can always optimize this at a later point. Thanks, 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