When dyndbg classmaps get used (later in this series), the
__dyndbg_classes section (which has 28 byte structs on i386), causes
mis-alignment of the following __dyndbg section, resulting in a NULL
pointer deref in dynamic_debug_init().

Fix this by:

Adding ALIGN(8) to the BOUNDED_SECTION* macros.  This aligns all
sections using those macros, including the problem section above.
Almost all the other macro uses are already ALIGN(8), either
directly or by being below one.

Removing BOUNDED_SECTION* uses in ORC_UNWINDER sections.  These
explicitly have smaller alignments, and using the modified macros here
would override that aligment, which scripts/sorttable.c does not
tolerate.

Move __dyndbg section back above __dyndbg_classes, restoring its
orignal position.  This is cosmetic, given the alignment added to the
macros.

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-lkp/[email protected]
Signed-off-by: Jim Cromie <[email protected]>
---
 include/asm-generic/vmlinux.lds.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index 1e1580febe4b..58daa551420b 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -212,11 +212,13 @@
 #endif
 
 #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)      \
+       . = ALIGN(8);                                                   \
        _BEGIN_##_label_ = .;                                           \
        KEEP(*(_sec_))                                                  \
        _END_##_label_ = .;
 
 #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)     \
+       . = ALIGN(8);                                                   \
        _label_##_BEGIN_ = .;                                           \
        KEEP(*(_sec_))                                                  \
        _label_##_END_ = .;
@@ -869,15 +871,21 @@
 #ifdef CONFIG_UNWINDER_ORC
 #define ORC_UNWIND_TABLE                                               \
        .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) {             \
-               BOUNDED_SECTION_BY(.orc_header, _orc_header)            \
+               __start_orc_header = .;                                 \
+               KEEP(*(.orc_header))                                    \
+               __stop_orc_header = .;                                  \
        }                                                               \
        . = ALIGN(4);                                                   \
        .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) {       \
-               BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip)      \
+               __start_orc_unwind_ip = .;                              \
+               KEEP(*(.orc_unwind_ip))                                 \
+               __stop_orc_unwind_ip = .;                               \
        }                                                               \
        . = ALIGN(2);                                                   \
        .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) {             \
-               BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind)            \
+               __start_orc_unwind = .;                                 \
+               KEEP(*(.orc_unwind))                                    \
+               __stop_orc_unwind = .;                                  \
        }                                                               \
        text_size = _etext - _stext;                                    \
        . = ALIGN(4);                                                   \
-- 
2.53.0

Reply via email to