arm/build: Assert for unwanted sections
authorKees Cook <keescook@chromium.org>
Fri, 21 Aug 2020 19:42:59 +0000 (12:42 -0700)
committerIngo Molnar <mingo@kernel.org>
Tue, 1 Sep 2020 08:03:18 +0000 (10:03 +0200)
In preparation for warning on orphan sections, enforce
expected-to-be-zero-sized sections (since discarding them might hide
problems with them suddenly gaining unexpected entries).

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Link: https://lore.kernel.org/r/20200821194310.3089815-19-keescook@chromium.org
arch/arm/include/asm/vmlinux.lds.h
arch/arm/kernel/vmlinux-xip.lds.S
arch/arm/kernel/vmlinux.lds.S

index 6624dd9..4a91428 100644 (file)
                ARM_MMU_DISCARD(*(__ex_table))                          \
                COMMON_DISCARDS
 
+/*
+ * Sections that should stay zero sized, which is safer to explicitly
+ * check instead of blindly discarding.
+ */
+#define ARM_ASSERTS                                                    \
+       .plt : {                                                        \
+               *(.iplt) *(.rel.iplt) *(.iplt) *(.igot.plt)             \
+       }                                                               \
+       ASSERT(SIZEOF(.plt) == 0,                                       \
+              "Unexpected run-time procedure linkages detected!")
+
 #define ARM_DETAILS                                                    \
                ELF_DETAILS                                             \
                .ARM.attributes 0 : { *(.ARM.attributes) }
index 11ffa79..5013682 100644 (file)
@@ -152,6 +152,8 @@ SECTIONS
        STABS_DEBUG
        DWARF_DEBUG
        ARM_DETAILS
+
+       ARM_ASSERTS
 }
 
 /*
index dc672fe..5f4922e 100644 (file)
@@ -151,6 +151,8 @@ SECTIONS
        STABS_DEBUG
        DWARF_DEBUG
        ARM_DETAILS
+
+       ARM_ASSERTS
 }
 
 #ifdef CONFIG_STRICT_KERNEL_RWX