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=-6.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 E741BC43381 for ; Fri, 12 Mar 2021 16:57:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B499965025 for ; Fri, 12 Mar 2021 16:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232487AbhCLQ4l (ORCPT ); Fri, 12 Mar 2021 11:56:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:49894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232501AbhCLQ4T (ORCPT ); Fri, 12 Mar 2021 11:56:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BAC46501D; Fri, 12 Mar 2021 16:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615568179; bh=sUw5X72tXoX09gxNNea9KLqurXYlY189vCRL3W4qdik=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G0oi+GyBCIDqsQHVnRhKDpq2WFc+tn4nKcydUWwiiUMAAd5j4YURLpF/QO1JgLRir SvUrEfEL2d9giqM6IwvBQ7/dDcdnZEC4LC/CPwz/RJuIWTSOsYOTXKXVq88RKlVXH5 Gb3gTDMG2Xq3eIbJz2XbKgM8DB/tG3QN5V6WORRVTDIBHFeS9UMCL7DZyzXLvnWQcM QcU2tGem2rA38vh7k2HQVrAjr0Ds2MUPbHGdMDDmPKn0d6AwGLsJiAJFrtZRsjBek/ AURbVhmz3efN/JgVM0lcUWNvS9uuqv6JFgSP+GptQtJvxMuU+dnVSKLISHD/R2GJW7 088JTb7Yx3ZwA== Date: Fri, 12 Mar 2021 18:55:54 +0200 From: Jarkko Sakkinen To: Dave Hansen Cc: "Yu, Yu-cheng" , x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang Subject: Re: [PATCH v22 8/8] x86/vdso: Add ENDBR64 to __vdso_sgx_enter_enclave Message-ID: References: <20210310220519.16811-1-yu-cheng.yu@intel.com> <20210310220519.16811-9-yu-cheng.yu@intel.com> <8b8efe44-b79f-ce29-ee28-066f88c93840@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 03:20:20PM -0800, Dave Hansen wrote: > On 3/10/21 2:55 PM, Yu, Yu-cheng wrote: > > On 3/10/2021 2:39 PM, Jarkko Sakkinen wrote: > >> On Wed, Mar 10, 2021 at 02:05:19PM -0800, Yu-cheng Yu wrote: > >>> When CET is enabled, __vdso_sgx_enter_enclave() needs an endbr64 > >>> in the beginning of the function. > >> > >> OK. > >> > >> What you should do is to explain what it does and why it's needed. > >> > > > > The endbr marks a branch target.  Without the "no-track" prefix, if an > > indirect call/jmp reaches a non-endbr opcode, a control-protection fault > > is raised.  Usually endbr's are inserted by the compiler.  For assembly, > > these have to be put in manually.  I will add this in the commit log if > > there is another revision.  Thanks! > > This is close, but it's missing a detail or two that I think is > important for someone like Jarkko trying to figure out what it means for > his subsystem or driver. > > I'd probably say: > > ENDBR is a special new instruction for the Indirect Branch Tracking > (IBR) component of CET. IBT prevents attacks by ensuring that (most) > indirect branches and function calls may only land at ENDBR > instructions. Branches that don't follow the rules will result in > control flow (#CF) exceptions. > > ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR > instructions are inserted automatically by the compiler, but branch > targets written in assembly must have ENDBR added manually, like this one. Thank you, this clears the whole thing a lot. Doesn't this mean that it could be there just as well unconditionally? /Jarkko