Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp902559rwl; Thu, 5 Jan 2023 06:14:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXvEOzK86lYSTQcVFYKfbu7VEioVQpqv2AUYr5fqsx84ZyHNNabEK/zR7zG7KII+tI0L9sBB X-Received: by 2002:a17:90b:2291:b0:226:43ba:54af with SMTP id kx17-20020a17090b229100b0022643ba54afmr20995190pjb.2.1672928047316; Thu, 05 Jan 2023 06:14:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672928047; cv=none; d=google.com; s=arc-20160816; b=mWJ16s4M24vCiwfzQ606ueO0OBmXVrSYVFq/NllK5Epa8ypwHx9iDdQAgjpSDm0R0w CW3egX0HZtHAWrTpsRdgyFclceQyvDxrM8Tf29SDu0CKZg0aBBe0w4G5pwxMpUn+14ov ZV58E3RQ5JPmZvsDNgmIHDA58fxjnQbwA04TGvRUBKKLzvnNRlovaUAHY7kqYBRBbLFb XV6xQ1aWZFZZcKqKCq3jDydSAaEA+YHBxBeSniO5n3crcB3bCWYeqniQf+cmovjFN64D ZGpNocki1lAxn8Y+xL9aAdTzur1g9YPrCQFGDZwpvWc+5LclNfIQ9ey8KN0ntElvHKzM TYug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zGZ7+eopQFwGuo7EYGAZa2H1GZDsDBa7oO0guAcUsdg=; b=wsCxj/OQuZ+SLPlVchvToQPZO/2gRkCdlr2fcCBdXHQtd81RNRo7MuZ3BU4OqAQQ/j mOoKZ0E+7rRaEtizCZQO63iSBfaAfzgwqarQXyshKbGwFh4TDR5cbSGrNuJv78KckFeg UdwXEkQoWsBjKXsu8KFYl35V9k3GST9oIdY3b08Br0uaEbt2U3dtMjl/NFxIs1Pi3E/D 5JkK1f+Btq4+ZYMlEZzzD1boyJC+Wy1P7+zidq5KrtAGFSzR5n2FRR3IVo4Wr+8qJ+yA aG8kb0+pB8CxygVkxGUdECIWN0d1dpkl7/jeTkYv7KiISCrq1OUZRtfuHytVtTukQQZ+ 13+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y9aS4xKZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot2-20020a17090b3b4200b00225f3e34336si2218577pjb.89.2023.01.05.06.14.00; Thu, 05 Jan 2023 06:14:07 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=Y9aS4xKZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232465AbjAENow (ORCPT + 56 others); Thu, 5 Jan 2023 08:44:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232763AbjAENos (ORCPT ); Thu, 5 Jan 2023 08:44:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14CA37277 for ; Thu, 5 Jan 2023 05:44:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6D73961A4D for ; Thu, 5 Jan 2023 13:44:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE021C43398 for ; Thu, 5 Jan 2023 13:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672926286; bh=oUowVryprpSKh0x6r/UB6C3j62vFgmCCkaUhgHs/5bg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Y9aS4xKZagBkJ4xEjwJ1aVMalSYiqIyd/2WGPUtnTtF7ewiH81nwiw9+HF9utsu3c BTxAK3VIfTB40jxSle0t0cebx2RaZPAm0HoZf1b+L+g53eQeDbLleckOSTwvp4wNTN NyJgaY86T9FB8MSX68chb6VT/FhZS0m25sU0NU314rnXveBymvHGMPqeCi69UROXfo GLkQLP/+e2lIhB1UN9jPatWmOGrWX/rLSF0wHRpFyAU++2arv3hR94ksSEMf0j93FC b8A+cgaiQ310ZQUMXjxFgERGwQv+8B9LOmKVEMfQSEL0BU6vH32dq6kefB+SLyR0Zk gLmldlujrDqgA== Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-14fb7fdb977so36337383fac.12 for ; Thu, 05 Jan 2023 05:44:46 -0800 (PST) X-Gm-Message-State: AFqh2kranrp5ueTIxLoqj+DVNVz/RZ74y32cHaOfemXOfIgq2AQyb7dl +VxYbzjNrBVv8Rq8vEZH0hV35cFfDFLZbQz75EQ= X-Received: by 2002:a05:6870:514c:b0:150:7e4a:2f00 with SMTP id z12-20020a056870514c00b001507e4a2f00mr1126149oak.194.1672926285969; Thu, 05 Jan 2023 05:44:45 -0800 (PST) MIME-Version: 1.0 References: <20230102225656.GA3532398@roeck-us.net> <20230103014535.GA313835@roeck-us.net> In-Reply-To: From: Masahiro Yamada Date: Thu, 5 Jan 2023 22:44:09 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Linux 6.2-rc2 To: Linus Torvalds Cc: Ard Biesheuvel , Guenter Roeck , "Jason A. Donenfeld" , Yoshinori Sato , Rich Felker , Arnd Bergmann , Linux Kernel Mailing List , Palmer Dabbelt Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Wed, Jan 4, 2023 at 3:34 AM Linus Torvalds wrote: > > On Tue, Jan 3, 2023 at 2:59 AM Ard Biesheuvel wrote: > > > > The purpose of this change is to prevent .note.GNU-stack from deciding > > the section type of the .notes output section, and so keeping it in > > its own section should be sufficient. E.g., > > > > - /DISCARD/ : { *(.note.GNU-stack) } \ > > + .note.GNU-stack : { *(.note.GNU-stack) } \ > > This seems to work for everybody, so let's go with this. Masahiro? > > Linus Sorry for the delay, I completely missed this thread. Tested-by: Masahiro Yamada It works for me, but the comment block above should be changed accordingly, for example: /* - * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler. + * Separte note.GNU-stack, which is emitted as PROGBITS by the compiler. * Otherwise, the type of .notes section would become PROGBITS instead of NOTES. */ This change, however, leaves an empty .note.GNU-stack section in vmlinux. I personally prefer discarding .note.GNU-stack entirely because GNU linker does not leave empty .note.GNU-stack when linking user-space programs. Because I did not notice the discussion was happening in this thread, I submitted a different approach for fixing s390, and it was quickly merged: https://lore.kernel.org/lkml/20230105031306.1455409-1-masahiroy@kernel.org/ This approach requires RUNTIME_DISCARD_EXIT for each architecture, though. I do not know how Michael will fix powerpc. While I was looking into this issue, I noticed the real issue is, how to discard sections is up to arch maintainers. [1] Most architectures discard .exit.* sections at run-time. Just run git grep EXIT_TEXT or find . -name vmlinux.lds.S | xargs grep "at runtime" [2] If .exit.* is allocated, then later discarded, it is kept. (the first occurrence wins, in other words, the sections defined in /DISCARD/ are not necessarily discarded) [3] Despite the fact of [1], many architectures forget to define RUNTIME_DISCARD_EXIT. They still work because they put DISCARD at the end of their linker scripts. [4] arm64 puts DISCARD at the beginning of the linker script, and defines RUNTIME_DISCARD_EXIT because otherwise .exit* are discarded due to the "first wins" rule. [5] If we really want to discard more sections, we often end up with moving DISCARD up, and at this point, we realize that RUNTIME_DISCARD_EXIT is missing. I think it is unreadable (and fragile) to keep/discard sections depending on the particular order in the linker scripts. Is there any better approach to make sure to discard sections defined in DISCARDS? -- Best Regards Masahiro Yamada