Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp602736pxx; Mon, 26 Oct 2020 16:33:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqawxctEt55NG01YH60JuGVT+7NwAkyn2FR/0QmRdG1EqyrQLKzqh3nrHH9sj4M/bRLawl X-Received: by 2002:a05:6402:195:: with SMTP id r21mr17966496edv.164.1603755193967; Mon, 26 Oct 2020 16:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603755193; cv=none; d=google.com; s=arc-20160816; b=LUYmSe5+i1MH2ruDkCfjRq398nOZID4+WYmanZzvpq4nt94ZgNfcKq4UhMQICeISZ6 uZ4JgvlcSz1zA+KBm6AtgClLnAlN5SL1DIND/MFF2wjLAU8uOASRFj/S6NPZQwjGMANa tkKKjHLuAY2+CrjAhkth3i9IsODL74Ddl0pUzXSpyD3Jett6pq0Rpb6vxDiFNLgZmFCI 34J1AGrrW2GlQ+Tm+cqUadyYzi3QAfy+MGwQ1khOx4aE2k/pEILlShiCroQZQb/+2xub 43NLAXWIXJvSPI2wkQWJsE9gnoAPb+QY21YUG7PCfdlCM8kNEvtmdQKIHe9ornW9s1ln KJCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w1/6VKuaxtnOQSh9u+GNtF0PEm0CXIxJ72v1J6ceCSU=; b=lkVK5coCCRDPGg2plCQnX/TQVmhDrU3QAiV0hcOogq1Yya/L4D0100ys0nDVZBoe08 nUJ1qtPMMHkDBsnQtv46eCnLDBcrge62IxBxoITj5zJqZIG0qS17M/LjNQO4cK3XZ8iR oTtQqKKZmLybjknglT4yYUaVL8Py6+nYxeQjR/zBU0dbXV/URRaRvH4gLaRZwWIO77Jv 4Tvm5b4SvVQrJ/F8jb4zAA21f8K176UA0PD8FMutAN/B0Htef2CcIKAPJzWP9uIJwT1Q dTYtl0Rs0wcXqmha/2XrtGwG9kBmgAPxj+XY87lZc3NslnQuiTANS0fo2gp2X4ni9xb8 YY+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=NDuAWgRk; 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 gb8si7918310ejc.394.2020.10.26.16.32.51; Mon, 26 Oct 2020 16:33:13 -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=NDuAWgRk; 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 S1780280AbgJZRtI (ORCPT + 99 others); Mon, 26 Oct 2020 13:49:08 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37495 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1780225AbgJZRtI (ORCPT ); Mon, 26 Oct 2020 13:49:08 -0400 Received: by mail-pl1-f196.google.com with SMTP id b12so2730560plr.4 for ; Mon, 26 Oct 2020 10:49:06 -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; bh=w1/6VKuaxtnOQSh9u+GNtF0PEm0CXIxJ72v1J6ceCSU=; b=NDuAWgRkWwi1znQBu90iZu25Zkc7g4j7Dy4U6gZntjNVYEVVAArppw0Wi1Vm6zNmEZ dKlOldrTTTzdi0GigaEr83YkpSyOFsCGQ8Jnq7tSOC/wz/HQKn6tqEg+1ZD18p9NYKXT g90cqjJ6/HYh67A7UVrq9VnosfDXBI90TNp5kJ6RZb5Rv300x9WQuLOpKmY2fesnahm3 jKAxyT2+vhK2JHEFYnJslrnhS76v03weyNqpNa3l+h37oBNdtWxWs3PUpHnvO6UhFPUf sKAZp4V8UksMOrhiVishvBVNK2P7wPd8IwSlPqJ4tNPDxV+wzb8/JODamjtTG7D2SYp+ ShyA== 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; bh=w1/6VKuaxtnOQSh9u+GNtF0PEm0CXIxJ72v1J6ceCSU=; b=RrGfUYfb7aHcAdHVYhpkzeGXrdHa7ddj/v7L6v/jQbpWriS4xC/LjifrCWTcjD2MS4 uIRVmbT/PCGQC4FnNP0rZ3hEOn6f2xXVqFPyPgs5iZSDs7NTDTBTQLj1Vv3lkzTx74XG ffc4/WIE5SYwLUVdfwCyg9QBkwk71kwzj/nl3Bn7n+cz6t5Yn9wet3R3RGU3ED7cG6wW Db5ru2D7vQSEjJn7ZOzReFg9XauOcub5uHJflUXw6iSw2L+sZj/2EjatPyS30CjxF+Sv 03dykYDfaJV6NYJRAAiwoObQyHlw0jPifYi+PA/AltQzh0pazgFo8D+I8G2OGOibqn9b 3q0g== X-Gm-Message-State: AOAM533bRGm/USUcWgsNRYwVq+RRH0MxwfqBlI/w7KLwx06tiY8Hyhy5 vrkAaugr/NnXWFkn3geooQChu1/cO3xAWcTGsGBe5Q== X-Received: by 2002:a17:90a:6b04:: with SMTP id v4mr21709795pjj.101.1603734545479; Mon, 26 Oct 2020 10:49:05 -0700 (PDT) MIME-Version: 1.0 References: <20200821194310.3089815-1-keescook@chromium.org> <20200821194310.3089815-14-keescook@chromium.org> In-Reply-To: From: Nick Desaulniers Date: Mon, 26 Oct 2020 10:48:54 -0700 Message-ID: Subject: Re: [PATCH v6 13/29] arm64/build: Assert for unwanted sections To: Geert Uytterhoeven Cc: Ard Biesheuvel , Kees Cook , Ingo Molnar , Catalin Marinas , Mark Rutland , Peter Collingbourne , James Morse , Borislav Petkov , Ingo Molnar , Russell King , Masahiro Yamada , Arvind Sankar , Nathan Chancellor , Arnd Bergmann , "the arch/x86 maintainers" , clang-built-linux , Linux-Arch , linux-efi , Linux ARM , Linux Kernel Mailing List , Linux-Renesas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 26, 2020 at 10:44 AM Geert Uytterhoeven wrote: > > Hi Ard, > > On Mon, Oct 26, 2020 at 6:39 PM Ard Biesheuvel wrote: > > On Mon, 26 Oct 2020 at 17:01, Geert Uytterhoeven wrote: > > > On Mon, Oct 26, 2020 at 2:29 PM Geert Uytterhoeven wrote: > > > > On Mon, Oct 26, 2020 at 1:29 PM Geert Uytterhoeven wrote: > > > > > On Fri, Aug 21, 2020 at 9:56 PM Kees Cook wrote: > > > > > > In preparation for warning on orphan sections, discard > > > > > > unwanted non-zero-sized generated sections, and enforce other > > > > > > expected-to-be-zero-sized sections (since discarding them might hide > > > > > > problems with them suddenly gaining unexpected entries). > > > > > > > > > > > > Suggested-by: Ard Biesheuvel > > > > > > Signed-off-by: Kees Cook > > > > > > > > > > This is now commit be2881824ae9eb92 ("arm64/build: Assert for unwanted > > > > > sections") in v5.10-rc1, and is causing the following error with > > > > > renesas_defconfig[1]: > > > > > > > > > > aarch64-linux-gnu-ld: warning: orphan section `.eh_frame' from > > > > > `kernel/bpf/core.o' being placed in section `.eh_frame' > > > > > aarch64-linux-gnu-ld: Unexpected GOT/PLT entries detected! > > > > > aarch64-linux-gnu-ld: Unexpected run-time procedure linkages detected! > > > > > > > > > > I cannot reproduce this with the standard arm64 defconfig. > > > > > > > > > > I bisected the error to the aforementioned commit, but understand this > > > > > is not the real reason. If I revert this commit, I still get: > > > > > > > > > > aarch64-linux-gnu-ld: warning: orphan section `.got.plt' from > > > > > `arch/arm64/kernel/head.o' being placed in section `.got.plt' > > > > > aarch64-linux-gnu-ld: warning: orphan section `.plt' from > > > > > `arch/arm64/kernel/head.o' being placed in section `.plt' > > > > > aarch64-linux-gnu-ld: warning: orphan section `.data.rel.ro' from > > > > > `arch/arm64/kernel/head.o' being placed in section `.data.rel.ro' > > > > > aarch64-linux-gnu-ld: warning: orphan section `.eh_frame' from > > > > > `kernel/bpf/core.o' being placed in section `.eh_frame' > > > > > > > > > > I.e. including the ".eh_frame" warning. I have tried bisecting that > > > > > warning (i.e. with be2881824ae9eb92 reverted), but that leads me to > > > > > commit b3e5d80d0c48c0cc ("arm64/build: Warn on orphan section > > > > > placement"), which is another red herring. > > > > > > > > kernel/bpf/core.o is the only file containing an eh_frame section, > > > > causing the warning. When I see .eh_frame, I think -fno-asynchronous-unwind-tables is missing from someone's KBUILD_CFLAGS. But I don't see anything curious in kernel/bpf/Makefile, unless cc-disable-warning is somehow broken. > > > > If I compile core.c with "-g" added, like arm64 defconfig does, the > > > > eh_frame section is no longer emitted. > > > > > > > > Hence setting CONFIG_DEBUG_INFO=y, cfr. arm64 defconfig, the warning > > > > is gone, but I'm back to the the "Unexpected GOT/PLT entries" below... > > > > > > > > > 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 linkages detected! > > > > > > > > > > The parent commit obviously doesn't show that (but probably still 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) > > > > The presence of .data.rel.ro and .got.plt sections suggests that the > > toolchain is using -fpie and/or -z relro to build shared objects > > rather than a fully linked bare metal binary. > > > > Which toolchain are you using? Does adding -fno-pie to the compiler > > gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) from Ubuntu 20.04LTS. > > > command line and/or adding -z norelro to the linker command line make > > any difference? > > I'll give that a try later... This patch just got picked up into the for-next branch of the arm64 tree; it enables `-z norelro` regardless of configs. https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?h=for-next/core&id=3b92fa7485eba16b05166fddf38ab42f2ff6ab95 If you apply that, that should help you test `-z norelro` quickly. -- Thanks, ~Nick Desaulniers