Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3404815ybi; Mon, 10 Jun 2019 09:41:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyizjjW8Gmp8pmXI0Uag7fdX1gt2m13d5inHSRIZ9BmT3lYQNH8bYlBb0e8sPAHGUGu9ktd X-Received: by 2002:a17:902:bb90:: with SMTP id m16mr5027655pls.54.1560184872694; Mon, 10 Jun 2019 09:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560184872; cv=none; d=google.com; s=arc-20160816; b=wvOVM3iQnH7B3fLz+mrsP5R6xlreylX1/dXigJrlLUfCNFhRUXg2zOrfBVeL/juuHw 0y37mp2Gfi5PF8WJQuw6n1XsBc51d9OX//z35UFYX0OYIsQL5Wbc84p2AdPeZzoayy8e ZtBvQkt1yssGvygui+rKDla6aaxTMcGNVvBL9ys4oxZieWBj26s8WvOCVdrSEoclUpA5 PoQEoCuovEpir7FnIDyshhctMf2aSsqk0IwR3nN5wfgZattRxVRQt2M+NsV7jyABkXTc FC0S5CI2U62OXkUyN/PYy5X9srzhYQLm2y5hVavLfLd70bSPSkixp7l6O3VuYmxF60LK dDoA== 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:date:cc:to:from:subject:message-id; bh=lYaG9zCQ8qUR/NZZG6yx3c/iv2W/XOEvUKjl2KtFrZc=; b=RX4TrLonEMcKglJIhREEDNpQa9E4CM1Awx6h8rJllP3gkSevQwNf6uP493U1aTQydv ljjpNywbiCJL5hJTlNIrRzKNVlzv3LaVOB3Pr5lwlhVjqFjj1fXePQMLvPEkwEwjCVa7 NPYI1b9wbVcZdxG9svrV/rRjR7W81dJrSPRHF4e2nGf+qqz2/VNA8MzMq2wGbmW1l2PB mMv/ENHKRQl3b5lgLHUfNNXhRwleVFAW8RGDeBM45a48+CXREuDv15wXKaeI+qxvFInS Q45nGiCzUwdK2GYsoK33qYnetUzNtZoBPfn+HC4yfi68yWKmGhyplD8Ee3pFpZij1xOx /Khg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z34si5166639pgl.240.2019.06.10.09.40.57; Mon, 10 Jun 2019 09:41:12 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387448AbfFJQhM (ORCPT + 99 others); Mon, 10 Jun 2019 12:37:12 -0400 Received: from mga07.intel.com ([134.134.136.100]:7055 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387407AbfFJQhM (ORCPT ); Mon, 10 Jun 2019 12:37:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jun 2019 09:37:11 -0700 X-ExtLoop1: 1 Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by fmsmga007.fm.intel.com with ESMTP; 10 Jun 2019 09:37:10 -0700 Message-ID: <94b9c55b3b874825fda485af40ab2a6bc3dad171.camel@intel.com> Subject: Re: [PATCH v7 22/27] binfmt_elf: Extract .note.gnu.property from an ELF file From: Yu-cheng Yu To: Dave Martin 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 Date: Mon, 10 Jun 2019 09:29:04 -0700 In-Reply-To: <20190607180115.GJ28398@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> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Yu-cheng