* [PATCH] arm64: fix .data.rel.ro size assertion when CONFIG_LTO_CLANG
@ 2024-11-06 16:18 Masahiro Yamada
2024-11-07 11:15 ` Will Deacon
2024-11-07 18:40 ` Catalin Marinas
0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2024-11-06 16:18 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, moderated for non-subscribers
Cc: linux-kbuild, Nicholas Piggin, Masahiro Yamada, Ingo Molnar,
Kees Cook, linux-arm-kernel, linux-kernel
Commit be2881824ae9 ("arm64/build: Assert for unwanted sections")
introduced an assertion to ensure that the .data.rel.ro section does
not exist.
However, this check does not work when CONFIG_LTO_CLANG is enabled,
because .data.rel.ro matches the .data.[0-9a-zA-Z_]* pattern in the
DATA_MAIN macro.
Move the ASSERT() above the RW_DATA() line.
Fixes: be2881824ae9 ("arm64/build: Assert for unwanted sections")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
arch/arm64/kernel/vmlinux.lds.S | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 58d89d997d05..f84c71f04d9e 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -287,6 +287,9 @@ SECTIONS
__initdata_end = .;
__init_end = .;
+ .data.rel.ro : { *(.data.rel.ro) }
+ ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
+
_data = .;
_sdata = .;
RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
@@ -343,9 +346,6 @@ SECTIONS
*(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
}
ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
-
- .data.rel.ro : { *(.data.rel.ro) }
- ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
}
#include "image-vars.h"
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] arm64: fix .data.rel.ro size assertion when CONFIG_LTO_CLANG
2024-11-06 16:18 [PATCH] arm64: fix .data.rel.ro size assertion when CONFIG_LTO_CLANG Masahiro Yamada
@ 2024-11-07 11:15 ` Will Deacon
2024-11-07 18:40 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Will Deacon @ 2024-11-07 11:15 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Catalin Marinas, moderated for non-subscribers, linux-kbuild,
Nicholas Piggin, Ingo Molnar, Kees Cook, linux-kernel
On Thu, Nov 07, 2024 at 01:18:42AM +0900, Masahiro Yamada wrote:
> Commit be2881824ae9 ("arm64/build: Assert for unwanted sections")
> introduced an assertion to ensure that the .data.rel.ro section does
> not exist.
>
> However, this check does not work when CONFIG_LTO_CLANG is enabled,
> because .data.rel.ro matches the .data.[0-9a-zA-Z_]* pattern in the
> DATA_MAIN macro.
>
> Move the ASSERT() above the RW_DATA() line.
>
> Fixes: be2881824ae9 ("arm64/build: Assert for unwanted sections")
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> arch/arm64/kernel/vmlinux.lds.S | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
> index 58d89d997d05..f84c71f04d9e 100644
> --- a/arch/arm64/kernel/vmlinux.lds.S
> +++ b/arch/arm64/kernel/vmlinux.lds.S
> @@ -287,6 +287,9 @@ SECTIONS
> __initdata_end = .;
> __init_end = .;
>
> + .data.rel.ro : { *(.data.rel.ro) }
> + ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
> +
> _data = .;
> _sdata = .;
> RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
> @@ -343,9 +346,6 @@ SECTIONS
> *(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
> }
> ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
> -
> - .data.rel.ro : { *(.data.rel.ro) }
> - ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
> }
>
> #include "image-vars.h"
Acked-by: Will Deacon <will@kernel.org>
Catalin, please can you pick this up for 6.13?
Will
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] arm64: fix .data.rel.ro size assertion when CONFIG_LTO_CLANG
2024-11-06 16:18 [PATCH] arm64: fix .data.rel.ro size assertion when CONFIG_LTO_CLANG Masahiro Yamada
2024-11-07 11:15 ` Will Deacon
@ 2024-11-07 18:40 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2024-11-07 18:40 UTC (permalink / raw)
To: Will Deacon, linux-arm-kernel, Masahiro Yamada
Cc: linux-kbuild, Nicholas Piggin, Ingo Molnar, Kees Cook,
linux-kernel
On Thu, 07 Nov 2024 01:18:42 +0900, Masahiro Yamada wrote:
> Commit be2881824ae9 ("arm64/build: Assert for unwanted sections")
> introduced an assertion to ensure that the .data.rel.ro section does
> not exist.
>
> However, this check does not work when CONFIG_LTO_CLANG is enabled,
> because .data.rel.ro matches the .data.[0-9a-zA-Z_]* pattern in the
> DATA_MAIN macro.
>
> [...]
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64: fix .data.rel.ro size assertion when CONFIG_LTO_CLANG
https://git.kernel.org/arm64/c/340fd66c8566
--
Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-07 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06 16:18 [PATCH] arm64: fix .data.rel.ro size assertion when CONFIG_LTO_CLANG Masahiro Yamada
2024-11-07 11:15 ` Will Deacon
2024-11-07 18:40 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox