linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6.3] riscv: Link with '-z norelro'
@ 2023-06-20 17:44 Nathan Chancellor
  2023-06-20 17:47 ` Palmer Dabbelt
  2023-06-22  8:08 ` Patch "riscv: Link with '-z norelro'" has been added to the 6.3-stable tree gregkh
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-06-20 17:44 UTC (permalink / raw)
  To: gregkh, sashal
  Cc: palmer, conor, ndesaulniers, nathan, linux-riscv, stable, llvm,
	kernel test robot

This patch fixes a stable only patch, so it has no direct upstream
equivalent.

After a stable only patch to explicitly handle the '.got' section to
handle an orphan section warning from the linker, certain configurations
error when linking with ld.lld, which enables relro by default:

  ld.lld: error: section: .got is not contiguous with other relro sections

This has come up with other architectures before, such as arm and arm64
in commit 0cda9bc15dfc ("ARM: 9038/1: Link with '-z norelro'") and
commit 3b92fa7485eb ("arm64: link with -z norelro regardless of
CONFIG_RELOCATABLE"). Additionally, '-z norelro' is used unconditionally
for RISC-V upstream after commit 26e7aacb83df ("riscv: Allow to
downgrade paging mode from the command line"), which alluded to this
issue for the same reason. Bring 6.3 in line with mainline and link with
'-z norelro', which resolves the above link failure.

Fixes: e6d1562dd4e9 ("riscv: vmlinux.lds.S: Explicitly handle '.got' section")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202306192231.DJmWr6BX-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/riscv/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index b05e833a022d..d46b6722710f 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -7,7 +7,7 @@
 #
 
 OBJCOPYFLAGS    := -O binary
-LDFLAGS_vmlinux :=
+LDFLAGS_vmlinux := -z norelro
 ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
 	LDFLAGS_vmlinux := --no-relax
 	KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY

---
base-commit: f2427f9a3730e9a1a11b69f6b767f7f2fad87523
change-id: 20230620-6-3-fix-got-relro-error-lld-397f3112860b

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 6.3] riscv: Link with '-z norelro'
  2023-06-20 17:44 [PATCH 6.3] riscv: Link with '-z norelro' Nathan Chancellor
@ 2023-06-20 17:47 ` Palmer Dabbelt
  2023-06-22  8:08 ` Patch "riscv: Link with '-z norelro'" has been added to the 6.3-stable tree gregkh
  1 sibling, 0 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2023-06-20 17:47 UTC (permalink / raw)
  To: nathan
  Cc: Greg KH, sashal, Conor Dooley, ndesaulniers, nathan, linux-riscv,
	stable, llvm, lkp

On Tue, 20 Jun 2023 10:44:50 PDT (-0700), nathan@kernel.org wrote:
> This patch fixes a stable only patch, so it has no direct upstream
> equivalent.
>
> After a stable only patch to explicitly handle the '.got' section to
> handle an orphan section warning from the linker, certain configurations
> error when linking with ld.lld, which enables relro by default:
>
>   ld.lld: error: section: .got is not contiguous with other relro sections
>
> This has come up with other architectures before, such as arm and arm64
> in commit 0cda9bc15dfc ("ARM: 9038/1: Link with '-z norelro'") and
> commit 3b92fa7485eb ("arm64: link with -z norelro regardless of
> CONFIG_RELOCATABLE"). Additionally, '-z norelro' is used unconditionally
> for RISC-V upstream after commit 26e7aacb83df ("riscv: Allow to
> downgrade paging mode from the command line"), which alluded to this
> issue for the same reason. Bring 6.3 in line with mainline and link with
> '-z norelro', which resolves the above link failure.
>
> Fixes: e6d1562dd4e9 ("riscv: vmlinux.lds.S: Explicitly handle '.got' section")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202306192231.DJmWr6BX-lkp@intel.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/riscv/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index b05e833a022d..d46b6722710f 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -7,7 +7,7 @@
>  #
>
>  OBJCOPYFLAGS    := -O binary
> -LDFLAGS_vmlinux :=
> +LDFLAGS_vmlinux := -z norelro
>  ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
>  	LDFLAGS_vmlinux := --no-relax
>  	KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
>
> ---
> base-commit: f2427f9a3730e9a1a11b69f6b767f7f2fad87523
> change-id: 20230620-6-3-fix-got-relro-error-lld-397f3112860b
>
> Best regards,

Acked-by: Palmer Dabbelt <palmer@rivosinc.com>

Thanks!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Patch "riscv: Link with '-z norelro'" has been added to the 6.3-stable tree
  2023-06-20 17:44 [PATCH 6.3] riscv: Link with '-z norelro' Nathan Chancellor
  2023-06-20 17:47 ` Palmer Dabbelt
@ 2023-06-22  8:08 ` gregkh
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2023-06-22  8:08 UTC (permalink / raw)
  To: 202306192231.DJmWr6BX-lkp, conor, gregkh, linux-riscv, lkp, llvm,
	nathan, ndesaulniers, palmer, palmer, sashal
  Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    riscv: Link with '-z norelro'

to the 6.3-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-link-with-z-norelro.patch
and it can be found in the queue-6.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From nathan@kernel.org  Thu Jun 22 09:37:45 2023
From: Nathan Chancellor <nathan@kernel.org>
Date: Tue, 20 Jun 2023 17:44:50 +0000
Subject: riscv: Link with '-z norelro'
To: gregkh@linuxfoundation.org, sashal@kernel.org
Cc: palmer@dabbelt.com, conor@kernel.org, ndesaulniers@google.com, nathan@kernel.org, linux-riscv@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev, kernel test robot <lkp@intel.com>
Message-ID: <20230620-6-3-fix-got-relro-error-lld-v1-1-f3e71ec912d1@kernel.org>

From: Nathan Chancellor <nathan@kernel.org>

This patch fixes a stable only patch, so it has no direct upstream
equivalent.

After a stable only patch to explicitly handle the '.got' section to
handle an orphan section warning from the linker, certain configurations
error when linking with ld.lld, which enables relro by default:

  ld.lld: error: section: .got is not contiguous with other relro sections

This has come up with other architectures before, such as arm and arm64
in commit 0cda9bc15dfc ("ARM: 9038/1: Link with '-z norelro'") and
commit 3b92fa7485eb ("arm64: link with -z norelro regardless of
CONFIG_RELOCATABLE"). Additionally, '-z norelro' is used unconditionally
for RISC-V upstream after commit 26e7aacb83df ("riscv: Allow to
downgrade paging mode from the command line"), which alluded to this
issue for the same reason. Bring 6.3 in line with mainline and link with
'-z norelro', which resolves the above link failure.

Fixes: e6d1562dd4e9 ("riscv: vmlinux.lds.S: Explicitly handle '.got' section")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202306192231.DJmWr6BX-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/riscv/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -7,7 +7,7 @@
 #
 
 OBJCOPYFLAGS    := -O binary
-LDFLAGS_vmlinux :=
+LDFLAGS_vmlinux := -z norelro
 ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
 	LDFLAGS_vmlinux := --no-relax
 	KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY


Patches currently in stable-queue which might be from nathan@kernel.org are

queue-6.3/riscv-link-with-z-norelro.patch

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-22  8:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20 17:44 [PATCH 6.3] riscv: Link with '-z norelro' Nathan Chancellor
2023-06-20 17:47 ` Palmer Dabbelt
2023-06-22  8:08 ` Patch "riscv: Link with '-z norelro'" has been added to the 6.3-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).