Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp849783pxv; Thu, 22 Jul 2021 13:59:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoaMGCD0h1GAJgV5NTWF6I1XSGxhs4rnnp1YtOLE7vLWPD/wtiw/BKtieRw8pGexo6pn+v X-Received: by 2002:a92:dc4f:: with SMTP id x15mr1201781ilq.64.1626987574105; Thu, 22 Jul 2021 13:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626987574; cv=none; d=google.com; s=arc-20160816; b=c5FMqDx2N78sg/LIN8EoOplcIXBbjafLrGw4x5lp7Oe+ABP4xwH/VGytnUe4tzJr7/ solYiZuSuxe5qRu4WmoDmjVtYrNshysEGmPILTmpp6snmW7l4GY+ikWL0iaydQECrQ6T RmbzzZ2xggJWaV8xr0sGB6y938lPlH1Z56sy4RdSTpq04vH7Q9TaZWiJE9ggu3skCnuW ZFy6hoXm2A5m49sBgyL/7vqoXVi5fR8RCzKPC5SGMm0f28pBjBAfCOB3epPSiUo2GGqn 0DgpJWmr8Ak8es+lvOxkxQKD5L7hRYNB/Gymert4cHV6vl43UqQ6H0iicJWpOLM1SLRw HQaQ== 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=ILANh/5SGjXjWUCe4GcW7SqjwLuA8slUFLHIpwT0PT1mFiMHoaFrXI/csMRqalmEml jxK/df7NFqzqPekHbI6+9irjUtd9CIsTYxkNiezEdni3MBJp6ukMKRyx4/6B/mnVvWuN ADAQTAPqzbi3jcjoGBO6eKWB+qdYqJbaLCFisS1L2PkH+0KHFyND0C4uERq6s5vtKOa9 1uPq0N8KOYlMFPDRR1+RAWxUCxyYGegq4i9Rlea62Me5fAyJIi3NnbaxVuR5EmCJMW39 o7+X+dw+b75U7pjgoVaTKv6F4g4/CACGSujkxl9auv000vTzSxkLXRWdsI9H4WWuPT5r gYWg== 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 x19si29571730ioa.74.2021.07.22.13.59.22; Thu, 22 Jul 2021 13:59:34 -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 S231719AbhGVURw (ORCPT + 99 others); Thu, 22 Jul 2021 16:17:52 -0400 Received: from mga07.intel.com ([134.134.136.100]:54784 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231368AbhGVURb (ORCPT ); Thu, 22 Jul 2021 16:17:31 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10053"; a="275561720" X-IronPort-AV: E=Sophos;i="5.84,262,1620716400"; d="scan'208";a="275561720" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2021 13:58:05 -0700 X-IronPort-AV: E=Sophos;i="5.84,262,1620716400"; d="scan'208";a="433273382" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2021 13:58:05 -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 v28 08/10] x86/vdso: Introduce ENDBR macro Date: Thu, 22 Jul 2021 13:57:21 -0700 Message-Id: <20210722205723.9476-9-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210722205723.9476-1-yu-cheng.yu@intel.com> References: <20210722205723.9476-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