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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C2BDECAAD8 for ; Fri, 16 Sep 2022 19:40:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbiIPTkt (ORCPT ); Fri, 16 Sep 2022 15:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbiIPTkj (ORCPT ); Fri, 16 Sep 2022 15:40:39 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7548551A26 for ; Fri, 16 Sep 2022 12:40:38 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id go6so17820162pjb.2 for ; Fri, 16 Sep 2022 12:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=vH9TYUFkIGeMDXb5QksQYPq2h16Z8OyKOOQMeyEvl7I=; b=yQYnZNYXV2FOBIibg997hqy6cC66Xcky9Sj1dsdt9zQ2ExgJBmCw7m7HEVew01OMsq F5Syd9PMYleHHa8qZTq3Fm9U8YYRdzBT6XwXkLH6AkBSRD4kYLWXSbmA+XE0Ijd7Y02R fywzlhmHsq9NLj5EqW7MBVPTfeuC0m1PXQXy01iqcDPQ5fpf2SfP9VjvqQG43JPfEMzd THexk1qxiNY3EdQ9PhS20kfWyFX+ybdJ8u7ZRMlpfyWhiuQGOrEOcL0pCG6Ph5f1NyCE rYM8RxnObeweJJ5wHVpXvCjsOKxxl4A9iZ4d9eqpD/xkB/ezV5oRZDFpQnnhCdNgRhRC Uehw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=vH9TYUFkIGeMDXb5QksQYPq2h16Z8OyKOOQMeyEvl7I=; b=1PatgN8cCD1GpmxZCwnMwWIzA+khFNxj53aocnACLWTYIHcX/Bpn/dgEQBhF2KZTCk YBBy4Osuo1VDKJTLDsXlh3CFuPuy9F6NPt8JXBLiFYU99OUG0kdZc2B5dCviBcXztS4o kgJHVJ2Kpz+UgpdbgElei+UEnn5PWOwK0KWdBzr0G9rIaydLHLX3sDcTXzUMwFeFP0NZ iRHtGZM3WjrNFgm6pVTDvciqNwf2beqBOlquf1+lSoPZ1kjGWGU4fOd/a+zE8WFXILuu sF//5wjboa7SRgNo8nxwVQVvwyd2LUMu5yas04XeR9K5P1XGPlgK8g/Q1edxZgKCaU+0 He+w== X-Gm-Message-State: ACrzQf3d+SM9NhHFiJEpdfg3OLm4HlpXrVnG9ixuD3PXU1Mc2dvxsV4h 1ggfrBGM1txEAe8ClD8DGIFSLQ== X-Google-Smtp-Source: AMsMyM7bBzN5wKpJ4/hmwedRCv3ia/zW3TzU2MrSu2w0889ImAiNQlhDbVHcvxIyYWbaKNLMT5PpHA== X-Received: by 2002:a17:90b:4c0c:b0:203:1407:809c with SMTP id na12-20020a17090b4c0c00b002031407809cmr7126292pjb.193.1663357237910; Fri, 16 Sep 2022 12:40:37 -0700 (PDT) Received: from relinquished.localdomain ([2620:10d:c090:500::3:3c76]) by smtp.gmail.com with ESMTPSA id c3-20020a170903234300b001780a528540sm15448988plh.93.2022.09.16.12.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:40:37 -0700 (PDT) Date: Fri, 16 Sep 2022 12:40:35 -0700 From: Omar Sandoval To: "H.J. Lu" Cc: linux-kernel@vger.kernel.org, Yu-cheng Yu , Arnd Bergmann , linux-arch@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Kees Cook , Borislav Petkov , "Naveen N . Rao" , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 2/2] Discard .note.gnu.property sections in generic NOTES Message-ID: References: <20200428132105.170886-1-hjl.tools@gmail.com> <20200428132105.170886-2-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200428132105.170886-2-hjl.tools@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2020 at 06:21:05AM -0700, H.J. Lu wrote: > With the command-line option, -mx86-used-note=yes, the x86 assembler > in binutils 2.32 and above generates a program property note in a note > section, .note.gnu.property, to encode used x86 ISAs and features. But > kernel linker script only contains a single NOTE segment: > > PHDRS { > text PT_LOAD FLAGS(5); > data PT_LOAD FLAGS(6); > percpu PT_LOAD FLAGS(6); > init PT_LOAD FLAGS(7); > note PT_NOTE FLAGS(0); > } > SECTIONS > { > ... > .notes : AT(ADDR(.notes) - 0xffffffff80000000) { __start_notes = .; KEEP(*(.not > e.*)) __stop_notes = .; } :text :note > ... > } > > The NOTE segment generated by kernel linker script is aligned to 4 bytes. > But .note.gnu.property section must be aligned to 8 bytes on x86-64 and > we get > > [hjl@gnu-skx-1 linux]$ readelf -n vmlinux > > Displaying notes found in: .notes > Owner Data size Description > Xen 0x00000006 Unknown note type: (0x00000006) > description data: 6c 69 6e 75 78 00 > Xen 0x00000004 Unknown note type: (0x00000007) > description data: 32 2e 36 00 > xen-3.0 0x00000005 Unknown note type: (0x006e6558) > description data: 08 00 00 00 03 > readelf: Warning: note with invalid namesz and/or descsz found at offset 0x50 > readelf: Warning: type: 0xffffffff, namesize: 0x006e6558, descsize: > 0x80000000, alignment: 8 > [hjl@gnu-skx-1 linux]$ > > Since note.gnu.property section in kernel image is never used, this patch > discards .note.gnu.property sections in kernel linker script by adding > > /DISCARD/ : { > *(.note.gnu.property) > } > > before kernel NOTE segment in generic NOTES. > > Signed-off-by: H.J. Lu > Reviewed-by: Kees Cook > --- > include/asm-generic/vmlinux.lds.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > index 71e387a5fe90..95cd678428f4 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -833,7 +833,14 @@ > #define TRACEDATA > #endif > > +/* > + * Discard .note.gnu.property sections which are unused and have > + * different alignment requirement from kernel note sections. > + */ > #define NOTES \ > + /DISCARD/ : { \ > + *(.note.gnu.property) \ > + } \ > .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ > __start_notes = .; \ > KEEP(*(.note.*)) \ > -- > 2.25.4 > Hi, H.J., I recently ran into this same .notes corruption when building kernels on Arch Linux. What ended up happening to this patch? It doesn't appear to have been merged, and I couldn't find any further discussion about it. I'm happy to resend it for you if you need a hand. Thanks, Omar 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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4457EECAAD8 for ; Sat, 17 Sep 2022 02:39:52 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MTwBt3HW0z3c8s for ; Sat, 17 Sep 2022 12:39:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=osandov-com.20210112.gappssmtp.com header.i=@osandov-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=yQYnZNYX; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=osandov.com (client-ip=2607:f8b0:4864:20::1035; helo=mail-pj1-x1035.google.com; envelope-from=osandov@osandov.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osandov-com.20210112.gappssmtp.com header.i=@osandov-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=yQYnZNYX; dkim-atps=neutral Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MTkvJ1sWZz3bdk for ; Sat, 17 Sep 2022 05:40:42 +1000 (AEST) Received: by mail-pj1-x1035.google.com with SMTP id y11so5077754pjv.4 for ; Fri, 16 Sep 2022 12:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=vH9TYUFkIGeMDXb5QksQYPq2h16Z8OyKOOQMeyEvl7I=; b=yQYnZNYXV2FOBIibg997hqy6cC66Xcky9Sj1dsdt9zQ2ExgJBmCw7m7HEVew01OMsq F5Syd9PMYleHHa8qZTq3Fm9U8YYRdzBT6XwXkLH6AkBSRD4kYLWXSbmA+XE0Ijd7Y02R fywzlhmHsq9NLj5EqW7MBVPTfeuC0m1PXQXy01iqcDPQ5fpf2SfP9VjvqQG43JPfEMzd THexk1qxiNY3EdQ9PhS20kfWyFX+ybdJ8u7ZRMlpfyWhiuQGOrEOcL0pCG6Ph5f1NyCE rYM8RxnObeweJJ5wHVpXvCjsOKxxl4A9iZ4d9eqpD/xkB/ezV5oRZDFpQnnhCdNgRhRC Uehw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=vH9TYUFkIGeMDXb5QksQYPq2h16Z8OyKOOQMeyEvl7I=; b=ljMPam6lZV3zYy2ixcqdE+5DRrgnWa8UrDylF6WmchFFPMi0QLpbHyKMr4vkrqJ95h J0/MO8GmvCT185i36Sp7OSWfeFq6xvixyRaWbfaETOxf/iMFgJ3I/xtr6bW08ap5RYfP dBXbFkygs7kshPjv8QjUrsLJIb6TzKpQPd8PB+sjg4Sb1332QM2bbnR+xQaAsgp9hANf I9Q3XXN4XN81Y1yIXBC++TqM25tsbwxr4Q8XRAJUmdvRzxNkDN1r6g8328xxoccewzlG IZKo1AyopQLQ0tNAEMkY9zumo/rpm32LQk2ZnU/hxIjsXELKwushibCLu1KDILYE6m35 dMJA== X-Gm-Message-State: ACrzQf3QlfHh56cJDci/LLWrKH6lNHVXDKtKIab23YXgtR81dsfvoE7G O2A6DuAHh/Uzz/IadPQzuyXjBw== X-Google-Smtp-Source: AMsMyM7bBzN5wKpJ4/hmwedRCv3ia/zW3TzU2MrSu2w0889ImAiNQlhDbVHcvxIyYWbaKNLMT5PpHA== X-Received: by 2002:a17:90b:4c0c:b0:203:1407:809c with SMTP id na12-20020a17090b4c0c00b002031407809cmr7126292pjb.193.1663357237910; Fri, 16 Sep 2022 12:40:37 -0700 (PDT) Received: from relinquished.localdomain ([2620:10d:c090:500::3:3c76]) by smtp.gmail.com with ESMTPSA id c3-20020a170903234300b001780a528540sm15448988plh.93.2022.09.16.12.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:40:37 -0700 (PDT) Date: Fri, 16 Sep 2022 12:40:35 -0700 From: Omar Sandoval To: "H.J. Lu" Subject: Re: [PATCH 2/2] Discard .note.gnu.property sections in generic NOTES Message-ID: References: <20200428132105.170886-1-hjl.tools@gmail.com> <20200428132105.170886-2-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200428132105.170886-2-hjl.tools@gmail.com> X-Mailman-Approved-At: Sat, 17 Sep 2022 12:39:15 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Yu-cheng Yu , Kees Cook , Arnd Bergmann , linux-kernel@vger.kernel.org, Paul Mackerras , "Naveen N . Rao" , Borislav Petkov , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, Apr 28, 2020 at 06:21:05AM -0700, H.J. Lu wrote: > With the command-line option, -mx86-used-note=yes, the x86 assembler > in binutils 2.32 and above generates a program property note in a note > section, .note.gnu.property, to encode used x86 ISAs and features. But > kernel linker script only contains a single NOTE segment: > > PHDRS { > text PT_LOAD FLAGS(5); > data PT_LOAD FLAGS(6); > percpu PT_LOAD FLAGS(6); > init PT_LOAD FLAGS(7); > note PT_NOTE FLAGS(0); > } > SECTIONS > { > ... > .notes : AT(ADDR(.notes) - 0xffffffff80000000) { __start_notes = .; KEEP(*(.not > e.*)) __stop_notes = .; } :text :note > ... > } > > The NOTE segment generated by kernel linker script is aligned to 4 bytes. > But .note.gnu.property section must be aligned to 8 bytes on x86-64 and > we get > > [hjl@gnu-skx-1 linux]$ readelf -n vmlinux > > Displaying notes found in: .notes > Owner Data size Description > Xen 0x00000006 Unknown note type: (0x00000006) > description data: 6c 69 6e 75 78 00 > Xen 0x00000004 Unknown note type: (0x00000007) > description data: 32 2e 36 00 > xen-3.0 0x00000005 Unknown note type: (0x006e6558) > description data: 08 00 00 00 03 > readelf: Warning: note with invalid namesz and/or descsz found at offset 0x50 > readelf: Warning: type: 0xffffffff, namesize: 0x006e6558, descsize: > 0x80000000, alignment: 8 > [hjl@gnu-skx-1 linux]$ > > Since note.gnu.property section in kernel image is never used, this patch > discards .note.gnu.property sections in kernel linker script by adding > > /DISCARD/ : { > *(.note.gnu.property) > } > > before kernel NOTE segment in generic NOTES. > > Signed-off-by: H.J. Lu > Reviewed-by: Kees Cook > --- > include/asm-generic/vmlinux.lds.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > index 71e387a5fe90..95cd678428f4 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -833,7 +833,14 @@ > #define TRACEDATA > #endif > > +/* > + * Discard .note.gnu.property sections which are unused and have > + * different alignment requirement from kernel note sections. > + */ > #define NOTES \ > + /DISCARD/ : { \ > + *(.note.gnu.property) \ > + } \ > .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ > __start_notes = .; \ > KEEP(*(.note.*)) \ > -- > 2.25.4 > Hi, H.J., I recently ran into this same .notes corruption when building kernels on Arch Linux. What ended up happening to this patch? It doesn't appear to have been merged, and I couldn't find any further discussion about it. I'm happy to resend it for you if you need a hand. Thanks, Omar