From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC04EC433ED for ; Thu, 29 Apr 2021 09:23:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71DCC61449 for ; Thu, 29 Apr 2021 09:23:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236492AbhD2JYm (ORCPT ); Thu, 29 Apr 2021 05:24:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230392AbhD2JYl (ORCPT ); Thu, 29 Apr 2021 05:24:41 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7494BC06138B for ; Thu, 29 Apr 2021 02:23:54 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id t4so15538116ejo.0 for ; Thu, 29 Apr 2021 02:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F8cREKu+7p2lFf21gsP7RTu5Zef9Sd3kayTqrQK/7ds=; b=Al1qjFvxRLGghYHIOI+isxnecFyTgSjOxpf7NwVHobrXlgIhwBEaKxIVbyllnEwoAp BoANU9NuXlpUbC9myklwu4LxrscJKNPBNDJpm1GQ+DbpC6v/LxXbhqD0NzGnj5hmjXmC RKubRD9+NjNWaGvyc4eU19c8mXnLwYKZPIMV4Dsi+/xGlY6Tv0zdvnoD/yAKhResXwD6 4vpgNIHik2Z3RJDQSmDwgcqSO7UBw5wIs469Veqmq6czAy0BaTs5lSUeVLFALzPszuty 0oyhGoFggGb7uCDn4674L8SXZRYQIphc9ont8/wpBMmDsW5ixiy1RdDwLoMrsR5An4KE b2GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F8cREKu+7p2lFf21gsP7RTu5Zef9Sd3kayTqrQK/7ds=; b=efLqY74o67y35KEeGxdmZZBROL77pbe3OPcIZbaRNjjjc7CgfoKzxnt9UMw/6S/p0h QdOc6BHjBRum++++yJPBwh0g/+RG1Eh1skfsDrY2P4FyT1e/v17uNxfKBuo5N9bNRr+z eRIzZwA3DBKHPHoMrMs3brPoAu0i9rzzMCBXKX8Ola9Dh+gyczSgauXD1ti4QJiLPgUX nPxuiCTG84l190WDyn2TADznTJLr8stN/j+ynGA3KgZ5MlK3hBZp/J3ejkdhX5HgbLEw ZdgCZaaufxhNFckqc0wtOt42XLvcIZNRs/GJNw9YtXMVVFQ+eXtHexYl5myvZ3UVG7mT 8LLw== X-Gm-Message-State: AOAM5316beGn5B3VAV1u252FNmG1fKWYOHDbL4vgs8p+hwRDGqZAIWr2 gxIMECGsRUCl5146W+TeX5ZVSC7AhOxJYo3Ukbmn X-Google-Smtp-Source: ABdhPJzmD5KIaSE76zux8n1Xthc6noF7GoYJOjt3oVwm/b5zsJgjfEFSjyl1HGJk8D9o50MGI6eo4N+rEp0rU6r5b60= X-Received: by 2002:a17:906:b7d3:: with SMTP id fy19mr12024625ejb.269.1619688232584; Thu, 29 Apr 2021 02:23:52 -0700 (PDT) MIME-Version: 1.0 References: <20210423205159.830854-1-morbo@google.com> <20210428172847.GC4022@arm.com> <20210428174010.GA4593@sirena.org.uk> <20210429075454.GQ9028@arm.com> In-Reply-To: <20210429075454.GQ9028@arm.com> From: Bill Wendling Date: Thu, 29 Apr 2021 02:23:41 -0700 Message-ID: Subject: Re: [PATCH] arm64/vdso: Discard .note.gnu.property sections in vDSO To: Szabolcs Nagy Cc: Mark Brown , Catalin Marinas , Kees Cook , Ard Biesheuvel , Will Deacon , LKML , linux-arm-kernel@lists.infradead.org, Daniel Kiss Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29, 2021 at 12:55 AM Szabolcs Nagy wrote: > The 04/28/2021 12:31, Bill Wendling wrote: > > On Wed, Apr 28, 2021 at 12:21 PM Bill Wendling wrote: > > > On Wed, Apr 28, 2021 at 10:40 AM Mark Brown wrote: > > > > On Wed, Apr 28, 2021 at 06:28:47PM +0100, Catalin Marinas wrote: > > > > > On Fri, Apr 23, 2021 at 01:51:59PM -0700, Bill Wendling wrote: > > > > > > > > > > Since the note.gnu.property section in the vDSO is not checked by the > > > > > > dynamic linker, discard the .note.gnu.property sections in the vDSO. > > > > > > > > > Can we not instead fix the linker script to preserve the > > > > > .note.gnu.property, correctly aligned? It doesn't take much space and > > > > > while we don't use it now, it has the BTI information about the binary. > > > > > > > > > Cc'ing a few others who were involved in the BTI support. > > > > > > > > Not just BTI, we also flag PAC usage in there too and could add other > > > > extensions going forwards. While the note isn't actively used by > > > > anything right now due to the kernel mapping the vDSO prior to userspace > > > > starting it is part of the ABI and something could end up wanting to use > > > > it and getting confused if it's not there. It would be much better to > > > > fix the alignment issue. > > > > > > If there's only one of the 8-byte aligned sections guaranteed, we > > > could place it first in the note. Otherwise, we will have to change > > > the alignment of the note (or somehow merge multiple notes). > > > > > I should have clarified that there's only one *entry* in the > > .note.gnu.properties section, and if not then is it possible to merge > > multiple entries into one. (Excuse my ignorance if this is already the > > case.) > > .note.gnu.property should go to PT_GNU_PROPERTY and it > should be merged following rules specified in > https://github.com/hjl-tools/linux-abi/wiki/Linux-Extensions-to-gABI > and > https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst#program-property > > it may also be covered by a (8byte aligned) PT_NOTE, but > that's not a requirement on aarch64 (x86 requires it for > compatibility with old dynamic linker, but since the vdso > is handled specially that may not be relevant either). > > i don't know how this works in linker scripts. This is a potential patch. I haven't had time to test it though. However, it does appear to format the section in the "expected" way, so one's able to grab the build IDs. Thoughts? $ objdump -s -j .note ./arch/arm64/kernel/vdso/vdso.so ./arch/arm64/kernel/vdso/vdso.so: file format elf64-little Contents of section .note: 0288 04000000 10000000 05000000 474e5500 ............GNU. 0298 000000c0 04000000 03000000 00000000 ................ 02a8 06000000 04000000 00000000 4c696e75 ............Linu 02b8 78000000 000a0500 06000000 01000000 x............... 02c8 00010000 4c696e75 78000000 00000000 ....Linux....... 02d8 04000000 14000000 03000000 474e5500 ............GNU. 02e8 958db149 af5156cb 45309896 7a53ae8a ...I.QV.E0..zS.. 02f8 ef34e95c .4.\ diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index d808ad31e01f..d51e886c6223 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -31,7 +31,13 @@ SECTIONS .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } - .note : { *(.note.*) } :text :note + /* + * Add the .note.gnu.property section first, as it's aligned to + * 8-bytes, while other notes are aligned to 4-bytes. + */ + . = ALIGN(8); + + .note : { *(.note.gnu.property) *(.note.*) } :text :note . = ALIGN(16); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B021C433B4 for ; Thu, 29 Apr 2021 09:25:53 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9ACB661405 for ; Thu, 29 Apr 2021 09:25:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9ACB661405 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DdTWmEPMDquxyvVx8fcqbLc/ucDIQ3gzTvc9lCYyzN8=; b=Ww/M7vwWF3lh3svnmwirD1gxS 8oCXYVYzYJw/6aJflrpBpxE4oH8hnsmp+ZZ4ZKPW2b2NVdghPGO3UwQfMRw59z34OlO9pSzdY6bza ispbNlAk8DN2ClFPOjxg2J2DS4sQh/2hj4RnqNuzxgvnTb7/O75qilU5NkxYZW5APaJGWLpwhQ/GE KXC0k+nAwjTa/4nBYQOOxNbmeM21sihAxU4KCrSJ0CWHtSAfwkZxQtRVGx7e7iTMyJ+c3zrQUI8e0 HFULo7mF1cgI5IRfSdfDFP4KFKTu5HLtuY/FGz2IrPzvW1vcLpXEWmJf6jrKvSgyMwhEbhTg/MKES zSHNctRCA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lc2tv-005Qga-Rw; Thu, 29 Apr 2021 09:24:03 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lc2tp-005QgF-Sq for linux-arm-kernel@desiato.infradead.org; Thu, 29 Apr 2021 09:24:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=F8cREKu+7p2lFf21gsP7RTu5Zef9Sd3kayTqrQK/7ds=; b=NjU4DzTh16n3rNGgpNicyu2pdV 4ODY1Qz1xwtNs3XYcrfHZEtxh9ofl80izAQmYcd4xV7v6E/FhgJM+1MZrtNIqY81rnaZR4DfqAwJL T9kvIIeYxIlF3fsTGN5X1wGAbJoqCvLKKucTRzMGifuUUT4LRwjdq3XvQcPkccWfiWlmuz03zNiAs uRL1BckPhaff8g21Ih/vFIoWbsakiPz98zETRDJb3v0gUC1voI995OTG439a48ZyDXWvSaxYER1SX FP8HEbcqE6RxKBh7ai+Mz97DQwPVAcUOvp46hfa433CYEzgGtvpBZ/AkT/w+mWa3lLV1SzwfKCAc+ 1aanCURw==; Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lc2tn-000WST-2k for linux-arm-kernel@lists.infradead.org; Thu, 29 Apr 2021 09:23:56 +0000 Received: by mail-ej1-x630.google.com with SMTP id f24so271721ejc.6 for ; Thu, 29 Apr 2021 02:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F8cREKu+7p2lFf21gsP7RTu5Zef9Sd3kayTqrQK/7ds=; b=Al1qjFvxRLGghYHIOI+isxnecFyTgSjOxpf7NwVHobrXlgIhwBEaKxIVbyllnEwoAp BoANU9NuXlpUbC9myklwu4LxrscJKNPBNDJpm1GQ+DbpC6v/LxXbhqD0NzGnj5hmjXmC RKubRD9+NjNWaGvyc4eU19c8mXnLwYKZPIMV4Dsi+/xGlY6Tv0zdvnoD/yAKhResXwD6 4vpgNIHik2Z3RJDQSmDwgcqSO7UBw5wIs469Veqmq6czAy0BaTs5lSUeVLFALzPszuty 0oyhGoFggGb7uCDn4674L8SXZRYQIphc9ont8/wpBMmDsW5ixiy1RdDwLoMrsR5An4KE b2GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F8cREKu+7p2lFf21gsP7RTu5Zef9Sd3kayTqrQK/7ds=; b=JKabbPcSbUVpfOV+ZgpKmAFufta4NinAVyljDb9brl3bSvxMi13ENqFPb0b2FN/Wrh yETfNbb2sbQviO6IJlqVCPYrflQFn4cOTTjpyKZrKNNX/aUPNN31rmw27KvROMCBjXQD ZBE4KhIhycD+BRCAW7jDkNMmX3r10AucFJ8T0VEemIlpreHAT40iuBWEFuI9F6CPpTW/ tTCJP1kHb3LTNSx6bB9lCkiMlHOMDtMTRw6V3QqIT7RoMCjuXVdLU2R+/Gu6MvKQWWqB vqNWqbW6P44ks9F/DroqFOTR70Q3zS8qaIR3iR5QkF3RAi/LsP5p3oQ07pEk3WpDE2Ih tyWg== X-Gm-Message-State: AOAM531/SgOWz8Y7G2Uby7EsForLifFSoxPbMl/piTdnRGOlp3In5i0z /f9Ez/dFmHYlcKqPYk4MFBx1IQ9CnZCZSkDnF0Ma X-Google-Smtp-Source: ABdhPJzmD5KIaSE76zux8n1Xthc6noF7GoYJOjt3oVwm/b5zsJgjfEFSjyl1HGJk8D9o50MGI6eo4N+rEp0rU6r5b60= X-Received: by 2002:a17:906:b7d3:: with SMTP id fy19mr12024625ejb.269.1619688232584; Thu, 29 Apr 2021 02:23:52 -0700 (PDT) MIME-Version: 1.0 References: <20210423205159.830854-1-morbo@google.com> <20210428172847.GC4022@arm.com> <20210428174010.GA4593@sirena.org.uk> <20210429075454.GQ9028@arm.com> In-Reply-To: <20210429075454.GQ9028@arm.com> From: Bill Wendling Date: Thu, 29 Apr 2021 02:23:41 -0700 Message-ID: Subject: Re: [PATCH] arm64/vdso: Discard .note.gnu.property sections in vDSO To: Szabolcs Nagy Cc: Mark Brown , Catalin Marinas , Kees Cook , Ard Biesheuvel , Will Deacon , LKML , linux-arm-kernel@lists.infradead.org, Daniel Kiss X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210429_022355_163125_BD416F7A X-CRM114-Status: GOOD ( 35.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 29, 2021 at 12:55 AM Szabolcs Nagy wrote: > The 04/28/2021 12:31, Bill Wendling wrote: > > On Wed, Apr 28, 2021 at 12:21 PM Bill Wendling wrote: > > > On Wed, Apr 28, 2021 at 10:40 AM Mark Brown wrote: > > > > On Wed, Apr 28, 2021 at 06:28:47PM +0100, Catalin Marinas wrote: > > > > > On Fri, Apr 23, 2021 at 01:51:59PM -0700, Bill Wendling wrote: > > > > > > > > > > Since the note.gnu.property section in the vDSO is not checked by the > > > > > > dynamic linker, discard the .note.gnu.property sections in the vDSO. > > > > > > > > > Can we not instead fix the linker script to preserve the > > > > > .note.gnu.property, correctly aligned? It doesn't take much space and > > > > > while we don't use it now, it has the BTI information about the binary. > > > > > > > > > Cc'ing a few others who were involved in the BTI support. > > > > > > > > Not just BTI, we also flag PAC usage in there too and could add other > > > > extensions going forwards. While the note isn't actively used by > > > > anything right now due to the kernel mapping the vDSO prior to userspace > > > > starting it is part of the ABI and something could end up wanting to use > > > > it and getting confused if it's not there. It would be much better to > > > > fix the alignment issue. > > > > > > If there's only one of the 8-byte aligned sections guaranteed, we > > > could place it first in the note. Otherwise, we will have to change > > > the alignment of the note (or somehow merge multiple notes). > > > > > I should have clarified that there's only one *entry* in the > > .note.gnu.properties section, and if not then is it possible to merge > > multiple entries into one. (Excuse my ignorance if this is already the > > case.) > > .note.gnu.property should go to PT_GNU_PROPERTY and it > should be merged following rules specified in > https://github.com/hjl-tools/linux-abi/wiki/Linux-Extensions-to-gABI > and > https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst#program-property > > it may also be covered by a (8byte aligned) PT_NOTE, but > that's not a requirement on aarch64 (x86 requires it for > compatibility with old dynamic linker, but since the vdso > is handled specially that may not be relevant either). > > i don't know how this works in linker scripts. This is a potential patch. I haven't had time to test it though. However, it does appear to format the section in the "expected" way, so one's able to grab the build IDs. Thoughts? $ objdump -s -j .note ./arch/arm64/kernel/vdso/vdso.so ./arch/arm64/kernel/vdso/vdso.so: file format elf64-little Contents of section .note: 0288 04000000 10000000 05000000 474e5500 ............GNU. 0298 000000c0 04000000 03000000 00000000 ................ 02a8 06000000 04000000 00000000 4c696e75 ............Linu 02b8 78000000 000a0500 06000000 01000000 x............... 02c8 00010000 4c696e75 78000000 00000000 ....Linux....... 02d8 04000000 14000000 03000000 474e5500 ............GNU. 02e8 958db149 af5156cb 45309896 7a53ae8a ...I.QV.E0..zS.. 02f8 ef34e95c .4.\ diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index d808ad31e01f..d51e886c6223 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -31,7 +31,13 @@ SECTIONS .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } - .note : { *(.note.*) } :text :note + /* + * Add the .note.gnu.property section first, as it's aligned to + * 8-bytes, while other notes are aligned to 4-bytes. + */ + . = ALIGN(8); + + .note : { *(.note.gnu.property) *(.note.*) } :text :note . = ALIGN(16); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel