Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1608958ybh; Tue, 14 Jul 2020 02:24:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD7WGyLQdbxqwhUASEbYoq7dzrZXjhUdjKFAB2G9xkBhwhTvtYK51iIodvLo4mk0Ey9yjh X-Received: by 2002:a17:906:430b:: with SMTP id j11mr3605402ejm.270.1594718674800; Tue, 14 Jul 2020 02:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594718674; cv=none; d=google.com; s=arc-20160816; b=D66Hc5IvJDpOk5lEKetp+qey+vGFaVIadie3TqOo3axjJdtPN9vod2Uv+4qwzGQNTl zhoUaaq2hL1KmRU0O+QT1R4EA4tBJyxg/GWRFkxK6mHoSgMKtnRpaU463QtjY0S0J8XN TiEwr5HxtHzAl/bh+JUInNt/AVuzOWpR7NJXd4YlbG5viu8Q48PGf2rBtmsXDNg02E0J 12TRwD2buXdPmKpIyZl1IJj8jTIGxU51Z2D40C0C/m07yqXoezp+nXTM59CraPJclgf3 38CixfMOuT2MGjLUqlLVkvzXlqr8ikIoIbAyGUssw+aG1m1itsxduoMsRXxYMSSteyTz zJ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:dkim-signature; bh=C11Oho+jb/RAewyI2tPC4vl+z9j8D1ewX1ArPvL+1E8=; b=A7uqEoJJ0XgN1NgRwqbrIxLLlD/HJ2H6f9bpblrTCLIKqlMW7aw8Tghg+/IUTiy5yq 00wMtYL+dbn9FEgb8kK9yWqIL70aBoSIEDYQLRCHmTOF8IctvJ+gzOEmssSF2vHzHSkt F5Hc3b/qYsAJ3YPvZ3oeFZDe0G6W1OmkdwsvgV02PfM12lKrgeBQAyNi1B22HtctSn+2 DG0DIKoDLWdEIJjiwieXufWQGeIkf4JeHK4eCYdQdenmfx4mgF3OkpXfqGFYgqBFPJ9Z fqBdkPskLWMjTrnX/rltXRWHK1WLJwUA0BcNLAMJDck9Ng4P3FByMB/9J2wmv1gGHI/j LCOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tEvn4OQx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l1si11212111edv.381.2020.07.14.02.24.12; Tue, 14 Jul 2020 02:24:34 -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=@gmail.com header.s=20161025 header.b=tEvn4OQx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726782AbgGNJVJ (ORCPT + 99 others); Tue, 14 Jul 2020 05:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbgGNJVJ (ORCPT ); Tue, 14 Jul 2020 05:21:09 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E35B6C061755 for ; Tue, 14 Jul 2020 02:21:08 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id v6so16561944iob.4 for ; Tue, 14 Jul 2020 02:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=C11Oho+jb/RAewyI2tPC4vl+z9j8D1ewX1ArPvL+1E8=; b=tEvn4OQxwUa/AnfyKQ7zrBWp93Qp1Ib98B+IaC3VDMOqbRzjjtpEMjZsWL29AgtsBC f8PuQ374JWWzyg5dXzuFTq6eq4pENL4HNq70vP2/pfBs+QtdETXj5SzcUbYi8L0UeqbI 81+iungd2ZWjQhKBt7V40lgzabDRb2df6c8kE56Zme3bZBu4HHJVCTN+TK6mmZRVPgEe GNMIiNttXP79IKrNpJM6eKrNgJPI03jnVzyiWcEDCIZ8Icq+dqmv40Ttf4VN1dmT+wII q0qCh88D2Bv1Ap/IrFnHGlDURfjC7iZODGzHRdGBR6MUiNQNm/2qkwLOCJ8bGowBnmgj NYQg== 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:reply-to :from:date:message-id:subject:to:cc; bh=C11Oho+jb/RAewyI2tPC4vl+z9j8D1ewX1ArPvL+1E8=; b=mxQ7dJ8C4iWYHQshZkAibBaW4H0gjbUOCt+JKQvQjscYlB9BwKgmK6hsUtWD+gcmx6 nyOg28pcjUkUliFV8ZcWMKEIxYjHfIDcYnOZSjQ7ME7uGVaIy5c7w9KAQ2i0wmpjBzHk JYae0yMt1RVNAxPTj9Ph8tf5EOCvyJkvypYXnMrUXGexhWVn5rdN5boWVVklpmR3OlOh ocMnkdPAA2ALP/cARAw22bIj7McsCb2jPbj33Cyh10NPbC0JtI7Yh3o236vTLQNBVio9 HcG8o5hMAnSSYgNKZMCz3es0TRYMcpRCe6BTwNmAQrKt9HpSU0LmfDmB+ejVy5dwwUlW RxeA== X-Gm-Message-State: AOAM531ChpMsHytnbwlJU7LaPLoG7ruqOb1KwPiITKVYqs4Ot+/8UoDT iXSb5mFJOjGwMbpM0II871V951KYcOjcT2KxUbI= X-Received: by 2002:a05:6602:1555:: with SMTP id h21mr3908817iow.163.1594718468272; Tue, 14 Jul 2020 02:21:08 -0700 (PDT) MIME-Version: 1.0 References: <20200629140928.858507-1-nivedita@alum.mit.edu> <20200629140928.858507-3-nivedita@alum.mit.edu> In-Reply-To: <20200629140928.858507-3-nivedita@alum.mit.edu> Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Tue, 14 Jul 2020 11:20:57 +0200 Message-ID: Subject: Re: [PATCH v3 2/7] x86/boot/compressed: Force hidden visibility for all symbol references To: Arvind Sankar Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Nick Desaulniers , Fangrui Song , Dmitry Golovin , Clang-Built-Linux ML , Ard Biesheuvel , Masahiro Yamada , Daniel Kiper , Kees Cook , Nathan Chancellor , Arnd Bergmann , "H . J . Lu" , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 29, 2020 at 4:09 PM Arvind Sankar wrote: > > From: Ard Biesheuvel > > Eliminate all GOT entries in the decompressor binary, by forcing hidden > visibility for all symbol references, which informs the compiler that > such references will be resolved at link time without the need for > allocating GOT entries. > > To ensure that no GOT entries will creep back in, add an assertion to > the decompressor linker script that will fire if the .got section has > a non-zero size. > > [Arvind: fixup -include hidden.h to -include $(srctree)/$(src)/hidden.h] > Thanks for your v3 patchset. I tried your initial patchset and informed you about the include file handling. Dropped your patchset against Linux v5.7 as I got no (satisfying) replies. For me this one is missing a Reported-by of mine. As I want to test the whole v3 series, I will report later. - Sedat - > Signed-off-by: Ard Biesheuvel > Acked-by: Arvind Sankar > Signed-off-by: Arvind Sankar > From: Ard Biesheuvel > Link: https://lore.kernel.org/r/20200523120021.34996-3-ardb@kernel.org > --- > arch/x86/boot/compressed/Makefile | 1 + > arch/x86/boot/compressed/hidden.h | 19 +++++++++++++++++++ > arch/x86/boot/compressed/vmlinux.lds.S | 1 + > 3 files changed, 21 insertions(+) > create mode 100644 arch/x86/boot/compressed/hidden.h > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > index 7619742f91c9..b01c8aed0f23 100644 > --- a/arch/x86/boot/compressed/Makefile > +++ b/arch/x86/boot/compressed/Makefile > @@ -42,6 +42,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, gnu) > KBUILD_CFLAGS += -Wno-pointer-sign > KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) > KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > +KBUILD_CFLAGS += -include $(srctree)/$(src)/hidden.h > > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > GCOV_PROFILE := n > diff --git a/arch/x86/boot/compressed/hidden.h b/arch/x86/boot/compressed/hidden.h > new file mode 100644 > index 000000000000..49a17b6b5962 > --- /dev/null > +++ b/arch/x86/boot/compressed/hidden.h > @@ -0,0 +1,19 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * When building position independent code with GCC using the -fPIC option, > + * (or even the -fPIE one on older versions), it will assume that we are > + * building a dynamic object (either a shared library or an executable) that > + * may have symbol references that can only be resolved at load time. For a > + * variety of reasons (ELF symbol preemption, the CoW footprint of the section > + * that is modified by the loader), this results in all references to symbols > + * with external linkage to go via entries in the Global Offset Table (GOT), > + * which carries absolute addresses which need to be fixed up when the > + * executable image is loaded at an offset which is different from its link > + * time offset. > + * > + * Fortunately, there is a way to inform the compiler that such symbol > + * references will be satisfied at link time rather than at load time, by > + * giving them 'hidden' visibility. > + */ > + > +#pragma GCC visibility push(hidden) > diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S > index b17d218ccdf9..4bcc943842ab 100644 > --- a/arch/x86/boot/compressed/vmlinux.lds.S > +++ b/arch/x86/boot/compressed/vmlinux.lds.S > @@ -81,6 +81,7 @@ SECTIONS > DISCARDS > } > > +ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") > #ifdef CONFIG_X86_64 > ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!") > #else > -- > 2.26.2 >