From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABA56C388F9 for ; Tue, 27 Oct 2020 08:37:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64BBB22202 for ; Tue, 27 Oct 2020 08:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2895015AbgJ0Ih4 (ORCPT ); Tue, 27 Oct 2020 04:37:56 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:38745 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2895002AbgJ0Ihy (ORCPT ); Tue, 27 Oct 2020 04:37:54 -0400 Received: by mail-oi1-f193.google.com with SMTP id h10so493654oie.5; Tue, 27 Oct 2020 01:37:51 -0700 (PDT) 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=CPOwLhlXLOT2UZd39wDStOTHkcJ+bIgNaCGTA5V1Xlc=; b=HfOFnHuwmTe/Yk8v+YeF+wpMvQy/FWhZq5DeHoZI6YbXfbtamGoBxCulIroZz+1PKN ur/4RRG2bIGH2UQlZxkZhGGPX9z3wXAJ/1gXyZgpVRQzdm0TbJKnFYOMatIPwRsneV/U ++mnftgLVDRJK9bjOaUiFiD2HzRCtoAOS2XaalxiZYwrpdZ2T263xvFOcFjoNWBCd7S3 evso65ol8brc2jp5DM1tX7DBkMrY/GN++VKI3PrcDtERFAlgRIla877uzfT5U0I6gzhX 768iSS85mXcZPjizCJTYkBGnHJ9HO7UVzoge2X7uma3NpMXESS7GnoW0p+VxwL6tRTqQ M+KA== X-Gm-Message-State: AOAM530lhTvisSi845iSup0L4DDWpNusPv/rpVno4+CgJYlf1Rgknaxj B5nlaEE8u3+2Pna92dqlNg7LZSegEypvY8geAFg= X-Google-Smtp-Source: ABdhPJwaTB2iVr+7OU3MtN9ar0oiQ89rb++59/AFQW7IOWauPeDmlmQaVq9ehknOXiewJFiM95SLhML4FAiQRXDDJOc= X-Received: by 2002:aca:f203:: with SMTP id q3mr657056oih.148.1603787871413; Tue, 27 Oct 2020 01:37:51 -0700 (PDT) MIME-Version: 1.0 References: <20200821194310.3089815-1-keescook@chromium.org> <20200821194310.3089815-14-keescook@chromium.org> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 27 Oct 2020 09:37:37 +0100 Message-ID: Subject: Re: [PATCH v6 13/29] arm64/build: Assert for unwanted sections To: Nick Desaulniers 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 Hi Nick, On Mon, Oct 26, 2020 at 6:53 PM Geert Uytterhoeven wrote: > On Mon, Oct 26, 2020 at 6:49 PM Nick Desaulniers > wrote: > > On Mon, Oct 26, 2020 at 10:44 AM Geert Uytterhoeven > > wrote: > > > 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. > > Yeah, I noticed it's added in arch/arm64/Makefile, and verified that it is > actually passed when building kernel/bpf/core.o. > > > > > > > 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, will give that a try, too. Commit 3b92fa7485eba16b05166fddf38ab42f2ff6ab95 is part of v5.10-rc1, so it was already included, and thus doesn't fix the issue. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A032DC4363A for ; Tue, 27 Oct 2020 08:39:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 40E5422202 for ; Tue, 27 Oct 2020 08:39:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="j/QFaD2w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40E5422202 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+K+uLuohpnw4EhbWZY6p6qpOoqxkLu+Ts9V1I/N5XMc=; b=j/QFaD2w/hXkpDsp6R9R/vdKL 5UXjk1iPjwYZ0TyyOqkhrqrZWySDFpcQrJJXv4t2naF5h70tJRUhK330b6tE9uC8F5o7IrD6hmSS2 uVERW1qESbd1V7krSMWsBsULvCDCQQJeJ8LVTp0pVtGkaE35B3ZZz/yHl3djyJsZanTc6vHCx1GeC RF6dQRWXhktc/qIJoZKgxorpm8eJgkcfRXwRY3OcypAjyu5lz1hqIHZUIoQDyrtwuuhxzsMsHp5cm elw4QaQgdvRMMtvdaKYxKDZ2/YxfdQWaaOoEZx6i62t75kKPKBcMr6JXu5xxtpYDGtSlSERLN0B4s 1wvSAv3bg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXKUQ-0002Z7-6A; Tue, 27 Oct 2020 08:37:58 +0000 Received: from mail-oi1-f196.google.com ([209.85.167.196]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXKUM-0002Xa-Ne for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2020 08:37:56 +0000 Received: by mail-oi1-f196.google.com with SMTP id y186so501216oia.3 for ; Tue, 27 Oct 2020 01:37:51 -0700 (PDT) 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=CPOwLhlXLOT2UZd39wDStOTHkcJ+bIgNaCGTA5V1Xlc=; b=Pw390ydngINLzvLFNf1IuyFBgbW9tQUpR70OhlG7oPw8AEb+ZYofu4fwL/Nk0ik56t UAZo2Zb7P1ElqIOeKriVtDEpeMPlql8EOejKUTEhvUhWk9e+I5V7nHohomfXVqimpF99 B4WaCep3NNOK7iTGK9GBl8J78Lho4xCvB+6JU/AIELGeZG2rIadAu344RBZG6jqvK4Rf dUwdSggSTdwkvKlSsAFkIn1oay0nkPSoOm+dZd2myVqbjbl+X6lG3AAtu7oqrXX4W9C7 4pdc/x3f8wjDg9doXtCC+YRbosEL2qLAA3qvT97dYViqe+/QTsepiVTbPXPGGObwdv13 bTCg== X-Gm-Message-State: AOAM533iwRMST3HqUmdIibWv1wN2Q289iJQSF/dnVR3WjCNtSZvarTpJ ERXPqUeNY6hmwK5UaFecqj3Kjym5AFUViOcLnIM= X-Google-Smtp-Source: ABdhPJwaTB2iVr+7OU3MtN9ar0oiQ89rb++59/AFQW7IOWauPeDmlmQaVq9ehknOXiewJFiM95SLhML4FAiQRXDDJOc= X-Received: by 2002:aca:f203:: with SMTP id q3mr657056oih.148.1603787871413; Tue, 27 Oct 2020 01:37:51 -0700 (PDT) MIME-Version: 1.0 References: <20200821194310.3089815-1-keescook@chromium.org> <20200821194310.3089815-14-keescook@chromium.org> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 27 Oct 2020 09:37:37 +0100 Message-ID: Subject: Re: [PATCH v6 13/29] arm64/build: Assert for unwanted sections To: Nick Desaulniers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201027_043754_881545_2340041E X-CRM114-Status: GOOD ( 37.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Linux-Arch , linux-efi , Linux Kernel Mailing List , Kees Cook , Arnd Bergmann , Catalin Marinas , Masahiro Yamada , the arch/x86 maintainers , Russell King , Ard Biesheuvel , 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Nick, On Mon, Oct 26, 2020 at 6:53 PM Geert Uytterhoeven wrote: > On Mon, Oct 26, 2020 at 6:49 PM Nick Desaulniers > wrote: > > On Mon, Oct 26, 2020 at 10:44 AM Geert Uytterhoeven > > wrote: > > > 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. > > Yeah, I noticed it's added in arch/arm64/Makefile, and verified that it is > actually passed when building kernel/bpf/core.o. > > > > > > > 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, will give that a try, too. Commit 3b92fa7485eba16b05166fddf38ab42f2ff6ab95 is part of v5.10-rc1, so it was already included, and thus doesn't fix the issue. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel