Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1691188pxb; Fri, 20 Aug 2021 11:26:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLQTdnxq2IdSbo4Q2Wx2t7E60E0bXdZ8CHjEL0doSIbTc1qL91Jv92xfN4l+OCrUTiSPfO X-Received: by 2002:a05:6602:3293:: with SMTP id d19mr902342ioz.158.1629483997543; Fri, 20 Aug 2021 11:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629483997; cv=none; d=google.com; s=arc-20160816; b=gsLXSrXZtkf21K7x8swIGAPVKz4+iujZdC7m+Oq/y6oePAtGVoJz+X0E79vglTkjog NPm0NXLhH03kF4NaDlZRKT8OBFPVOjhDtLsFf1n8X64B61VsumYyoEjVQAjaneqRiUE/ HGh5FOiFeCyrzgWXrKSHyy9p44spa9RgCqW6+FIaKHGLlHGtdJ165f+fxXwZbwtfD6Th WImIZgxSkN42mgh3i1LU0mReJHYMgB/RETiI6GjSbYvt7M3Ez8s5jqNaYdFL9bOlG+Az AM4Wta0I11KwGOEeSFjfd3poSfzQHva71GXq+9xueaW5qwjzh7BBT+p6hn+8dtYrOBjR 0xqg== 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=SiiREc7TIXwCQ9HPvqyjQIl2ykZ/N/a1lepLZDyyO6Y=; b=oT/TtxPB3JgMhZh+HQ5QpwDMT5ux1KdWE9HwXTorHBTx8GlR3exK9y+2leNZGYyuCc aWyfSvd4fY4E9+AK+5seFBv1FLV7T5t4+3ci/dGNwfHGsOTdjMOnVnc1mzfc9ZoWi+NA bx7Q6tJqcCmjx4Fin8yqpoPFDZmvg2yG//qHwlOmWMZ040958xDPp4w8DqmpTygqO18c Kf00vPWMV+jv35E4Y7xJJ5KEUloLzBLg6WQG/z3IpQIKy4apuRGtgrvVASz12ujRSfz8 a7rG3FPDg8voTJ76nEcMzC+blM/b81/BQxM1T7DbFIVVTn2fRhPnzVNYav5R6nhenBnS tLDw== 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 f14si8829727jat.94.2021.08.20.11.26.26; Fri, 20 Aug 2021 11:26:37 -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 S238332AbhHTSYx (ORCPT + 99 others); Fri, 20 Aug 2021 14:24:53 -0400 Received: from mga18.intel.com ([134.134.136.126]:48116 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238979AbhHTSYX (ORCPT ); Fri, 20 Aug 2021 14:24:23 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10082"; a="203964964" X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="203964964" 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:09 -0700 X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="523799176" 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 08/10] x86/vdso: Introduce ENDBR macro Date: Fri, 20 Aug 2021 11:22:43 -0700 Message-Id: <20210820182245.1188-9-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. Introduce ENDBR64/ENDBR32 macros. 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 --- arch/x86/include/asm/vdso.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h index 98aa103eb4ab..97358246e4c7 100644 --- a/arch/x86/include/asm/vdso.h +++ b/arch/x86/include/asm/vdso.h @@ -52,6 +52,24 @@ extern int map_vdso_once(const struct vdso_image *image, unsigned long addr); extern bool fixup_vdso_exception(struct pt_regs *regs, int trapnr, unsigned long error_code, unsigned long fault_addr); -#endif /* __ASSEMBLER__ */ +#else /* __ASSEMBLER__ */ + +/* + * ENDBR is an instruction for the Indirect Branch Tracking (IBT) component + * of CET. IBT prevents attacks by ensuring that (most) indirect branches + * 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. + */ +#ifdef CONFIG_X86_IBT +#define ENDBR64 endbr64 +#define ENDBR32 endbr32 +#else +#define ENDBR64 +#define ENDBR32 +#endif +#endif /* __ASSEMBLER__ */ #endif /* _ASM_X86_VDSO_H */ -- 2.21.0