Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1106531ybz; Wed, 29 Apr 2020 15:11:09 -0700 (PDT) X-Google-Smtp-Source: APiQypKf+7F+6dU6m0UN30M4dGItPYED5+LKc2kY7LoJM/DJGpZpgG1xEpfs0mzBjrYoUDUy+Wn/ X-Received: by 2002:a17:906:3004:: with SMTP id 4mr4788781ejz.381.1588198269656; Wed, 29 Apr 2020 15:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588198269; cv=none; d=google.com; s=arc-20160816; b=ZXf75KpEzgAfibP7OiLR1mGYNm5dWTVoJCE2rKKx4qe/WQVtrrUkaFEuoZdqp3ns6F Us2RX++ziZ985A03fd/AH4LLmseWG3POKxCH/PZfEKVNcsIHE/lRls4TbTtZnOn+R3Wz nDeJ1ihjbhCx/OqMnPfYaiZrXMv8j8xSSWiCohA0+UyFt0Cb1hYH6mqXqnZhSFkmdM/b VV1IkcZ4sVFV7xo+eRKOl4+2f7dIc5xyIJznILFfTy0S7tZqVvD2ibGae+maIEez1dAF rR3LZc+ySDnCX/lV9F/YoFzFqXPNQkxuQY0kEdlZkXcjwtalSSd1LzBC/dwbUbKLdGtF fxcA== 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=8iHjv033clEY1T2LrI2LBm4Pf0uR15HSi1UkUI7WKAk=; b=w9JF4fWP20cVF/H9ZQlO7Zhigu3+No/PJykUNJ5cRi/jIuizZSxaP68T67PrMoLaPX 6UsKSuB1vP/YlopbhkPNOiy7L5CNjRIGYdlhKDZeN/OQM7Y1VdEpHOC3ZSYKkFgLcOip XuHhEz3VtcbOtJV1pfm0nY52cjCTi7dK7DQRsXqfFs/ALWL9Ih4Bnv6teWIUvyVk9d1a TDE2G73ebYh08AnBoat4jKgxX7lEXtqFNZCju/aDbWpv3w/ZWqiAsiLDpR2JQTQhsuHn 1KWSpeSf1ffaV+WvEtbZgU39N1UU+2tkonEuzGwzL+/pwqpzFa4Pziyik56ZnMCyfuJE MOKw== 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 nm1si4662119ejb.451.2020.04.29.15.10.45; Wed, 29 Apr 2020 15:11:09 -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 S1728122AbgD2WJE (ORCPT + 99 others); Wed, 29 Apr 2020 18:09:04 -0400 Received: from mga09.intel.com ([134.134.136.24]:61306 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728064AbgD2WI6 (ORCPT ); Wed, 29 Apr 2020 18:08:58 -0400 IronPort-SDR: 2H9FZd+1ngEaY+f7021506Brjb1PKuoD+VveXcaC74jBboFbxH98YMBln3ERDmMFdnSY0XMTcb nzLDnVHn7B1g== 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:54 -0700 IronPort-SDR: 9j1+4qYBMzc2L9aY/UoxwygXzrHMaOIyykJVoAXHFi+cdrMzPDzxCWL0mi7HlRCFpTh8Sy8fgb ZorXVBzA4izQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,333,1583222400"; d="scan'208";a="276308934" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga002.jf.intel.com with ESMTP; 29 Apr 2020 15:08:53 -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 23/26] ELF: Introduce arch_setup_elf_property() Date: Wed, 29 Apr 2020 15:07:29 -0700 Message-Id: <20200429220732.31602-24-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 An ELF file's .note.gnu.property indicates architecture features of the file. These features are extracted earlier and stored in the struct 'arch_elf_state'. Introduce arch_setup_elf_property() to setup and enable these features. The first use-case of this function is shadow stack. Signed-off-by: Yu-cheng Yu --- fs/binfmt_elf.c | 4 ++++ include/linux/elf.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 327a995ff743..d7a4c0a1245e 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1216,6 +1216,10 @@ static int load_elf_binary(struct linux_binprm *bprm) set_binfmt(&elf_format); + retval = arch_setup_elf_property(&arch_state); + if (retval < 0) + goto out; + #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES retval = arch_setup_additional_pages(bprm, !!interpreter); if (retval < 0) diff --git a/include/linux/elf.h b/include/linux/elf.h index 7bdc6da160c7..81f2161fa4a8 100644 --- a/include/linux/elf.h +++ b/include/linux/elf.h @@ -78,9 +78,15 @@ static inline int arch_parse_elf_property(u32 type, const void *data, { return 0; } + +static inline int arch_setup_elf_property(struct arch_elf_state *arch) +{ + return 0; +} #else extern int arch_parse_elf_property(u32 type, const void *data, size_t datasz, bool compat, struct arch_elf_state *arch); +extern int arch_setup_elf_property(struct arch_elf_state *arch); #endif #endif /* _LINUX_ELF_H */ -- 2.21.0