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=-23.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 A8207C47085 for ; Mon, 24 May 2021 18:51:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 313ED6141F for ; Mon, 24 May 2021 18:51:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 313ED6141F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 59766940087; Mon, 24 May 2021 14:51:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 546C7940076; Mon, 24 May 2021 14:51:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 399F6940087; Mon, 24 May 2021 14:51:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 09C0C940076 for ; Mon, 24 May 2021 14:51:21 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9A6ED12D1 for ; Mon, 24 May 2021 18:51:21 +0000 (UTC) X-FDA: 78177017562.17.492063C Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf15.hostedemail.com (Postfix) with ESMTP id CF1BBA0001DD for ; Mon, 24 May 2021 18:51:17 +0000 (UTC) Received: by mail-pg1-f174.google.com with SMTP id q15so20758351pgg.12 for ; Mon, 24 May 2021 11:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DYhGzoCLydoQC9np+Qc6RmKIKm+MNO34z2K8vwu8xf4=; b=dXgwIRb5SvhKcl5kt27uGYyi2v8bnA6P/8PYjDrTrsuiXCuRtluVsJWE1uT7UPNKEd NNOWAIf+w9Ad0X+qgShJueKQ56dr54u5XGzQFkGMUUZ1I25JrgwWP3fYNe6aGjbc2n7O yx5CvyyTEdQKjl3v4yXo5kDLjfVW49xMRcH4H2EudTL0OI9mY1DeyhUVMQzNLbzizHU+ u3uDMSlYW69VUPfv7rvSgB5Dzm8TZ5cRAemuwtp4JAvv+00fasZEt5eMxsw6HAodlSnh S3sAyyvHQl5dAtU96VqUqBlM0g3EVcZ30xIF9J/dZKSp2JytgejFmJf6w1zoolb9io40 vaFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DYhGzoCLydoQC9np+Qc6RmKIKm+MNO34z2K8vwu8xf4=; b=GUGBCUAdfl9bUztPlOuNpG86rFYPHkiA1x4UryUF/Vw/kSlhDKtB6ImieUvc8NCaQK k2OgIQFzpvdZfulVZMCOn/gGtK+dG9yXac8BjeWFdtddm5bNUIV94Rr5XATy6FjCA0ii QqHdPtwef4onkBRQ0SkAEBpfOUmDvo6OgJ5gKf7TjJXUlv+wRz2ZfseIc1leJHUCJQ9i IStzR2T3s4wvhByBIQ4RLyjBkydiJL+IARukKYRV6bwqRz/TimyJJYf5VR1lNlO6d2pz Rw3pSJaVXbu+PcTfTT251E/ks7suYakFWTshnqvzEERL7KYi7LgTj70cqgWiM/Np27et rT3A== X-Gm-Message-State: AOAM531X/XB2Mn+raWlX446peGaroOP+NOowxqLNiBTIRZIIYWt7Etp4 WP6z28ZJz5gfAugo4q3HfPfmpg== X-Google-Smtp-Source: ABdhPJzzPvak6IZs9Er3fOpe/vBYnXweqCWn6tBN6i0rHLcG33/VrRmNNZ/5UwCZQSAWIuLg+0ow5A== X-Received: by 2002:a63:5d19:: with SMTP id r25mr14647985pgb.317.1621882279927; Mon, 24 May 2021 11:51:19 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id w197sm11402472pfc.5.2021.05.24.11.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 11:51:19 -0700 (PDT) Date: Mon, 24 May 2021 18:51:15 +0000 From: Sean Christopherson 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 , Jarkko Sakkinen 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> Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=dXgwIRb5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of seanjc@google.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=seanjc@google.com X-Stat-Signature: of167g4j693e8dxbm46p8r8z4ehne546 X-Rspamd-Queue-Id: CF1BBA0001DD X-Rspamd-Server: rspam02 X-HE-Tag: 1621882277-266395 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 01, 2021, 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. ^ |- indirect After reading the changelog, I was expecting ENDBR on every label. > Signed-off-by: Yu-cheng Yu > Cc: Andy Lutomirski > Cc: Borislav Petkov > Cc: Dave Hansen > Cc: Jarkko Sakkinen > Cc: Peter Zijlstra > --- > 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 It would be better to move this below the comment about EEXIT. As is, it looks like a misplaced annotation on the AEP. The AEP doesn't need ENDBR, it's the EEXIT target that needs ENDBR because EEXIT is treated as an indirect branch. Might also be helpful for future readers to explicitly state in the changelog that EEXIT is considered an indirect branch. I.e. > /* EEXIT jumps here unless the enclave is doing something fancy. */ ENDBR > 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 >