Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2598152rwn; Fri, 16 Sep 2022 12:55:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jFlVY5IrG64qbMWtm7R8JHlnmPBTZqLR/WH4bJa40Z/F7Z8mZe0xRFuxw8WQ/+B42+coj X-Received: by 2002:a17:907:9805:b0:77b:cbe2:c5dd with SMTP id ji5-20020a170907980500b0077bcbe2c5ddmr4692919ejc.41.1663358117415; Fri, 16 Sep 2022 12:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663358117; cv=none; d=google.com; s=arc-20160816; b=n/DryyDT06pdRH/TyskuAgmCVA391fxPSha4OtS6D8KTegE8pGdNbB+/x5KU4ncwH1 O+lVelpil8kcGXKGJ/Rz1oj6dTa1bqMpd4hxy6MZrow4LPVX5jtUGn/Zyf/YA2Izv3Sl BtmjW9PVzMwXNSqTSVtH9Bc9QlZLOlUk9u/XIzhCjtGAw4KOuAC+sRrtIYvcVJ8KkruK Xe4VkDCOcIQgSOCQ8lLaU0joCkK5Y3labqfIDtoHiMfJalZgpJE4ywdaA56YXlH+7OM0 7vfHM8zXNioR+c6HAfWLuUnylWo5EEi5oNIYRu5RuLPeKc0OOU8pF0Muo6K7NT9s/MlO zKsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vH9TYUFkIGeMDXb5QksQYPq2h16Z8OyKOOQMeyEvl7I=; b=bswwn3URz+p/Il6fu9CtiJUWeYpGTAl4jPqR4O7VtPCND7ILaHXlR2g6qKk0umARjk ciZrmd1rr5hbxGmZ4NryZR4mjH30oNeLXizVMwhIzcw01T7l653NW2tf4L6o3JnAXWBY 2ZMpOuQWsnHLadkcQz4GAJinLLJVyeTXam5XaW2Amnq8sulhqmW5yoaQE92xU72a9DSV y2h3Y5279gkoxfWXAEhanIZxInPH/O3yZxu87vuZl8gJ2zlbc8YMgme9z9mo0H4KxE45 qbqqrmKW53CyjTL3QpvYAMxsm+I6aGO/HXhkQoUz8/+aBfEAx/xFN2SroNim8KXMcne2 VGkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20210112.gappssmtp.com header.s=20210112 header.b=yQYnZNYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho20-20020a1709070e9400b00775de3ca64bsi15545246ejc.92.2022.09.16.12.54.45; Fri, 16 Sep 2022 12:55:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@osandov-com.20210112.gappssmtp.com header.s=20210112 header.b=yQYnZNYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbiIPTks (ORCPT + 99 others); Fri, 16 Sep 2022 15:40:48 -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-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> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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