Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5374823pxu; Wed, 21 Oct 2020 23:56:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAFsj3AnTdszbF8s0515cMpbGpxDlIN4fwyABmdnuKO/apJGEE2TX0dTDF3drKpka6Y+vd X-Received: by 2002:a50:fe09:: with SMTP id f9mr930756edt.239.1603349795561; Wed, 21 Oct 2020 23:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603349795; cv=none; d=google.com; s=arc-20160816; b=waLu4XZhyur5bt88evAW6LTqFN0u7PvPALRsgQjtudc5XcdmlMpCyNIH9e57gmzEvX 1iOUi5BC3pl0wqoio1WyURcAnOhb8m/RDyqqjysaLPO4VvbSYVLzl+khnTn6z6sAo/02 kkQB5bHAMceGEVZy0kscSw4JxPLYX1L4UyQkT4sfO3xyeTNYovi22zIaGK2x3WaqxvMI q4+ikMqwukolatUtOBOFQll8oWqlheCs+/JqoTVvhoyga8ohQhYma+9ULR7A9Ii4KXvc tlsIRo7+XLf64nlIWc6Lz9XhG0wei6vJyuSsi5gRCduaI137CLhzxmKFq6+/hss7XUyq cqGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ZlQ9VQDQ1Y9MZKtPS8PBXAKEQPFLhfcQu+fvrtVUj70=; b=jV8JhBvV2iHLmahw8sFtljGvd9siuj/jHCVe0qnz0P54XqppkZoD3AtWkONsvGUU2T YKWCUR/LeZ5C10r4EqzAWqEXM/z4XtgJIpuvwDkHLnGFZGjQwAKsgNrlnis4iQ77ERQn 3GJOCGO+ZBGvTSTTFdYej4B6ry7rjp1bXckYZ50sIeyYkOM0X9H+qoMP84xuUCPFX4Yf ykOa1Eh1l0kJgJfJDMRUM0X//bWqLi/jmsP28FKWquPTmTAUBcyVgcED+F5Ngy2Zn+Rv 3ff7sSXwcWBpg+h5qtkp1ct/Jfv9CxkcyCNUL0S9gqXzw1WdirxKY871z6CXYreKS0Ib N7Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Emippq77; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si405520edj.601.2020.10.21.23.56.13; Wed, 21 Oct 2020 23:56:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Emippq77; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2505352AbgJUUcZ (ORCPT + 99 others); Wed, 21 Oct 2020 16:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410339AbgJUUcZ (ORCPT ); Wed, 21 Oct 2020 16:32:25 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69007C0613CE for ; Wed, 21 Oct 2020 13:32:21 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id a200so2166965pfa.10 for ; Wed, 21 Oct 2020 13:32:21 -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:content-transfer-encoding; bh=ZlQ9VQDQ1Y9MZKtPS8PBXAKEQPFLhfcQu+fvrtVUj70=; b=Emippq77DbvWgKUDGkyBMfhRMm1aDnbYDXtMujdgf+mu86LHMe+9Tlr+o7S+4ixM11 j/yvPBB4uvdF3zfF9C70EW8ygMoDOjnFoe2zerU36e4d5nRZYzQNJaDi6Y8z2uj2hJI4 PhL0lcNF0rL3NTBTeqlT4jza+R/TkvHn6SUxthmepS0xajOLKrIek6s/xEhdCSlnsUWq EB2HsmKjK+IijnLdv9z2G3jWa7jN2T+KNvWypDG/8+fSUCRMnmoeAbpovfiF5c3RE2Tp TSrAhiFsocuyPdjHtu1LoF4xT23mVI0v2BV+TXGqD6p3EAPx9VgvgCEWBgc6gVnfr2hK nnkA== 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:content-transfer-encoding; bh=ZlQ9VQDQ1Y9MZKtPS8PBXAKEQPFLhfcQu+fvrtVUj70=; b=maFCLXpb9moGGadinNvYARH3y4Plyc8jcmx8HrtZLaMV+8D/NFv0mSLS0R5AvVLWWM VsZsevr/b2F1y39kF19U//sCBevsz2n7kXaTsf5TrssrFyb/kmhK0CqrYXfkljVgeTGx lCul7/+9wnK+30wbj8ElE+JhLIDh4VqjFJ2fVa1lDQRT+MVbD+QmM1+8ZwsPYUJqOpxp PD4G/qvJwLlQevdTWgDaOj7sven5UixIaozy81aEMs6dmA8bEC0E0OBK+ekfNInuiFlV xfZ6BinxQhbclrbacQof/iU5q0VkQFs57xwJxM7pRRpVqRGFdDChDI/3uPoHj04sUCTI vfEw== X-Gm-Message-State: AOAM530DUYHevHxiKGtYi/EcHn55U4inruQvwLnf41Gz4wirwmGC/KMj UdYKjAR7CyOU0SKM7Q31EUBfhVbnb4BsRzFb+y/RSQ== X-Received: by 2002:a65:4485:: with SMTP id l5mr4905625pgq.121.1603312340655; Wed, 21 Oct 2020 13:32:20 -0700 (PDT) MIME-Version: 1.0 References: <20201005025720.2599682-1-keescook@chromium.org> <202010141603.49EA0CE@keescook> <202010211304.60EF97AF2@keescook> In-Reply-To: <202010211304.60EF97AF2@keescook> From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Wed, 21 Oct 2020 13:32:09 -0700 Message-ID: Subject: Re: [PATCH v2] vmlinux.lds.h: Keep .ctors.* with .ctors To: Kees Cook Cc: Ingo Molnar , Stephen Rothwell , Nick Desaulniers , Arnd Bergmann , clang-built-linux , linux-arch , LKML , X86 ML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 21, 2020 at 1:09 PM Kees Cook wrote: > > On Wed, Oct 14, 2020 at 09:53:39PM -0700, F=C4=81ng-ru=C3=AC S=C3=B2ng wr= ote: > > On Wed, Oct 14, 2020 at 4:04 PM Kees Cook 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() . =3D ALIGN(8); = \ > > > > __ctors_start =3D .; \ > > > > + 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>=3D10.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?