Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp917069pxb; Thu, 12 Nov 2020 22:08:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwS5uERUFGtAY77KnciQTrDU4XIi+4jZaAlFJxEJoKTIEf+CjPlDGxiWHUUTJQ2b9lKaO8/ X-Received: by 2002:a05:6402:b8e:: with SMTP id cf14mr895875edb.86.1605247701568; Thu, 12 Nov 2020 22:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605247701; cv=none; d=google.com; s=arc-20160816; b=nc2vsAaXiY271pwBuCZgouhBFes07DFwXvv6io9LWjXTiv3IdSDGF2VlWylOf2ieuS 5OVxr3b4uWjBPS4C58KKUqdrTTwRm52hQ1mx+bzuE6wdrtVYq4xQ6kU/kvv207MDjKVe DPLkgyWgdtvPrMXh1l84RdDSUtfrNSQEQ5mn169290309lhoKuAADYmH/v/fHnQGodaM EtMk/j4Wq7zYRzsSOCW2P88vYjzSmhSpUiLr7XzLx8hbLcQwvBBOgCeIGnH8Aq59m2CY UtXbpGpxg3DvGQyP5ni6raxblsmVYTmdZtUGhoNmjdVq/Ppm8Wh0no8+vP/8CPRrv7ko ujMw== 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=aw75eT7JO/7eCnGy9qZC1ZoRUMcFr5xeBB6pDu4Qfe8=; b=xLY2vqlePWzq7QtERt8ZOAliXmnlLdWDEwFqz4RVjCf7z4nA+Cq+UU95W1xlCrKhOf 2MFFjycHIesuzA+6DeTyrWT7vMRhXYdOoRCHA8Pf12cZda/w7jKn8QA1NjcTCnXEK+Pj 0cT6q+gQQk4WdkxrX2BOdSViPAgSqlKY7/K27DmGJeioYiX0V1d/rdfi3Zg+JC7e/LRm 5NHjSGGwuyKg0FiduuSFYeXpIoIpQURjVtxbiUgizqHwAUa544O5ZXnCeRvxY0ZsbesN fE7AXGTZlmXvdXg448yLFxhmvuvB/NhX/hLTLAOFpfZqHDP+NWJamd580G1isYKOCYoy 2QBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FGg0DF+n; 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 bc24si5594222edb.438.2020.11.12.22.07.58; Thu, 12 Nov 2020 22:08:21 -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=@kernel.org header.s=default header.b=FGg0DF+n; 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 S1726270AbgKMGGU (ORCPT + 99 others); Fri, 13 Nov 2020 01:06:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:57498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgKMGGU (ORCPT ); Fri, 13 Nov 2020 01:06:20 -0500 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (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 B89AB22201; Fri, 13 Nov 2020 06:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605247579; bh=5zkiwx4d0DuFFhv97YB0hnk+AeMXazz8WynYQMIwirQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FGg0DF+nIlkyFf8NhXl8jes6nU7IxqbztQgj8eEe6Nua/K+HSdbgucfYdtpu8b8Rv LgbAWJpdLdg91vmAkoY83Yj1muQxYfwnd7nX4yNktZGzKsjSPyDtsqC7MseKhPI9n2 VeTJGurn6i0uuDR6495e9+IUE03VTymSnCE/kUrg= Received: by mail-oi1-f179.google.com with SMTP id d9so9298434oib.3; Thu, 12 Nov 2020 22:06:19 -0800 (PST) X-Gm-Message-State: AOAM533scAFytMYtQZLB35gkqf7tIZv4w0+50Hh1Zot3ehzhSye/YkK3 Mx7NmWNWbPbbN1+DPPGKM83nKbt2JIEt6eo9QXg= X-Received: by 2002:aca:d583:: with SMTP id m125mr396725oig.47.1605247578865; Thu, 12 Nov 2020 22:06:18 -0800 (PST) MIME-Version: 1.0 References: <20201112183839.1009297-1-natechancellor@gmail.com> <20201113005347.GA3625030@ubuntu-m3-large-x86> In-Reply-To: <20201113005347.GA3625030@ubuntu-m3-large-x86> From: Ard Biesheuvel Date: Fri, 13 Nov 2020 07:06:06 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: Always link with '-z norelro' To: Nathan Chancellor Cc: Nick Desaulniers , 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 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.