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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham 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 576C9C55ABD for ; Fri, 13 Nov 2020 19:34:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AC8D208B6 for ; Fri, 13 Nov 2020 19:34:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="P6HAc57q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726236AbgKMTeY (ORCPT ); Fri, 13 Nov 2020 14:34:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725967AbgKMTeY (ORCPT ); Fri, 13 Nov 2020 14:34:24 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1F0C0613D1 for ; Fri, 13 Nov 2020 11:34:24 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id x15so5039917pll.2 for ; Fri, 13 Nov 2020 11:34:24 -0800 (PST) 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=z8F0h3EiXSYH2EwQ00yhxQHEYYtz5zW5mBasLaONkpU=; b=P6HAc57qE2Y5UcbYBoRa5r/4fC17b0CPIYGfj09rjoC4y+H+fAssvRyYyO+LgbOh4k 0Avtb8vbC2gKyR8qI/tRiojazj31g/0UjY/wR/h1q1SRtRo5UfFWU8QNqjSzcDtOFMc1 YvgGbbQgMs/h1aqB09iLPlZAjftBRLiyiyivj8rN6vkaGIel6wcEPX0G7g2k5SA1Vqw1 8EQTImjwSSiZKrdYvcvFJ2sPkDrpRJd0ndDLysiqRYfSTDSbDBsm94dGVXlM/UDfdwaX GzV+fgDxCX3U+OubSQkCQ44eJr2p7G0vRobS9xQP47oG7PmbwY4Bo09RNStd63bzeZBt DBTw== 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=z8F0h3EiXSYH2EwQ00yhxQHEYYtz5zW5mBasLaONkpU=; b=PreUenPIQl+bK4WUhwej7EaZa1wogDUUzMVMyhbjUkxrXdVOrgdErb8Dn7ck7RV8IU xB9awSgIL96efxmlDIAWRcNmV3vY0UcGnmTLDwSMmmsGvXZPAVix5SXrZ8hMb1rDYuWc Tk/JDQzBYoes7xDQG1lVcsj+t+XRX0TzQLTxAFepSoyIAEzaf6BRv4onMFCya+syjuuJ 92RKXXDKK34+492Gkvux3OUqMyVySFqK++4ui7DS5Yfn+/QPsFGL+VzJvMzVz99Quy87 bNUKkUfDTH8BzsX8HKta0KiAIu+Ri3mEv8F8Q1oC93j807JpSmDkS8k32lTU5soA/gOH 8PaA== X-Gm-Message-State: AOAM532ydZHMFAoth3eXfXjfYSH+YV/dij1mAS2vfLVmmmbEP5mUrL4s S711iXMS+wku1YjG+lq6JYM62O5NqUIIS6szrFt8vg== X-Google-Smtp-Source: ABdhPJyhopxb7RfHnNVf8DNmtk8myF/2H+M5fzPOJVrVSM9HWXnDlBhQ6V385hHHAXP1h8pNPPVnryqLNySs22r4GZE= X-Received: by 2002:a17:902:760c:b029:d6:efa5:4cdd with SMTP id k12-20020a170902760cb02900d6efa54cddmr3344130pll.56.1605296063135; Fri, 13 Nov 2020 11:34:23 -0800 (PST) MIME-Version: 1.0 References: <20201112183839.1009297-1-natechancellor@gmail.com> <20201113005347.GA3625030@ubuntu-m3-large-x86> In-Reply-To: From: Nick Desaulniers Date: Fri, 13 Nov 2020 11:34:11 -0800 Message-ID: Subject: Re: [PATCH] kbuild: Always link with '-z norelro' To: Ard Biesheuvel Cc: Nathan Chancellor , Masahiro Yamada , Michal Marek , Catalin Marinas , Will Deacon , Russell King , Florian Fainelli , Arnd Bergmann , Abbott Liu , Linus Walleij , Jian Cai , Andrey Ryabinin , Mike Rapoport , Linux Kbuild mailing list , LKML , Linux ARM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 12, 2020 at 10:06 PM Ard Biesheuvel wrote: > > On Fri, 13 Nov 2020 at 01:53, Nathan Chancellor > wrote: > > > > On Thu, Nov 12, 2020 at 04:44:46PM -0800, Nick Desaulniers wrote: > > > On Thu, Nov 12, 2020 at 10:41 AM Nathan Chancellor > > > wrote: > > > > > > > > Commit 3bbd3db86470 ("arm64: relocatable: fix inconsistencies in linker > > > > script and options") added '-z norelro' to the arm64 Makefile when > > > > CONFIG_RELOCATABLE was set to help support ld.lld because ld.lld > > > > defaults to '-z relro' but the kernel does not use program headers or > > > > adhere to the section layout that is required for RELRO to work. > > > > > > > > Commit 3b92fa7485eb ("arm64: link with -z norelro regardless of > > > > CONFIG_RELOCATABLE") unconditionally added it to LDFLAGS_vmlinux because > > > > an error occurs with CONFIG_KASAN set even when CONFIG_RELOCATABLE is > > > > unset. > > > > > > > > As it turns out, ARM experiences the same error after CONFIG_KASAN was > > > > implemented, meaning that '-z norelro' needs to be added to that > > > > Makefile as well (multi_v7_defconfig + CONFIG_KASAN=y + LD=ld.lld): > > > > > > > > $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- LLVM=1 zImage > > > > ld.lld: error: section: .exit.data is not contiguous with other relro sections > > > > > > > > To avoid playing whack-a-mole with different architectures over time, > > > > hoist '-z norelro' into the main Makefile. This does not affect ld.bfd > > > > because '-z norelro' is the default for it. > > > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1189 > > > > Suggested-by: Nick Desaulniers > > > > Signed-off-by: Nathan Chancellor > > > > > > Why not add it additionally to KBUILD_LDFLAGS_MODULE a la > > > `--build-id=sha1` a few lines above? (or `LDFLAGS_MODULE`, but that > > > looks unused?) We probably don't want this for modules either. In > > > that case, you could add -z norelo to the two existing lines with > > > `--build-id=sha1` above? > > > > Yes, I can do that. I will send a v2 along tomorrow morning to let > > others comment. > > > > Modules are partially linked objects, so there is no point in passing > -z options for them. Ok then. Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers More work to be done to boot this config, but at least we can link without error. -- Thanks, ~Nick Desaulniers