Skip to content

Commit

Permalink
vmlinux.lds.h: Move NOTES into RO_DATA
Browse files Browse the repository at this point in the history
The .notes section should be non-executable read-only data. As such,
move it to the RO_DATA macro instead of being per-architecture defined.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # s390
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-alpha@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-c6x-dev@linux-c6x.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Will Deacon <will@kernel.org>
Cc: x86-ml <x86@kernel.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Link: https://lkml.kernel.org/r/20191029211351.13243-11-keescook@chromium.org
  • Loading branch information
Kees Cook authored and Borislav Petkov committed Nov 4, 2019
1 parent fbe6a8e commit eaf9370
Show file tree
Hide file tree
Showing 26 changed files with 5 additions and 38 deletions.
2 changes: 0 additions & 2 deletions arch/alpha/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ SECTIONS
swapper_pg_dir = SWAPPER_PGD;
_etext = .; /* End of text section */

NOTES

RODATA
EXCEPTION_TABLE(16)

Expand Down
2 changes: 0 additions & 2 deletions arch/arc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ SECTIONS
/DISCARD/ : { *(.eh_frame) }
#endif

NOTES

. = ALIGN(PAGE_SIZE);
_end = . ;

Expand Down
2 changes: 0 additions & 2 deletions arch/arm/kernel/vmlinux-xip.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ SECTIONS
ARM_UNWIND_SECTIONS
#endif

NOTES

_etext = .; /* End of text and rodata section */

ARM_VECTORS
Expand Down
2 changes: 0 additions & 2 deletions arch/arm/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ SECTIONS
ARM_UNWIND_SECTIONS
#endif

NOTES

#ifdef CONFIG_STRICT_KERNEL_RWX
. = ALIGN(1<<SECTION_SHIFT);
#else
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ SECTIONS

RO_DATA(PAGE_SIZE) /* everything from this point to */
EXCEPTION_TABLE(8) /* __init_begin will be marked RO NX */
NOTES

. = ALIGN(PAGE_SIZE);
idmap_pg_dir = .;
Expand Down
1 change: 0 additions & 1 deletion arch/c6x/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ SECTIONS
}

EXCEPTION_TABLE(16)
NOTES

RO_DATA_SECTION(PAGE_SIZE)
.const :
Expand Down
1 change: 0 additions & 1 deletion arch/csky/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ SECTIONS
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .;

NOTES
EXCEPTION_TABLE(L1_CACHE_BYTES)
BSS_SECTION(L1_CACHE_BYTES, PAGE_SIZE, L1_CACHE_BYTES)
VBR_BASE
Expand Down
1 change: 0 additions & 1 deletion arch/h8300/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ SECTIONS
_etext = . ;
}
EXCEPTION_TABLE(16)
NOTES
RO_DATA_SECTION(4)
ROMEND = .;
#if defined(CONFIG_ROMKERNEL)
Expand Down
1 change: 0 additions & 1 deletion arch/hexagon/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ SECTIONS
_edata = .;

EXCEPTION_TABLE(16)
NOTES

BSS_SECTION(_PAGE_SIZE, _PAGE_SIZE, _PAGE_SIZE)

Expand Down
2 changes: 0 additions & 2 deletions arch/ia64/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ SECTIONS {
/*
* Read-only data
*/
NOTES

EXCEPTION_TABLE(16)

/* MCA table */
Expand Down
1 change: 0 additions & 1 deletion arch/microblaze/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ SECTIONS {
. = ALIGN(16);
RODATA
EXCEPTION_TABLE(16)
NOTES

/*
* sdata2 section can go anywhere, but must be word aligned
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ SECTIONS
__stop___dbe_table = .;
}

NOTES

_sdata = .; /* Start of data section */
RODATA

Expand Down
1 change: 0 additions & 1 deletion arch/nds32/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ SECTIONS
_edata = .;

EXCEPTION_TABLE(16)
NOTES
BSS_SECTION(4, 4, 4)
_end = .;

Expand Down
1 change: 0 additions & 1 deletion arch/nios2/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ SECTIONS

STABS_DEBUG
DWARF_DEBUG
NOTES

DISCARDS
}
1 change: 0 additions & 1 deletion arch/openrisc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ SECTIONS
_edata = .;

EXCEPTION_TABLE(4)
NOTES

/* Init code and data */
. = ALIGN(PAGE_SIZE);
Expand Down
1 change: 0 additions & 1 deletion arch/parisc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ SECTIONS

/* RO because of BUILDTIME_EXTABLE_SORT */
EXCEPTION_TABLE(8)
NOTES

/* unwind info */
.PARISC.unwind : {
Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ SECTIONS
#endif
EXCEPTION_TABLE(0)

NOTES

/*
* Init sections discarded at runtime
*/
Expand Down
1 change: 0 additions & 1 deletion arch/riscv/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ SECTIONS
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)

EXCEPTION_TABLE(0x10)
NOTES

.rel.dyn : {
*(.rel.dyn*)
Expand Down
2 changes: 0 additions & 2 deletions arch/s390/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ SECTIONS
_etext = .; /* End of text section */
} :text = 0x0700

NOTES

RO_DATA_SECTION(PAGE_SIZE)

. = ALIGN(PAGE_SIZE);
Expand Down
1 change: 0 additions & 1 deletion arch/sh/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ SECTIONS
} = 0x0009

EXCEPTION_TABLE(16)
NOTES

_sdata = .;
RO_DATA(PAGE_SIZE)
Expand Down
1 change: 0 additions & 1 deletion arch/sparc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ SECTIONS
__stop___fixup = .;
}
EXCEPTION_TABLE(16)
NOTES

. = ALIGN(PAGE_SIZE);
__init_begin = ALIGN(PAGE_SIZE);
Expand Down
1 change: 0 additions & 1 deletion arch/um/include/asm/common.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
PROVIDE (_unprotected_end = .);

. = ALIGN(4096);
NOTES
EXCEPTION_TABLE(0)

BUG_TABLE
Expand Down
1 change: 0 additions & 1 deletion arch/unicore32/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ SECTIONS
_edata = .;

EXCEPTION_TABLE(L1_CACHE_BYTES)
NOTES

BSS_SECTION(0, 0, 0)
_end = .;
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ SECTIONS
_etext = .;
} :text = 0x9090

NOTES

EXCEPTION_TABLE(16)

/* .text should occupy whole number of pages */
Expand Down
1 change: 0 additions & 1 deletion arch/xtensa/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ SECTIONS
.fixup : { *(.fixup) }

EXCEPTION_TABLE(16)
NOTES
/* Data section */

_sdata = .;
Expand Down
9 changes: 5 additions & 4 deletions include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* _edata = .;
*
* EXCEPTION_TABLE(...)
* NOTES
*
* BSS_SECTION(0, 0, 0)
* _end = .;
Expand Down Expand Up @@ -512,10 +511,12 @@
__start___modver = .; \
KEEP(*(__modver)) \
__stop___modver = .; \
. = ALIGN((align)); \
__end_rodata = .; \
} \
. = ALIGN((align));
\
NOTES \
\
. = ALIGN((align)); \
__end_rodata = .;

/* RODATA & RO_DATA provided for backward compatibility.
* All archs are supposed to use RO_DATA() */
Expand Down

0 comments on commit eaf9370

Please sign in to comment.