Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4833733pxy; Tue, 27 Apr 2021 13:49:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy98qMhbfgIT5Yl9FRj8ORmjhaWuAY26avi8V8cGNBgBbLwwKUA0gz2vZ+vAr3GvGflu/ZH X-Received: by 2002:a05:6402:1a47:: with SMTP id bf7mr6746703edb.173.1619556594545; Tue, 27 Apr 2021 13:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619556594; cv=none; d=google.com; s=arc-20160816; b=rYP1oR+g7pRx3Sfu3pIo9vNal/2c0hBHmXbMlTGwlz4Yh0zY8cEhXN+6qMnc8iVvR0 VdsnFIGPU4IXWBtsXhBq/xc6VZTXBK55rfZvp0jgnt/be4affRDWaz/fanbFNs+3bwtg fQc5AdieC6FslG2kspBlZUtLpJ7rs+i6+oj0JyS/DBybblZwd6MfOOaKPc/422K5ZJT+ gnaUjC0cdm7+APOgSbQalPO2PNbzinPkTfYgBDC0DvrdaBK2MYKGvTpHjRXp8iQPjbDz 4OMntq60h6zX5L/6T1X/VYZIkmxlAviZ/Ag+kbb54z7ebp/g7t9G3RF7ZAVZsXT32/WI 3qdQ== 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 :ironport-sdr:ironport-sdr; bh=MRJZ93103Z8lsHqhjzP4zUwJhinfMoAITom6Yh7lPdE=; b=VwpxUi5CIOontoPwpqXPbC0EMXvasc+B2rSszkYDjsLiuL8hYbO1CD14KlxzPsOeRe 42QXR41cByt5HrNkk+crkZGcmtqN1jcW0KLvYD3iLqfgjKtD0DsvfU+72+aNU18IEEUm NQ5XrKnyww80BOU9nYmQVs+TYEV5gB62V00g5hqOtjz8T+Zc6LVowRTvqLYLC+VOPuPH z3q/VLXKHeztAySQcX/APutADIEpKBfEBZ4hTKzjd8qTehbtmUDaFQeo475XygkLpry9 mS+VJtsViTGoxVKPROXdAKa0uSHXK6otFrJCQANYMmqZPz9gajo5fiulJEYBxfnR749i lpUA== 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 k14si3346310eds.577.2021.04.27.13.49.31; Tue, 27 Apr 2021 13:49:54 -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 S239263AbhD0UtG (ORCPT + 99 others); Tue, 27 Apr 2021 16:49:06 -0400 Received: from mga09.intel.com ([134.134.136.24]:56332 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238905AbhD0Usy (ORCPT ); Tue, 27 Apr 2021 16:48:54 -0400 IronPort-SDR: qrHD+RE+DRSMklvCHzKqg/r7ELFtZ2kSPT06UPd1Yx0bBnomtnzRIJjEizil9dmgf7WG1dw4M5 NbihUXW8WFmg== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="196699395" X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="196699395" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:47:48 -0700 IronPort-SDR: f9inyIWS4gdZNzCtHUkX3aKAiva8vNIjb2Agxbkgs5rvZKph/uQp35BbsuI/yGTappcjSSPtYj 0kLYOjdstLng== X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="457835096" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:47:47 -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" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang Cc: Yu-cheng Yu , Jarkko Sakkinen Subject: [PATCH v26 7/9] x86/vdso: Introduce ENDBR macro Date: Tue, 27 Apr 2021 13:47:18 -0700 Message-Id: <20210427204720.25007-8-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210427204720.25007-1-yu-cheng.yu@intel.com> References: <20210427204720.25007-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 Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Jarkko Sakkinen Cc: Peter Zijlstra --- v25: - Change from using the compiler's cet.h back to just ENDBR64/ENDBR32, since the information is already known, and keep it simple. 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