Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp96765imm; Tue, 9 Oct 2018 14:29:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV63p8d3tzsyErDe1H4KPP3Mkzkso+u8+ekLiYn7x3PXGi1xG5FCp5fF7XNjJb5LxsRZZxbnG X-Received: by 2002:a63:b04f:: with SMTP id z15-v6mr25561954pgo.442.1539120575808; Tue, 09 Oct 2018 14:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539120575; cv=none; d=google.com; s=arc-20160816; b=HGrYLT7SL2CmBgRUDnA3vkd1dXwzL1UQBkYdBaqdKLl24fTWU7chwayM7tun9BEXkZ IgAMPhu+p79G2aCAfExNbHc/At3pX/ePsu4SZlRuoGxvxS3l3IWR4qIT+NE7nm+EA07N vAna1/iOj6mViWMVJ5WZkgjX71hGzoZ6SrdfTshc4rDaA4S1TAqTcgPtBuQM10rSbRWI 5tj6Iw6OhPKAVR0JnmwBRLDQppG9z3KAxGQq0vYljefUxOgPuvIzztuq8lYTKyIglr70 QU+JW67I2HWJlnVmKw64YQjjlrYY3lgYDZ+mVk8shBH56aS9jzr9tlBMGCLsThf92eq0 3veQ== 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=GJ7QD1QeKCWLDfexfepeFjm5xBSjrHtD3o1aODpXA3Q=; b=oCG8EtSnLBLHM8QF/U5Kyut7eY4CL6DjmKLB90rIwCvu+oX8uqWM/0RambGHjgRCxE 6Ze2D6bE4mQxHWJzdzQXLB2Pi+AmzlAuksPz+7NLWRcGt7TWqL6CRbJBXT1Kc+CkpOZ/ tM9MYMEeESvMgS5yRRE7Gyake8NlgQFQdg+RQS1bsTq47PZtT7bkCI+a2d4XTbIWZfI+ NqjkdHyQV2tBfe0fabo1Gmb7aaLrES/mTVTmNyOPvlOl3QVVZ8xIIkcuTxD63G8wuJv8 P6+RBlfaTOs0iPNcbOezYal2Z7OtKnGmXmW+P9INCFRoyfqRv4XGtOpNs2JM+WphEmZ5 JJKg== 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 p17-v6si19994903pgj.416.2018.10.09.14.28.50; Tue, 09 Oct 2018 14:29:35 -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 S1727873AbeJJEjB (ORCPT + 99 others); Wed, 10 Oct 2018 00:39:01 -0400 Received: from mga04.intel.com ([192.55.52.120]:54055 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726523AbeJJEjB (ORCPT ); Wed, 10 Oct 2018 00:39:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Oct 2018 14:20:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,361,1534834800"; d="scan'208";a="81242652" Received: from 2b52.sc.intel.com ([143.183.136.51]) by orsmga006.jf.intel.com with ESMTP; 09 Oct 2018 14:20:04 -0700 Message-ID: <38064485f5255aa999700d87debecbd6c7e084ba.camel@intel.com> Subject: Re: [RFC PATCH v4 21/27] x86/cet/shstk: ELF header parsing of Shadow Stack From: Yu-cheng Yu To: Eugene Syromiatnikov 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 , Cyrill Gorcunov , Dave Hansen , 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: Tue, 09 Oct 2018 14:15:14 -0700 In-Reply-To: <20181003232736.GI32759@asgard.redhat.com> References: <20180921150351.20898-1-yu-cheng.yu@intel.com> <20180921150351.20898-22-yu-cheng.yu@intel.com> <20181003232736.GI32759@asgard.redhat.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 Thu, 2018-10-04 at 01:27 +0200, Eugene Syromiatnikov wrote: > On Fri, Sep 21, 2018 at 08:03:45AM -0700, Yu-cheng Yu wrote: [...] > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > > index 0d157d2a1e2a..5b5f169c5c07 100644 > > --- a/arch/x86/include/asm/elf.h > > +++ b/arch/x86/include/asm/elf.h > > @@ -382,4 +382,9 @@ struct va_alignment { > > > > extern struct va_alignment va_align; > > extern unsigned long align_vdso_addr(unsigned long); > > + > > +#ifdef CONFIG_ARCH_HAS_PROGRAM_PROPERTIES > > +extern int arch_setup_features(void *ehdr, void *phdr, struct file *file, > > + bool interp); > > +#endif > > #endif /* _ASM_X86_ELF_H */ > > diff --git a/arch/x86/include/uapi/asm/elf_property.h > > b/arch/x86/include/uapi/asm/elf_property.h > > new file mode 100644 > > index 000000000000..af361207718c > > --- /dev/null > > +++ b/arch/x86/include/uapi/asm/elf_property.h > > @@ -0,0 +1,15 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +#ifndef _UAPI_ASM_X86_ELF_PROPERTY_H > > +#define _UAPI_ASM_X86_ELF_PROPERTY_H > > + > > +/* > > + * pr_type > > + */ > > +#define GNU_PROPERTY_X86_FEATURE_1_AND (0xc0000002) > > + > > +/* > > + * Bits for GNU_PROPERTY_X86_FEATURE_1_AND > > + */ > > +#define GNU_PROPERTY_X86_FEATURE_1_SHSTK (0x00000002) > > Hm, these defeinitions aren't much different comparing to NT_* > definitions in include/uapi/linux/elf.h, is it expected that those > properties have to be parsed individually for each architecture? Yes, we have NT_GNU_PROPERTY_TYPE_0 defined in include/uapi/linux/elf.h. GNU_PROPERTY_X86_FEATURE_1_xxxx is for X86 only. [...] > > There's a lot of similar code with bpf stackmap .build-id code (commit > v4.17-rc1~148^2~156^2~3^2~1), it might be worthy generalising some ELF > traversal routines, since there's general need of parsing ELF property > segments. Only a small similarity exists. The routine find_note_type_0() does a lot more validation. It appears stack_map_get_build_id() does not need that. Yu-cheng