Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp384023ybs; Sun, 24 May 2020 08:14:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyK9GdONEUmFxyPgKOV1P0UbZlTKERtFvS6xDI9wtD0cnHFqrvQVfsf6Tkc2/f8S0mecNE X-Received: by 2002:a17:906:68d2:: with SMTP id y18mr15990891ejr.248.1590333266685; Sun, 24 May 2020 08:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590333266; cv=none; d=google.com; s=arc-20160816; b=uVVo03/oMMYM8uNdzJU10aS5hAeTtlz8NLZND2pDba1uYSkzeuk4rjfq+g0JwIhZTH CvlScyVWNSn6FcGVMNDmQ5iTInp5yBBUQ8Bz9FJI29uGdOYDTXKWlOarMkUzCYxaGzwH XyOAOLJ9cW3Ww96jhTq5U3bh/2to1J4BxEBfUNXrmSYk4m7kjrtMH3Xh+FDEdKplnYaO 3uCeqAySyNyfEFOTCxA5T/jY1alSd1GQwuKdZH5xAXCcUoydpJ/9RxRJHUTO1qUZzsfv 9Cu+/ZZxKgbNjJr60RANoO+zw9jKd5y/h473DneDSL1qjGqJZb777XFCK3+80Kpym9lU ir4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=wX9254Tawo97HEIC7Lik11yES5ykzHmRr/c4BRavRG4=; b=yUi9fO+E5IkY7rlXMTe7q1l8uUFjNH1l7vCViRClQ6dR3Eo49FsZBN3tFxS5At4T0z pZLRUXUbs53Lw+HM08rsCUbY3cqmHlmU5trEHA08aoVtRWROxfq4gnmmu8doQhCoCIN0 M/SOl7PUw44lggI3wsP3EQzlwCRZ0EwPDvh0tpgFAWKOMbTVE03X0jhcLXA8Mj8xqZ7O kNTDKL1b13JbkOFkuifZlrhrI+PE4RKrW/uOar5cgB+NIpVQHls1OIWWmstziKh9MK2d 8hKdUxuZvH3cllmMAb+ldZXssi85VnWCeHr1Ngrzy6zQ/3dMu4LlbCUzibe5+FLcGYtM beOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VbTvtDBZ; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si8022844ejr.36.2020.05.24.08.14.04; Sun, 24 May 2020 08:14:26 -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=fail header.i=@gmail.com header.s=20161025 header.b=VbTvtDBZ; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729913AbgEXPMT (ORCPT + 99 others); Sun, 24 May 2020 11:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbgEXPMS (ORCPT ); Sun, 24 May 2020 11:12:18 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE7DC061A0E; Sun, 24 May 2020 08:12:18 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id s8so14872709wrt.9; Sun, 24 May 2020 08:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wX9254Tawo97HEIC7Lik11yES5ykzHmRr/c4BRavRG4=; b=VbTvtDBZ8GtfGdhGNl9ZbgfjN+8ZMPeZhRIOmU2rNB2QGpNcrRkm4ZCx/4AwvTPEdE p2aDPjU6EGMMykr5sdWnikPgpz8BKiOBbC70Z+fSpEjVuBGs75Y5qdui6StVFbMo2AcU eDMNX/FdBcqQhgUJImiQdr9h0fyYSbOebt66IqvlINHbULWH+/MW7yE0mEEa41oYKTUW pPMekQ3zN4uTZDaQZG5/6JC/oU2HePzktyRkyHR3U5vY+wbt7ffdJLz5mk7VRAjlFLxO dpDkgheWcRfg6l94rQBvTvF+lNDf4PU+o1zjWkCwUa+zJJxF3iCUbyOTOoEIFvOkb1Kj 9ZsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=wX9254Tawo97HEIC7Lik11yES5ykzHmRr/c4BRavRG4=; b=GAri0p9i5uYXnU7EVDSh58/2QT3ik7ktBYGXba5J94MxiNhGAn95hf8r8EKK5WjLV/ DlLhuPHLQtV15ajQtciSV5axpoZF6pZapaSecZYRHP/yFA/wH1DWM7pIMiAEh393S1ph 4kizFsBBFMbE2WPAw9Ws28yNZsaAnjmIQFQjpOjiOeHsT1G3c+KPYTEejZcSgkdLJBSd FgQeHoSSqHJLr2Zka1R6ii+JpWW2CzuyK4J2BWKXPks645e3QofjS6ND1y3+Lpf1ShFy aKE2Jv+B1ruH2JvP7tIhdZtSfZFq3KznegKMMrKc5Yg2pneIewfagxo6/Hsi7X9o7GPE UyDQ== X-Gm-Message-State: AOAM530n3hRKg9QVgx4L7ivo6N8t9c53gkVJQ1gCBQwQkwmGWr6swQNh HFbgoKKKqyW28vnn+MAqd6KzQQSe X-Received: by 2002:a5d:628c:: with SMTP id k12mr3818773wru.211.1590333137310; Sun, 24 May 2020 08:12:17 -0700 (PDT) Received: from gmail.com (54033286.catv.pool.telekom.hu. [84.3.50.134]) by smtp.gmail.com with ESMTPSA id l18sm14911160wmj.22.2020.05.24.08.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 08:12:16 -0700 (PDT) Date: Sun, 24 May 2020 17:12:14 +0200 From: Ingo Molnar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Maarten Lankhorst , Linus Torvalds , Arvind Sankar Subject: Re: [PATCH v2 2/3] x86/boot/compressed: force hidden visibility for all symbol references Message-ID: <20200524151214.GB11617@gmail.com> References: <20200523120021.34996-1-ardb@kernel.org> <20200523120021.34996-3-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200523120021.34996-3-ardb@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Ard Biesheuvel wrote: > 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. > > Signed-off-by: Ard Biesheuvel > --- > 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(+) > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > index 5f7c262bcc99..aa9ed814e5fa 100644 > --- a/arch/x86/boot/compressed/Makefile > +++ b/arch/x86/boot/compressed/Makefile > @@ -40,6 +40,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 hidden.h > + * 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) BTW., how many such GOT entries did we have before this change, on a typical kernel? > +ASSERT (SIZEOF(.got) == 0, "Unexpected GOT entries detected!") s/ASSERT ( /ASSERT( Thanks, Ingo