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=-14.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,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 20526C2D0E4 for ; Fri, 13 Nov 2020 00:45:30 +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 9E1C621D79 for ; Fri, 13 Nov 2020 00:45:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eZg+9+qp"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="jVu4e1Sp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E1C621D79 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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=XFfbHFMg9OZIcgzYo7YthFWabfX751Wx25Ccv/z0xTc=; b=eZg+9+qpNFHGYqnPQI11kp2r8 qZRiRvLXA0YLxJh7HU2SZAjc9sRWUuVloI9k+KZd1+XoxgftXZ5/OtTa/RAcnqpMDbmh+VklBLZDE UUNW0DFYZMtn+n561biKlhfjL62tw94nHUuD4URbq4SeaiLIO0j+DI1U9eeClRJ1hiAOD0V2SQREw UiotuQRVRVmaMOEbtl7jeNKM048t8ghLIe+cYUGe8o8m2M3vTX7EJRcTjWB8PUwCU8paNjVZaLXtH lSYQ3ZFAnKoLpWXd729cKLJdJcM9by+iwH8RL17w12Ka8noKUQ0R/N2xxm07XnPXoc/0fB08CkFZL 3BUYhOWbQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdND4-00040q-Ni; Fri, 13 Nov 2020 00:45:02 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdND2-0003zu-12 for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 00:45:01 +0000 Received: by mail-pf1-x444.google.com with SMTP id a18so6144207pfl.3 for ; Thu, 12 Nov 2020 16:44:59 -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=uPz0VNRgAU6deAyeUwvHx8BA1S/DOt0Kxt6fec1P47Y=; b=jVu4e1SpPT8q2ZSLkXlUchM4CAK+7CacjDt1JACHjvW3bNh3Jw0OxOWHELqcqv47hV h8wN6iQfU66pciPEgbgT1chLXIf9cRIZskLq2NrJWCPuY+/9tirTRRWs6PwUkwwhg8yM C1A21Zo+dbuBqJVJlG/IvsQPjDiOiuFnD3chj0Of9bMEy1Q1/BhakuQYfRecPXacg6w6 JsKZn7CFQzRwglZdBGIh0eEEvRcSzvGlllD96QpxYfT/Vb1xifRy1Kgo1x7m89VvDOUR i4V4iiFbJdTUWMEvpxuWuG6pPz/WWDJxuqqEfz5/NaC+1f2PwZkAtBA4e3t3/FAS6bp/ DWIQ== 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=uPz0VNRgAU6deAyeUwvHx8BA1S/DOt0Kxt6fec1P47Y=; b=qX0rugsYvB9AjNshFDoNmLdvFUOAFFRCVRk/hZAh0REw2f20Vox4iF6veuzUInYGTY xDi9/JbHVDLwwS8QQkZBx+jTjtebUqbvMs/IbvhsL8tFkYsvynfziDIoXIlbOPUp7LHO tAJiBNUKyS3yY/tzjDTPmq83kvUmJf/9WPK3bxOYnYpUa+MVlEGjwR6JodOuZk9FH8KD R94h3TJ2fAq8/+NddY1B1xIYwpydiwChfsxAYu+59L41KLGaxCzOR44Y4EAYP22T5wVC VQrYsF40X26dOeoS88Sfw2xe5rkQ9oOLNJIro/cQNi0v56/KUjGRY5HjaAtHwGPOJfZM GgKg== X-Gm-Message-State: AOAM532DCZrRsYFSNdC0cYGw5BMb/4TGYnqfYK5f+D7W/L3PblNIKBc2 EcZZj5ksM96phibNX0o4NQZoujFCfBFvDvB6q8XVLQ== X-Google-Smtp-Source: ABdhPJxGes8jw96mSloaUfHwfGTOota16TXwD/Vk/8CX5nUzF9zDdKv5unc+Ykk2kcWi7/EBCVvv5iWQLVXMiEeSDhk= X-Received: by 2002:a17:90b:110b:: with SMTP id gi11mr457122pjb.25.1605228297498; Thu, 12 Nov 2020 16:44:57 -0800 (PST) MIME-Version: 1.0 References: <20201112183839.1009297-1-natechancellor@gmail.com> In-Reply-To: <20201112183839.1009297-1-natechancellor@gmail.com> From: Nick Desaulniers Date: Thu, 12 Nov 2020 16:44:46 -0800 Message-ID: Subject: Re: [PATCH] kbuild: Always link with '-z norelro' To: Nathan Chancellor , Masahiro Yamada X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_194500_148176_F1D775FD X-CRM114-Status: GOOD ( 26.99 ) 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: Florian Fainelli , Arnd Bergmann , Linux Kbuild mailing list , Catalin Marinas , Linus Walleij , Russell King , Jian Cai , Michal Marek , Linux ARM , Abbott Liu , Andrey Ryabinin , Mike Rapoport , Will Deacon , Ard Biesheuvel , LKML 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 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? > --- > > Hi all, > > This should probably go into Russell's tree with acks from the arm64 and > kbuild maintainers. > > Cheers, > Nathan > > Makefile | 2 ++ > arch/arm64/Makefile | 2 +- > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 008aba5f1a20..648bfb486244 100644 > --- a/Makefile > +++ b/Makefile > @@ -984,6 +984,8 @@ ifeq ($(CONFIG_RELR),y) > LDFLAGS_vmlinux += --pack-dyn-relocs=relr > endif > > +LDFLAGS_vmlinux += -z norelro > + > # Align the bit size of userspace programs with the kernel > KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) > KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > index 5789c2d18d43..85495ff8f0fd 100644 > --- a/arch/arm64/Makefile > +++ b/arch/arm64/Makefile > @@ -10,7 +10,7 @@ > # > # Copyright (C) 1995-2001 by Russell King > > -LDFLAGS_vmlinux :=--no-undefined -X -z norelro > +LDFLAGS_vmlinux :=--no-undefined -X > > ifeq ($(CONFIG_RELOCATABLE), y) > # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour > > base-commit: f8394f232b1eab649ce2df5c5f15b0e528c92091 > -- > 2.29.2 > -- Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel