linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fāng-ruì Sòng" <maskray@google.com>
To: Kees Cook <keescook@chromium.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Arnd Bergmann <arnd@arndb.de>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	linux-arch <linux-arch@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, X86 ML <x86@kernel.org>
Subject: Re: [PATCH v2] vmlinux.lds.h: Keep .ctors.* with .ctors
Date: Wed, 21 Oct 2020 13:32:09 -0700	[thread overview]
Message-ID: <CAFP8O3KzCbFQarDCBbwsV_saQ2stpy69-a1zBY0Jf2u9PnzzKQ@mail.gmail.com> (raw)
In-Reply-To: <202010211304.60EF97AF2@keescook>

On Wed, Oct 21, 2020 at 1:09 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, Oct 14, 2020 at 09:53:39PM -0700, Fāng-ruì Sòng wrote:
> > On Wed, Oct 14, 2020 at 4:04 PM Kees Cook <keescook@chromium.org> wrote:
> > > > index 5430febd34be..b83c00c63997 100644
> > > > --- a/include/asm-generic/vmlinux.lds.h
> > > > +++ b/include/asm-generic/vmlinux.lds.h
> > > > @@ -684,6 +684,7 @@
> > > >  #ifdef CONFIG_CONSTRUCTORS
> > > >  #define KERNEL_CTORS()       . = ALIGN(8);                      \
> > > >                       __ctors_start = .;                 \
> > > > +                     KEEP(*(SORT(.ctors.*)))            \
> > > >                       KEEP(*(.ctors))                    \
> > > >                       KEEP(*(SORT(.init_array.*)))       \
> > > >                       KEEP(*(.init_array))               \
> > > > --
> > > > 2.25.1
> >
> > I think it would be great to figure out why these .ctors.* .dtors.* are generated.
>
> I haven't had the time to investigate. This patch keeps sfr's builds
> from regressing, so we need at least this first.

We need to know under what circumstances .ctors.* are generated.
For Clang>=10.0.1, for all *-linux triples, .init_array/.finit_array
are used by default.
There is a toggle -fno-use-init-array (not in GCC) to switch back to
.ctors/.dtors

Modern GCC also uses .init_array. The minimum requirement is now GCC
4.9 and thus I wonder whether the .ctors configuration is still
supported.
If it is (maybe because glibc version which is not specified on
https://www.kernel.org/doc/html/latest/process/changes.html ), we
should use
some #if to highlight that.

> > ~GCC 4.7 switched to default to .init_array/.fini_array if libc
> > supports it. I have some refactoring in this area of Clang as well
> > (e.g. https://reviews.llvm.org/D71393)
> >
> > And I am not sure SORT(.init_array.*) or SORT(.ctors.*) will work. The
> > correct construct is SORT_BY_INIT_PRIORITY(.init_array.*)
>
> The kernel doesn't seem to use the init_priority attribute at all. Are
> you saying the cause of the .ctors.* names are a result of some internal
> use of init_priority by the compiler here?
>

If no priority is intended, consider deleting SORT to avoid confusion?

  reply	other threads:[~2020-10-21 20:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05  2:57 [PATCH v2] vmlinux.lds.h: Keep .ctors.* with .ctors Kees Cook
2020-10-05 17:36 ` Nick Desaulniers
2020-10-14 23:04 ` Kees Cook
2020-10-15  4:53   ` Fāng-ruì Sòng
2020-10-21 20:09     ` Kees Cook
2020-10-21 20:32       ` Fāng-ruì Sòng [this message]
2020-10-21 20:04 ` Kees Cook
2020-10-21 22:22   ` Borislav Petkov
2020-10-21 22:25     ` Kees Cook
2020-10-21 22:29       ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFP8O3KzCbFQarDCBbwsV_saQ2stpy69-a1zBY0Jf2u9PnzzKQ@mail.gmail.com \
    --to=maskray@google.com \
    --cc=arnd@arndb.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=keescook@chromium.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sfr@canb.auug.org.au \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).