Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1691316pxb; Fri, 20 Aug 2021 11:26:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHoqThJnokcEnc1kDa6DOSOYBpa4yg/QpbC4CeEdm4HX3fJSYgYeKWyQBZ8XWknS3srzbm X-Received: by 2002:a92:cb52:: with SMTP id f18mr15263907ilq.120.1629484008836; Fri, 20 Aug 2021 11:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629484008; cv=none; d=google.com; s=arc-20160816; b=NxGC/WCi9ZMjG+y4XoO7Qp8Ypf8A7qyfIMxt195alSFWzlebe/Y3Ns8N1JsRenuJub E2L1OU+/8zFrjYN1Y96BeiRWbzw9aSDapyTZtXLe69Kb+6ez6te3/gEVL1+NUSa8x7dU 9cmjDjlcBldI5IsISSGMyKu0RtJi1+19HwDxAFe78vRNkDFHCLseTO39uK2L0o/CVMQq 4n6FhKPuZ0AhXe2BqNGq6rk/n9yerzoyvp1WvfxaW8H5zERn6csXrQjizq1TaHWgIFQ4 J1fEHZysWgu53V1hAcbmps7a3/Rlp/hByZ1JCsjCPcGFdozy+az9Tu5YSU1MnfEhSwTR N6NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=STfMNUvPA3o40IiFB0RPdJCkC/iW6RA149wcukceFvo=; b=DP2AXrNhPIzsgiBheMZVW96/8dhauojCBj7UMmZsqioYwvOrPPfXtAuKS2kurorK0y v7xEWpA4GpgXr1FonDutmHbrsPQqMPuP1XHNEP6YORn7KNUonxqmPj3BI/IeBj0MZhNs mO6t9xkUbTyD00NUnP94ApG80pQ6HUCneo3KjuD224Pz3sJQdadBf1xXO0m2Wl8mD18N JgV9/5VZHKRunbNpAUYR/jWGLf7qvVNI6lNRW83QwetkdjN9AlFLM4RGg6yNPeI8KkTy kGnw+eYhF4AypzmHOrdf6PN2Xa3itK4rfIJcpVVnxLdQbopDVNt20DwZxFm2LQLsM7sZ mOfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si7100660ila.149.2021.08.20.11.26.37; Fri, 20 Aug 2021 11:26:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238590AbhHTSZF (ORCPT + 99 others); Fri, 20 Aug 2021 14:25:05 -0400 Received: from mga18.intel.com ([134.134.136.126]:48046 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238037AbhHTSYm (ORCPT ); Fri, 20 Aug 2021 14:24:42 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10082"; a="203964971" X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="203964971" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 11:23:10 -0700 X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="523799184" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 11:23:09 -0700 From: Yu-cheng Yu To: 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" , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , Rick P Edgecombe Cc: Yu-cheng Yu , Jarkko Sakkinen Subject: [PATCH v29 10/10] x86/vdso: Add ENDBR to __vdso_sgx_enter_enclave Date: Fri, 20 Aug 2021 11:22:45 -0700 Message-Id: <20210820182245.1188-11-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210820182245.1188-1-yu-cheng.yu@intel.com> References: <20210820182245.1188-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() indirect branch targets, including EEXIT, which is considered an indirect branch. Signed-off-by: Yu-cheng Yu Reviewed-by: Kees Cook Acked-by: Jarkko Sakkinen Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Peter Zijlstra --- v28: - Move ENDBR64 below EEXIT comment (no functional change). - Update change log, state EEXIT is considered an indirect branch. --- 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..d65a7f9dea8b 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 @@ -64,6 +66,7 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) enclu /* EEXIT jumps here unless the enclave is doing something fancy. */ + ENDBR64 mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx /* Set exit_reason. */ @@ -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