Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp135749pxx; Wed, 28 Oct 2020 00:11:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCsW9iwVdCXm88v9r9GZhVd4h81wRqKreJVFC/vj3Rf71WNlLNw5A3jfTrl0HEDN36HQp6 X-Received: by 2002:a50:fc85:: with SMTP id f5mr6478511edq.187.1603869101874; Wed, 28 Oct 2020 00:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603869101; cv=none; d=google.com; s=arc-20160816; b=R63XAFErSNjWhKMb8g5kpb4eThID03Xgv2shk3kxFWWJACGCU8Pq1ehmDp4SVvYDEs 4TCDexsKwqRqlMckLjzFbi2oJaSN+pJPClIv/jZrDPBhcQhZPo1+iUk4FDRMlpWGWUSX Cw3rdYnOaSDXZegDRuHjI42sNO/Tj+EmnIJiA3A8sctvwrz8ROIktQt6Xs+IeOfcxJwn vXPK7/5oAXBEzoJmv5mbYbWd7falMilW1H0yKRDJVO3QP5kV4VR1EoYtjdSUFrYtGOcn 8QtosweVmeGW4Jz9Dwx5iib1/BZ7zBKBqEOZ79hjTBp2D5I2voYpBLCX6QTOeo29d8Ym t2lw== 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=btLnpkHf+lqD2YPLwPVwRwI9+/3aDZ18TECCV3YdDSU=; b=squTYmx1YY2oEgJKlqisoM3AbngwtNuXl28vFWvXhVxva3mkssOUt6jRfKaKsJfJDx wbds35E57p8rx9g+4QyOW2OlExZjVoTGxW2G9xlKI6txIk4+SLKDS2ispIVj/NvxngGu ZWcTJvmtM5GXy9cfqi5zRdACWvyGeSXVSVS4QUUloXbKvOWs7lwqaGtMkCgDz7TbJksP KF5qWOQ65GU5iUCByYBugaG0CvCmivP666Ey5p0uK45dB7Wu1GQsFgwn2rJrMh8Ngbck rp/jGonvgzJZFwZR0OsXTWEDbK5FGS2iW6ezwla23T7zBE+xEWyWa851d9WHgx7cx+DH SshA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Go1yw0v4; 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 v3si2766810ejq.157.2020.10.28.00.11.20; Wed, 28 Oct 2020 00:11:41 -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=@kernel.org header.s=default header.b=Go1yw0v4; 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 S2899157AbgJ0LaC (ORCPT + 99 others); Tue, 27 Oct 2020 07:30:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:45006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438783AbgJ0LaB (ORCPT ); Tue, 27 Oct 2020 07:30:01 -0400 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51B7622282; Tue, 27 Oct 2020 11:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603798200; bh=Zy6p8+sSge22tZ6Ol0fxyz4pPaYBH0Xpzov0a0c9eFM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Go1yw0v4tO3ujDXhN6SjKClRzHWR3408QisVWd3P49ylQM4I9od5kXgRGVbYw1V7G /urQQRSeFPehVotDxDlU43CVV5AJICHFidlu9A1CEG/DvWBAzds2pF245XGLJu+kb8 20marS7FYLHZsCEb1tE3W1qHazkIdURXunYBcp98= Received: by mail-ot1-f43.google.com with SMTP id f97so788300otb.7; Tue, 27 Oct 2020 04:30:00 -0700 (PDT) X-Gm-Message-State: AOAM530c1L9f9bs8OJ1PBCDeRzZhgQjYShEnnL4OZrYJGII0MARSMS3i vBbXbK3Eb26Gz/lGTchUrt/NqS+4n1EOWLrsExs= X-Received: by 2002:a05:6830:4028:: with SMTP id i8mr1085883ots.90.1603798199464; Tue, 27 Oct 2020 04:29:59 -0700 (PDT) MIME-Version: 1.0 References: <20200821194310.3089815-1-keescook@chromium.org> <20200821194310.3089815-14-keescook@chromium.org> <20201027100844.GA1514990@myrica> In-Reply-To: From: Ard Biesheuvel Date: Tue, 27 Oct 2020 12:29:48 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 13/29] arm64/build: Assert for unwanted sections To: Geert Uytterhoeven Cc: Jean-Philippe Brucker , Mark Rutland , Linux-Arch , linux-efi , Kees Cook , Arnd Bergmann , Catalin Marinas , Masahiro Yamada , "the arch/x86 maintainers" , Nick Desaulniers , Russell King , Linux Kernel Mailing List , Linux-Renesas , clang-built-linux , Arvind Sankar , Ingo Molnar , James Morse , Nathan Chancellor , Borislav Petkov , Peter Collingbourne , Ingo Molnar , Linux ARM 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 Tue, 27 Oct 2020 at 11:20, Geert Uytterhoeven wro= te: > > Hi Jean-Philippe, > > On Tue, Oct 27, 2020 at 11:09 AM Jean-Philippe Brucker > wrote: > > On Mon, Oct 26, 2020 at 06:38:46PM +0100, Ard Biesheuvel wrote: > > > > > > Note that even on plain be2881824ae9eb92, I get: > > > > > > > > > > > > aarch64-linux-gnu-ld: Unexpected GOT/PLT entries detected! > > > > > > aarch64-linux-gnu-ld: Unexpected run-time procedure linkage= s detected! > > > > > > > > > > > > The parent commit obviously doesn't show that (but probably sti= ll has > > > > > > the problem). > > > > > > > > Reverting both > > > > b3e5d80d0c48c0cc ("arm64/build: Warn on orphan section placement") > > > > be2881824ae9eb92 ("arm64/build: Assert for unwanted sections") > > > > seems to solve my problems, without any ill effects? > > > > > > > > > > I cannot reproduce the issue here with my distro GCC+binutils (Debian= 8.3.0) > > > > I have the same problem with one of my debug configs and Linux v5.10-rc= 1, > > and can reproduce with the Debian 8.3.0 toolchain, by using the arm64 > > defconfig and disabling CONFIG_MODULES: > > > > ld -EL -maarch64elf --no-undefined -X -z norelro -shared -Bsymbolic -z = notext --no-apply-dynamic-relocs --fix-cortex-a53-843419 --orphan-handling= =3Dwarn --build-id=3Dsha1 --strip-debug -o .tmp_vmlinux.kallsyms1 -T ./arch= /arm64/kernel/vmlinux.lds --whole-archive arch/arm64/kernel/head.o init/bui= lt-in.a usr/built-in.a arch/arm64/built-in.a kernel/built-in.a certs/built-= in.a mm/built-in.a fs/built-in.a ipc/built-in.a security/built-in.a crypto/= built-in.a block/built-in.a arch/arm64/lib/built-in.a lib/built-in.a driver= s/built-in.a sound/built-in.a net/built-in.a virt/built-in.a --no-whole-arc= hive --start-group arch/arm64/lib/lib.a lib/lib.a ./drivers/firmware/efi/li= bstub/lib.a --end-group > > ld: Unexpected GOT/PLT entries detected! > > ld: Unexpected run-time procedure linkages detected! > > > > Adding -fno-pie to this command doesn't fix the problem. > > > > Note that when cross-building with a GCC 10.2 and binutils 2.35.1 I als= o > > get several "aarch64-linux-gnu-ld: warning: -z norelro ignored" in > > addition to the error, but I don't get that warning with the 8.3.0 > > toolchain. > > Thanks, my config (renesas_defconfig) also had CONFIG_MODULES disabled. > Enabling that fixes the link error due to unexpected entries, but the > .eh_frame orphan section warning is still there. > Looks like this is caused by the VFIO driver doing nasty things with symbol_get(), resulting in weak symbol references being emitted. Since taking the address of a weak symbol can yield NULL, the only way for the linker to accommodate this is to use GOT indirection for the direct symbol reference, so that the GOT entry can be set to NULL if the reference is not satisfied at link time.