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=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 496F8C43461 for ; Sun, 4 Apr 2021 15:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18B5561369 for ; Sun, 4 Apr 2021 15:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbhDDPyq (ORCPT ); Sun, 4 Apr 2021 11:54:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230039AbhDDPyo (ORCPT ); Sun, 4 Apr 2021 11:54:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8BDF561368; Sun, 4 Apr 2021 15:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617551680; bh=Y+EXlFwOcupRcJHejpzX9O0l3XK9lB+QcIyNrCwXUZg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XwqnVFHquFYuCIg7xJmXG5NoG4GTtS3nhGBRNZQq9WvMNiHQ4ULTf9bkymZx+Kd7j ENn7ChaWWxdC2UvBl8qajs2NkEln3JuqbCR4LFbfRYrIPpCs4XEaLfe+SbDODSBexz 930qW/iWzfaIkJtlUDqBln4fecgjZVgKidnqkdABU/GD7yNkwNzBnZV/esL3K7D8SB 8BHevk1he7oHwcuvEk9l/Kk2ZzhFILOcCHWEIi2H9b1eHY9vZctMXPP/oaPNjb3+JR VP7dlUhnhpLGrXXiXslFWQGV1lj62lK1ajJjDSttB64ZjSQ/1h96ngUCM4oPiKSV37 L4c7QJ5hxJaQw== Date: Sun, 4 Apr 2021 18:54:37 +0300 From: Jarkko Sakkinen To: Yu-cheng Yu 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 Subject: Re: [PATCH v24 9/9] x86/vdso: Add ENDBR to __vdso_sgx_enter_enclave Message-ID: References: <20210401221403.32253-1-yu-cheng.yu@intel.com> <20210401221403.32253-10-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210401221403.32253-10-yu-cheng.yu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 01, 2021 at 03:14:03PM -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 > 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 86a0e94f68df..c63eafa54abd 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 > + ENDBR > 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 > + ENDBR > > /* 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: > + ENDBR > mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx > > /* Set the exception info. */ > -- > 2.21.0 > > /Jarkko