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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 2D7B3C04FF3 for ; Mon, 24 May 2021 19:01:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05E3561360 for ; Mon, 24 May 2021 19:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233425AbhEXTDW (ORCPT ); Mon, 24 May 2021 15:03:22 -0400 Received: from mga12.intel.com ([192.55.52.136]:4112 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233038AbhEXTDV (ORCPT ); Mon, 24 May 2021 15:03:21 -0400 IronPort-SDR: KsOQ6iihWiaMWpg9u29Abp0csjTSJibjasA371d8RikI0JSHe51+n/qqRUFYaqIsFP4RRHF4m0 EnSjrdlTyntA== X-IronPort-AV: E=McAfee;i="6200,9189,9993"; a="181645940" X-IronPort-AV: E=Sophos;i="5.82,325,1613462400"; d="scan'208";a="181645940" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2021 12:01:53 -0700 IronPort-SDR: f2NKSKkNtLAQOGKQ/SQox+/Jw6D0hjpN+6PBQLNr2y/OYvAvHpL4bWaeDXnqhLPHZf+7BxKWLA kBPtNJtDgMJQ== X-IronPort-AV: E=Sophos;i="5.82,325,1613462400"; d="scan'208";a="435385683" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.255.72.237]) ([10.255.72.237]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2021 12:01:49 -0700 Subject: Re: [PATCH v27 10/10] x86/vdso: Add ENDBR to __vdso_sgx_enter_enclave To: Jarkko Sakkinen Cc: 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 References: <20210521221531.30168-1-yu-cheng.yu@intel.com> <20210521221531.30168-11-yu-cheng.yu@intel.com> From: "Yu, Yu-cheng" Message-ID: <32352b93-8aeb-db26-6018-c103a4f36dd8@intel.com> Date: Mon, 24 May 2021 12:01:48 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On 5/22/2021 3:47 PM, Jarkko Sakkinen wrote: > On Fri, May 21, 2021 at 03:15:31PM -0700, Yu-cheng Yu wrote: >> ENDBR is a special new instruction for the Indirect Branch Tracking (IBT) >> 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. >> >> Add ENDBR to __vdso_sgx_enter_enclave() branch targets. >> >> Signed-off-by: Yu-cheng Yu >> Reviewed-by: Kees Cook >> Cc: Andy Lutomirski >> Cc: Borislav Petkov >> Cc: Dave Hansen >> Cc: Jarkko Sakkinen >> Cc: Peter Zijlstra > > > Acked-by: Jarkko Sakkinen > >> --- >> arch/x86/entry/vdso/vsgx.S | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S >> index 99dafac992e2..c7cb85d57b3f 100644 >> --- a/arch/x86/entry/vdso/vsgx.S >> +++ b/arch/x86/entry/vdso/vsgx.S >> @@ -4,6 +4,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "extable.h" >> >> @@ -27,6 +28,7 @@ >> SYM_FUNC_START(__vdso_sgx_enter_enclave) >> /* Prolog */ >> .cfi_startproc >> + ENDBR64 >> push %rbp >> .cfi_adjust_cfa_offset 8 >> .cfi_rel_offset %rbp, 0 >> @@ -62,6 +64,7 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) >> .Lasync_exit_pointer: >> .Lenclu_eenter_eresume: >> enclu >> + ENDBR64 >> >> /* EEXIT jumps here unless the enclave is doing something fancy. */ >> mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx >> @@ -91,6 +94,7 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) >> jmp .Lout >> >> .Lhandle_exception: >> + ENDBR64 >> mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx >> >> /* Set the exception info. */ >> -- >> 2.21.0 >> >> > > /Jarkko > Thanks!