Skip to content

Commit 9574134

Browse files
heicarstAlex Shi
authored andcommitted
vmlinux.lds.h: allow arch specific handling of ro_after_init data section
commit c74ba8b3480d ("arch: Introduce post-init read-only memory") introduced the __ro_after_init attribute which allows to add variables to the ro_after_init data section. This new section was added to rodata, even though it contains writable data. This in turn causes problems on architectures which mark the page table entries read-only that point to rodata very early. This patch allows architectures to implement an own handling of the .data..ro_after_init section. Usually that would be: - mark the rodata section read-only very early - mark the ro_after_init section read-only within mark_rodata_ro Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> (cherry picked from commit 32fb2fc5c357fb99616bbe100dbcb27bc7f5d045) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent d425243 commit 9574134

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

include/asm-generic/vmlinux.lds.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@
248248
. = ALIGN(align); \
249249
*(.data..init_task)
250250

251+
/*
252+
* Allow architectures to handle ro_after_init data on their
253+
* own by defining an empty RO_AFTER_INIT_DATA.
254+
*/
255+
#ifndef RO_AFTER_INIT_DATA
256+
#define RO_AFTER_INIT_DATA *(.data..ro_after_init)
257+
#endif
258+
251259
/*
252260
* Read only Data
253261
*/
@@ -256,7 +264,7 @@
256264
.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
257265
VMLINUX_SYMBOL(__start_rodata) = .; \
258266
*(.rodata) *(.rodata.*) \
259-
*(.data..ro_after_init) /* Read only after init */ \
267+
RO_AFTER_INIT_DATA /* Read only after init */ \
260268
*(__vermagic) /* Kernel version magic */ \
261269
. = ALIGN(8); \
262270
VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \

0 commit comments

Comments
 (0)