Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1399043pxb; Fri, 13 Nov 2020 11:36:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFLMzvYjzQN+zIZ5yMXed+//tI1BzcYE5E+Mgcw8mRZ7MacSxolX0zf4c6hvPtP3Yq3Giv X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr3638592ejf.11.1605296205403; Fri, 13 Nov 2020 11:36:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605296205; cv=none; d=google.com; s=arc-20160816; b=gEWwYwc4Th8nD+bR+3MPgkJIYOlc+8XbOP0xwRM9Yzb8rXRKoJiGOzKArnb5ClU6Hl 4wleNXAsUBzaAdfHTtlDqmp/aXDMPV57my2Tkxnl/t3/ObptvjY+4kCC02rCpRa2lX9i dkOdsaB/HEd66IB3eRkjo1YI9iY+jJ5fVe/hGJfY7PIb5rQYKSH/J5q3mqEigQ70PAYA cMXk6AF2bcuV0VTKYvb5AnyZJhK7vRTlEmDWvefYXHuJPbeW++XNFc2n883qE7mnU7nC khRzOqqnE4ravW/KoQ2dmvmpKA+QE22goLhsxb7CAW+1gHvl/uVeFcSY5L3nDYIFHBZf MqFw== 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=z8F0h3EiXSYH2EwQ00yhxQHEYYtz5zW5mBasLaONkpU=; b=LmXjKXMNs8rDR7f/qiIPCQtLuLy/6hXv3ncMlfPhJJBPtdZfi0tb4FN+aUl8ls0F58 tUfopDxOSaug6bgy0COK2CbR7KKpZXaH0UV4kAGOFIdNDL6oBS8xXKtucaPF9DrXv4oj fOQjqoiXk/rz6jJfGZENta5IxQY8AJS+sV/7NMQIN1Bv9w/qQeJ8ioyCOEq/6BBmt2OR JqWAVcsjJcSqFkWmPHDN/n1avlif8zkDeqUvT3CmeXOpJ46ujyMNMUmYK1tzouobtREb pHFASu3ypmmgpNjNJ3yVixY6zd9Z8IgBKpg9iqUXag4dMEG3LV4pLs4rg3Xp9CHBsUTr GHiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=P6HAc57q; 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 i13si6593187eds.459.2020.11.13.11.36.22; Fri, 13 Nov 2020 11:36:45 -0800 (PST) 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=P6HAc57q; 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 S1726090AbgKMTeY (ORCPT + 99 others); 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-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