Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp134350ybt; Tue, 30 Jun 2020 16:28:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4SowbOqhxoJi8EBBSpBW5rYmdVDqu1r8/LgHdy6OP151jbykqa7S6QeqMcmWSL8aqh0Kv X-Received: by 2002:a17:906:6d0e:: with SMTP id m14mr20115160ejr.251.1593559727878; Tue, 30 Jun 2020 16:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593559727; cv=none; d=google.com; s=arc-20160816; b=eVHGNhY98fBX/RjtzXE78tPGkYwP/xses/yWfSXriiBUTYNIGkghmcUiepQh12BKDY RYIToyQ/ukEb45PF3K5c9QUXMK7BGjczrX7Z2aaVz1d0bK84ktVlnnpLRwba4RXlTOEZ giFHgyTOXxW3D6p6he2BVv0zAQ8IqX3wqbhjGnUder5iheXyN7kJ7ouqsFbCvSiC++4c 4I6WewdTHi5hCXd06CeUTPQBUiaKihmFoHxslPaC/geDHLCOCKEMMvOMj+gs4B5lYh4d 8dsbseFY1dWHAS3SCwOLmyW0fx0hyOjaVo//KQS7UxaxPB7/IBk5l5uWhK2Qmj1OM9pu 6EvA== 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:date:from :dkim-signature; bh=iirypFBp2xtegwS2Iq4B1iPUgMABexUaf6RMKakBSKI=; b=OHqie25IRXoqxoWKgtMQakX+X88kaSn9lEy3uC1x/RIAajeix9VX2i9GR/4ZkEO2k8 j/w0NHKTDQmyvKz+rMBDrcd78i0VyG0KIQUS5KA3lw72NoRGXJ9YOPtfgSU6n81aMkWd 206k1hnLVFAXt6CG7b9wPAxpEu+vNvnuwxm347HO+kWgFSbLO7NdpfC0Hx7OEqsgV8J5 HSZabxCtLkxl9URo0M/TwuWOSoon+Hneu4sjXwN93OAMuRfsnQRD6iyulnVK322mZaLy p5CSA+jR6IYieyMUQD4aD9J8lwZU8BDNXm5mFTg1Hdi5fXvUXtt3b7LYjXp/wzH5RLny J4XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=D+w4anAV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si2661105ejk.407.2020.06.30.16.28.22; Tue, 30 Jun 2020 16:28:47 -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=D+w4anAV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726186AbgF3X2D (ORCPT + 99 others); Tue, 30 Jun 2020 19:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbgF3X2D (ORCPT ); Tue, 30 Jun 2020 19:28:03 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C826EC061755 for ; Tue, 30 Jun 2020 16:28:02 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id c139so20417281qkg.12 for ; Tue, 30 Jun 2020 16:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iirypFBp2xtegwS2Iq4B1iPUgMABexUaf6RMKakBSKI=; b=D+w4anAV9FqpiC8o3zpYnCH9ve8Tz0CdVll9wHtzOiCDDAZWWgSfDolrIa+ceJvU+y EWtPGt9GK0Eg56kfb2X3t8Xj7kzm9nLcgwKr8zlWkRE/fUP+RDaAk4QD3iMU4Oi/IAXG dGbgfTBrlhi3c9aLE6INbEnFr8lWSXaDpdMQ5g6JSZYUUG6LbXpX496c41z48vDLMRXh Y3CiV775LOD8komjPGlDaV1pJKecdBr4LohTHFmv3wNs7pS/krHJlawVB2jMZUmHOeOu LxbKeErT2KLqfvA5rNdaoIdsmAVvtcjFR2e8Jr2tedwCHuC5aMdU/5Md+gVyNo+/5N9R EJCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=iirypFBp2xtegwS2Iq4B1iPUgMABexUaf6RMKakBSKI=; b=NPr4wKr9H9yihK/b8av29b97Jr5Y94717h2vd3wUGCM6LghsJkyCHNHPm/nQxenZSl D4YLCcURINesQzfUC1hDUgxpXGycy5tZqeW31YtuvbmorzQecbkDr4jj0cpJE/6X3sSa 5IfAtodMNNeg9CNp25R+hv//tBXRnz9LgpyPCxYxho6NI1FqV1odcnitHxtrHkEtn3Gt S3yRTtl9cnIJQwkDniyR0EOSN6LQFGLoWweijLN7JM2xBWxY2/N1IMmUu0abUWR4RdEb 8uDunmFqWx1uskUagPi24wCFDLL2+ZBaokNzuEJHDkIbA1oDLi9qmpxncEMEIpGT4l5h 8NUA== X-Gm-Message-State: AOAM533XAd/6+oDpcrQJSsHvlPWK8VVlvydqPX53S8hmSyTL6itAhmAi lgSUDPcCe4mKdnfT9/m9FGc= X-Received: by 2002:a37:4c0d:: with SMTP id z13mr21851974qka.170.1593559681849; Tue, 30 Jun 2020 16:28:01 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id x13sm3868567qkx.10.2020.06.30.16.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 16:28:01 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Tue, 30 Jun 2020 19:27:59 -0400 To: Fangrui Song Cc: Arvind Sankar , Ard Biesheuvel , Kees Cook , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , X86 ML , Nick Desaulniers , Dmitry Golovin , clang-built-linux , Masahiro Yamada , Daniel Kiper , Sedat Dilek , Nathan Chancellor , Arnd Bergmann , "H . J . Lu" , Linux Kernel Mailing List Subject: Re: [PATCH v3 7/7] x86/boot: Check that there are no runtime relocations Message-ID: <20200630232759.GA2641539@rani.riverdale.lan> References: <202006290907.E5EF18A@keescook> <202006290919.93C759C62@keescook> <20200629165603.GD900899@rani.riverdale.lan> <20200629173735.l3ssrj7m3q5swfup@google.com> <20200629233405.n56yb4xwlgxrt3fn@google.com> <20200630175408.GA2301688@rani.riverdale.lan> <20200630220043.4snabunhgvfdktte@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200630220043.4snabunhgvfdktte@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 03:00:43PM -0700, Fangrui Song wrote: > * Ard Biesheuvel > > On Tue, 30 Jun 2020 at 01:34, Fangrui Song wrote: > > If the executable is purely static, it does not need to have PLT. All > calls to a PLT can be redirected to the function itself. Some range > extension thunks (other terms: stub groups, veneers, etc) may still be > needed if the distance is too large. > > There are cases where a GOT cannot be avoided, e.g. > > extern char foo[] __attribute__((weak, visibility("hidden"))); > char *fun() { return foo; } > > If foo is a SHN_ABS, `movq foo@GOTPCREL(%rip), %rax` can't be optimized > by GOTPCRELX (https://sourceware.org/bugzilla/show_bug.cgi?id=25749 binutils>=2.35 will be good) > Many other architectures don't even have a GOT optimization. Urk -- the example given in that bug report isn't even weak. Are you guys proposing to pessimize every access to a global symbol, regardless of visibility, by going through the GOT on the off chance that somebody might define one of them as SHN_ABS? Can we at least gate it behind something like __attribute__((might_be_shn_abs))? > > >I don't think it's really relevant for the kernel build -- all we get is > >ld -static --no-dynamic-linker, all -static does is prevent searching > >shared libraries, and we already pass --no-dynamic-linker if it's > >supported. > > > >[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81498