Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3420499ybi; Mon, 10 Jun 2019 09:59:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwDPhEcp8eCiCoRpfWnzSAZoHL86+DKn8UXLQbXmwZY9WD0g1ZfggazNnv0H4KetGKa3l+ X-Received: by 2002:a63:1f11:: with SMTP id f17mr16651117pgf.311.1560185939952; Mon, 10 Jun 2019 09:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560185939; cv=none; d=google.com; s=arc-20160816; b=PpNdstOIFEJ+XpBIuwkvmpo5IMNJreKPbhF2nuBf93b4ifYDzKek3WM6G5IbNQY7RK 7qLef0le3EFBOdJg6+HXNsDIXTDmAVGd7gkXqmC9zQ/UAnD9aH9AV3R/5rHP7madyELO Ksqs2I/u/J/x5MbbuT8eBnulZkvkVuTvI/q7F1hdcu6mBTbTTUb1aYFTuRH69VagLmZ8 H+PiWJxp9aKQ6W2Ox/dI2130DqowzHLopdO0SaGHRF2AEaei1FDC1UmfsBxtYt1AS6nn WZQXW121AzhKkFAW0ALBzTZPgScC+FI8QZaaCbokFF5sMsXfO1j2JMdTpw0zvFYgPdL+ CJmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=dqpGru3cDb67KYv0vCNiRWA48ZCMlc9F7dAnoJihJ2o=; b=Q6jCSGEmaQ/ukQ6R77vaQXU2VnW5wuXiBCYEVLosZi5/IPyPQTmqHQx+aa7MUdApP7 zllU+NErmp+rwyMCPCuhLpi4GCjEP7UktC/6TxzdhufX/U+mE4NrkHJ/xX12rAdUvwAc 7ZKanTPNUbfE1FWeh2vgMmFK3ZKYWfbRnPVi03Pfcw1Xziqdv9agTtsXv1nrh45ZbMGZ lU3FHLfO32Q/ZnWxa/zuhLJDOvIm/SyeTCOvJHZTuz0SJtYuxw/WKTf0zA3oTuAdex4Y Tiu2j0MYRIWeNHagCJM/zAI2oe8vEnKNsADjAkZoJuYU/+bPAoW7CT/yVhD+jvoIPCke 28Zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si9753024plk.272.2019.06.10.09.58.45; Mon, 10 Jun 2019 09:58:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387501AbfFJQ5i (ORCPT + 99 others); Mon, 10 Jun 2019 12:57:38 -0400 Received: from foss.arm.com ([217.140.110.172]:46232 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727648AbfFJQ5i (ORCPT ); Mon, 10 Jun 2019 12:57:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 027D7337; Mon, 10 Jun 2019 09:57:37 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B75A3F246; Mon, 10 Jun 2019 09:57:33 -0700 (PDT) Date: Mon, 10 Jun 2019 17:57:31 +0100 From: Dave Martin To: Yu-cheng Yu Cc: 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 Subject: Re: [PATCH v7 22/27] binfmt_elf: Extract .note.gnu.property from an ELF file Message-ID: <20190610165730.GM28398@e103592.cambridge.arm.com> References: <20190606200646.3951-1-yu-cheng.yu@intel.com> <20190606200646.3951-23-yu-cheng.yu@intel.com> <20190607180115.GJ28398@e103592.cambridge.arm.com> <94b9c55b3b874825fda485af40ab2a6bc3dad171.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <94b9c55b3b874825fda485af40ab2a6bc3dad171.camel@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2019 at 09:29:04AM -0700, Yu-cheng Yu wrote: > On Fri, 2019-06-07 at 19:01 +0100, Dave Martin wrote: > > On Thu, Jun 06, 2019 at 01:06:41PM -0700, Yu-cheng Yu wrote: > > > An ELF file's .note.gnu.property indicates features the executable file > > > can support. For example, the property GNU_PROPERTY_X86_FEATURE_1_AND > > > indicates the file supports GNU_PROPERTY_X86_FEATURE_1_IBT and/or > > > GNU_PROPERTY_X86_FEATURE_1_SHSTK. > > > > > > With this patch, if an arch needs to setup features from ELF properties, > > > it needs CONFIG_ARCH_USE_GNU_PROPERTY to be set, and a specific > > > arch_setup_property(). > > > > > > For example, for X86_64: > > > > > > int arch_setup_property(void *ehdr, void *phdr, struct file *f, bool inter) > > > { > > > int r; > > > uint32_t property; > > > > > > r = get_gnu_property(ehdr, phdr, f, GNU_PROPERTY_X86_FEATURE_1_AND, > > > &property); > > > ... > > > } > > > > Although this code works for the simple case, I have some concerns about > > some aspects of the implementation here. There appear to be some bounds > > checking / buffer overrun issues, and the code seems quite complex. > > > > Maybe this patch tries too hard to be compatible with toolchains that do > > silly things such as embedding huge notes in an executable, or mixing > > NT_GNU_PROPERTY_TYPE_0 in a single PT_NOTE with a load of junk not > > relevant to the loader. I wonder whether Linux can dictate what > > interpretation(s) of the ELF specs it is prepared to support, rather than > > trying to support absolutely anything. > > To me, looking at PT_GNU_PROPERTY and not trying to support anything is a > logical choice. And it breaks only a limited set of toolchains. > > I will simplify the parser and leave this patch as-is for anyone who wants to > back-port. Are there any objections or concerns? No objection from me ;) But I'm biased. Hopefully this change should allow substantial simplification. For one thing, PT_GNU_PROPERTY tells its file offset and size directly in its phdrs entry. That should save us a lot of effort on the kernel side. Cheers ---Dave