Commit 84814460 authored by Guo Ren's avatar Guo Ren Committed by Palmer Dabbelt

riscv: Fixup bootup failure with HARDENED_USERCOPY

6184358d ("riscv: Fixup static_obj() fail") attempted to elide a lockdep
failure by rearranging our kernel image to place all initdata within [_stext,
_end], thus triggering lockdep to treat these as static objects.  These objects
are released and eventually reallocated, causing check_kernel_text_object() to
trigger a BUG().

This backs out the change to make [_stext, _end] all-encompassing, instead just
moving initdata.  This results in initdata being outside of [__init_begin,
__init_end], which means initdata can't be freed.

Link: https://lore.kernel.org/linux-riscv/1593266228-61125-1-git-send-email-guoren@kernel.org/T/#tSigned-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
Reported-by: default avatarAurelien Jarno <aurelien@aurel32.net>
Tested-by: default avatarAurelien Jarno <aurelien@aurel32.net>
[Palmer: Clean up commit text]
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent a78c6f59
...@@ -22,13 +22,11 @@ SECTIONS ...@@ -22,13 +22,11 @@ SECTIONS
/* Beginning of code and text segment */ /* Beginning of code and text segment */
. = LOAD_OFFSET; . = LOAD_OFFSET;
_start = .; _start = .;
_stext = .;
HEAD_TEXT_SECTION HEAD_TEXT_SECTION
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
__init_begin = .; __init_begin = .;
INIT_TEXT_SECTION(PAGE_SIZE) INIT_TEXT_SECTION(PAGE_SIZE)
INIT_DATA_SECTION(16)
. = ALIGN(8); . = ALIGN(8);
__soc_early_init_table : { __soc_early_init_table : {
__soc_early_init_table_start = .; __soc_early_init_table_start = .;
...@@ -55,6 +53,7 @@ SECTIONS ...@@ -55,6 +53,7 @@ SECTIONS
. = ALIGN(SECTION_ALIGN); . = ALIGN(SECTION_ALIGN);
.text : { .text : {
_text = .; _text = .;
_stext = .;
TEXT_TEXT TEXT_TEXT
SCHED_TEXT SCHED_TEXT
CPUIDLE_TEXT CPUIDLE_TEXT
...@@ -67,6 +66,8 @@ SECTIONS ...@@ -67,6 +66,8 @@ SECTIONS
_etext = .; _etext = .;
} }
INIT_DATA_SECTION(16)
/* Start of data section */ /* Start of data section */
_sdata = .; _sdata = .;
RO_DATA(SECTION_ALIGN) RO_DATA(SECTION_ALIGN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment