Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3835589ybl; Tue, 20 Aug 2019 03:03:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNx2Y0BzweY9HimDjokvHT9wlKXNKakXPnFgwY6nRnb5hYebUR4XDeBRN+j+dTEI/68O32 X-Received: by 2002:a62:8281:: with SMTP id w123mr28786088pfd.36.1566295406625; Tue, 20 Aug 2019 03:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566295406; cv=none; d=google.com; s=arc-20160816; b=gIUlqvI2aWvdosoaaHuvKMXasErFIwZNVOMTSEYskN7tF2Hq7wa98JNa3QMoqegvml MiSuoQ7/5M3iA2mijN4clnpYJn+mSuJi5kIkRQs95JdR01ctK4Q6SpGww/mOlS9Y6x2O sDT8Gpmv+JgfFYQ3kBeqKDVlZ8IDv8yM1QL/9slyeau0kSaaaJvFafA8jNC+QLWyS/Fu Pr/d6vJlw0C2WTKDxqlGV1m+Lwn9ImdYXp7NK3eAUP1/vXOf1hN+40A2B06+PlNaORfm Pd5wfUQ7QLsBygp3egIs95TVvvdjE6UxTDjqta4dUQptZ+M2mNoHwd6h1BN6B3RLJwV4 y9gg== 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=gcJnUm4N2lfj+jhxJhMGx3Qla2MgIVPtKLFi+9pR3tI=; b=oX2RMs5xCa/skwhyKNLtGE8ic4p5XUwZ2tK1TgdiKZ8aUoYHZsD7wUIwW4b+13xakd sxAJg7tlcLJntHNlMELSYE11efDi6iAh4za/I5KRcCr/53Ks8cexXccnYwqJz+dzOgto /isivmB/85XXUjoDUrvBBoqrSkau3AS8TK0b+B7R/oieaRq/e2noDz9mZrWNjbODf+44 gDbHvYEkolRmkRBHjyMYOkEUX6hnR+hATApok9VpDcCvzC+49Leo9lBFxOQwhoi7mR9M uxULtYBU3Gpc6Dsbkp4AKYYdckN8uhHUr+t0gRHN6IaTVzk1wXj6nHZs5Kung+O95HrU HcKg== 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 gn12si11683462plb.321.2019.08.20.03.03.11; Tue, 20 Aug 2019 03:03:26 -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 S1729742AbfHTKCR (ORCPT + 99 others); Tue, 20 Aug 2019 06:02:17 -0400 Received: from foss.arm.com ([217.140.110.172]:37940 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729452AbfHTKCQ (ORCPT ); Tue, 20 Aug 2019 06:02:16 -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 E6723344; Tue, 20 Aug 2019 03:02:15 -0700 (PDT) Received: from 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 5C5113F706; Tue, 20 Aug 2019 03:02:12 -0700 (PDT) Date: Tue, 20 Aug 2019 11:02:10 +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 v8 22/27] binfmt_elf: Extract .note.gnu.property from an ELF file Message-ID: <20190820100208.GO10425@arm.com> References: <20190813205225.12032-1-yu-cheng.yu@intel.com> <20190813205225.12032-23-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190813205225.12032-23-yu-cheng.yu@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 Tue, Aug 13, 2019 at 01:52:20PM -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 specific > arch_parse_property() and 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); > ... > } > > This patch is derived from code provided by H.J. Lu . > > Signed-off-by: Yu-cheng Yu [...] For the hell of it, I tried implementing an alternate version [1] that tries to integrate into the existing ELF loader more directly. This may or may not be a better approach, but tries to solve some issues such as not repeatedly reading and parsing the properties. Cheers ---Dave [1] [RFC PATCH 0/2] ELF: Alternate program property parser https://lore.kernel.org/lkml/1566295063-7387-1-git-send-email-Dave.Martin@arm.com/