Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1109303ybz; Wed, 29 Apr 2020 15:14:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKBDRiY9SzL3o352n2TlUUYypyQHwntB4GA+vT0dh6u4Bz3teO/SA+3pKMHWLCu6XsU7Of7 X-Received: by 2002:aa7:c2d2:: with SMTP id m18mr151670edp.142.1588198440488; Wed, 29 Apr 2020 15:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588198440; cv=none; d=google.com; s=arc-20160816; b=TyXTF6fUZgvsVmt7bUk2L2D5Kw15VK1jwAjtJI40/nurwv2d8okWdpkTL/NFJGV9er 7R2EoJN/4x2XiQHPWp3DE7odKfoZ+0aCPYNryv7Nue9sbOF720j2+CswfC5DN05sO7VX wiGKw1/kZLYNiflEpSr1zP3hUanxN5djV2qJpt6SyW9FyEin0i6i8hbcAsFxgRGPSXVw sxkUs8ofwjMYEEkRALfmGszKZ4B+qQnCLUoO/tj7QY0KOQ1sDc/uGNrzf/w9FNfglg73 +RPkB8kQ6RPr09uPF12GIHAamy8PgmRmn+jTjYGths/5xAZIFTqUNNlu4VmGTkQKrDCl fEsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=8MSRhYAxGety5rAA1YxCgMfJIW1aEVpTCuFJ18YmbwQ=; b=vCkWPFedGCHFXr6CN3N1MopPy3P5OMWkVe5CAFlEIp713L0+G8tkHyfPhSmMu0JJ30 N0FWCLSrMFaA/tS9d6rYHezwhuvJSe2gG8nW9yThPDjD3byj9HGXF1+Kv+pIN4QEdnDL 8DgxLGoc2aUENz99kf/tLJsLz/iccO0NFht2sQ5K7SQMN/or1cGQ9Ks8ZOwmTBoq134+ x0mpW1ZCIoTYCWszgZaUH85+QGkkwOESt7DRtwOYTLo1GZtfkllIMwfku9fairep+cXZ QKDNu5fibW7jRnqqikvLxs05bNx4WD+AS7TW+E0GasQrwgfVrNHPTrS29WlTecWEmLi1 W47Q== 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 a88si4393455edf.379.2020.04.29.15.13.37; Wed, 29 Apr 2020 15:14:00 -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 S1728253AbgD2WJn (ORCPT + 99 others); Wed, 29 Apr 2020 18:09:43 -0400 Received: from mga09.intel.com ([134.134.136.24]:61308 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728002AbgD2WIy (ORCPT ); Wed, 29 Apr 2020 18:08:54 -0400 IronPort-SDR: 7LMEilFc7N3MJlzvYRlxkmlMSUpbYg6OJQSrao9pFIh19RupZV78JH3YKSKADpjHxClEkOXMDk tSThxShim+TA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2020 15:08:52 -0700 IronPort-SDR: 01B1B+noaRsFveAQnMg10Y5g4MAwi82ZZk/eGTjNIOD3XoDpF8cH9PYXbRRz8Wy8Bsqcxnd9PZ JT0uo80Cd19w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,333,1583222400"; d="scan'208";a="276308927" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga002.jf.intel.com with ESMTP; 29 Apr 2020 15:08:51 -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 Cc: Yu-cheng Yu Subject: [PATCH v10 21/26] ELF: UAPI and Kconfig additions for ELF program properties Date: Wed, 29 Apr 2020 15:07:27 -0700 Message-Id: <20200429220732.31602-22-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200429220732.31602-1-yu-cheng.yu@intel.com> References: <20200429220732.31602-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce basic ELF definitions relating to the NT_GNU_PROPERTY_TYPE_0 note. Signed-off-by: Yu-cheng Yu Reviewed-by: Kees Cook --- v10: - Merge GNU_PROPERTY_X86_FEATURE_1_* from a separate patch. fs/Kconfig.binfmt | 3 +++ include/linux/elf.h | 8 ++++++++ include/uapi/linux/elf.h | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 62dc4f577ba1..d2cfe0729a73 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -36,6 +36,9 @@ config COMPAT_BINFMT_ELF config ARCH_BINFMT_ELF_STATE bool +config ARCH_USE_GNU_PROPERTY + bool + config BINFMT_ELF_FDPIC bool "Kernel support for FDPIC ELF binaries" default y if !BINFMT_ELF diff --git a/include/linux/elf.h b/include/linux/elf.h index e3649b3e970e..459cddcceaac 100644 --- a/include/linux/elf.h +++ b/include/linux/elf.h @@ -2,6 +2,7 @@ #ifndef _LINUX_ELF_H #define _LINUX_ELF_H +#include #include #include @@ -56,4 +57,11 @@ static inline int elf_coredump_extra_notes_write(struct coredump_params *cprm) { extern int elf_coredump_extra_notes_size(void); extern int elf_coredump_extra_notes_write(struct coredump_params *cprm); #endif + +/* NT_GNU_PROPERTY_TYPE_0 header */ +struct gnu_property { + u32 pr_type; + u32 pr_datasz; +}; + #endif /* _LINUX_ELF_H */ diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index 34c02e4290fe..61251ecabdd7 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -36,6 +36,7 @@ typedef __s64 Elf64_Sxword; #define PT_LOPROC 0x70000000 #define PT_HIPROC 0x7fffffff #define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_PROPERTY 0x6474e553 #define PT_GNU_STACK (PT_LOOS + 0x474e551) @@ -443,4 +444,11 @@ typedef struct elf64_note { Elf64_Word n_type; /* Content type */ } Elf64_Nhdr; +/* .note.gnu.property types */ +#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002 + +/* Bits of GNU_PROPERTY_X86_FEATURE_1_AND */ +#define GNU_PROPERTY_X86_FEATURE_1_IBT 0x00000001 +#define GNU_PROPERTY_X86_FEATURE_1_SHSTK 0x00000002 + #endif /* _UAPI_LINUX_ELF_H */ -- 2.21.0