Skip to content

Commit dfabba9

Browse files
committed
Merge remote-tracking branch 'lsk/v4.4/topic/ro-vdso' into linux-linaro-lsk-v4.4
2 parents 34f6d2c + a1bd41f commit dfabba9

26 files changed

Lines changed: 103 additions & 84 deletions

File tree

Documentation/kernel-parameters.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,6 +3409,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
34093409

34103410
ro [KNL] Mount root device read-only on boot
34113411

3412+
rodata= [KNL]
3413+
on Mark read-only kernel memory as read-only (default).
3414+
off Leave read-only kernel memory writable for debugging.
3415+
34123416
root= [KNL] Root filesystem
34133417
See name_to_dev_t comment in init/do_mounts.c.
34143418

arch/arm/include/asm/cacheflush.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
491491
#endif
492492

493493
#ifdef CONFIG_DEBUG_RODATA
494-
void mark_rodata_ro(void);
495494
void set_kernel_text_rw(void);
496495
void set_kernel_text_ro(void);
497496
#else

arch/arm/vdso/vdso.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
#include <linux/const.h>
2424
#include <asm/page.h>
2525

26-
__PAGE_ALIGNED_DATA
27-
2826
.globl vdso_start, vdso_end
27+
.section .data..ro_after_init
2928
.balign PAGE_SIZE
3029
vdso_start:
3130
.incbin "arch/arm/vdso/vdso.so"

arch/arm64/include/asm/cacheflush.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,4 @@ int set_memory_rw(unsigned long addr, int numpages);
155155
int set_memory_x(unsigned long addr, int numpages);
156156
int set_memory_nx(unsigned long addr, int numpages);
157157

158-
#ifdef CONFIG_DEBUG_RODATA
159-
void mark_rodata_ro(void);
160-
#endif
161-
162158
#endif

arch/parisc/include/asm/cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
#define __read_mostly __attribute__((__section__(".data..read_mostly")))
2424

25+
/* Read-only memory is marked before mark_rodata_ro() is called. */
26+
#define __ro_after_init __read_mostly
27+
2528
void parisc_cache_init(void); /* initializes cache-flushing */
2629
void disable_sr_hashing_asm(int); /* low level support for above */
2730
void disable_sr_hashing(void); /* turns off space register hashing */

arch/parisc/include/asm/cacheflush.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vma
121121
}
122122
}
123123

124-
#ifdef CONFIG_DEBUG_RODATA
125-
void mark_rodata_ro(void);
126-
#endif
127-
128124
#include <asm/kmap_types.h>
129125

130126
#define ARCH_HAS_KMAP

arch/x86/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ config ARCH_SUPPORTS_UPROBES
289289
config FIX_EARLYCON_MEM
290290
def_bool y
291291

292+
config DEBUG_RODATA
293+
def_bool y
294+
292295
config PGTABLE_LEVELS
293296
int
294297
default 4 if X86_64

arch/x86/Kconfig.debug

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,16 @@ config EFI_PGT_DUMP
9191
issues with the mapping of the EFI runtime regions into that
9292
table.
9393

94-
config DEBUG_RODATA
95-
bool "Write protect kernel read-only data structures"
96-
default y
97-
depends on DEBUG_KERNEL
98-
---help---
99-
Mark the kernel read-only data as write-protected in the pagetables,
100-
in order to catch accidental (and incorrect) writes to such const
101-
data. This is recommended so that we can catch kernel bugs sooner.
102-
If in doubt, say "Y".
103-
10494
config DEBUG_RODATA_TEST
105-
bool "Testcase for the DEBUG_RODATA feature"
106-
depends on DEBUG_RODATA
95+
bool "Testcase for the marking rodata read-only"
10796
default y
10897
---help---
109-
This option enables a testcase for the DEBUG_RODATA
110-
feature as well as for the change_page_attr() infrastructure.
98+
This option enables a testcase for the setting rodata read-only
99+
as well as for the change_page_attr() infrastructure.
111100
If in doubt, say "N"
112101

113102
config DEBUG_WX
114103
bool "Warn on W+X mappings at boot"
115-
depends on DEBUG_RODATA
116104
select X86_PTDUMP_CORE
117105
---help---
118106
Generate a warning if any W+X mappings are found at boot.

arch/x86/entry/vdso/vdso2c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
140140
fprintf(outfile, "#include <asm/vdso.h>\n");
141141
fprintf(outfile, "\n");
142142
fprintf(outfile,
143-
"static unsigned char raw_data[%lu] __page_aligned_data = {",
143+
"static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
144144
mapping_size);
145145
for (j = 0; j < stripped_len; j++) {
146146
if (j % 10 == 0)

arch/x86/include/asm/cacheflush.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,10 @@ void clflush_cache_range(void *addr, unsigned int size);
9191

9292
#define mmio_flush_range(addr, size) clflush_cache_range(addr, size)
9393

94-
#ifdef CONFIG_DEBUG_RODATA
95-
void mark_rodata_ro(void);
9694
extern const int rodata_test_data;
9795
extern int kernel_set_to_readonly;
9896
void set_kernel_text_rw(void);
9997
void set_kernel_text_ro(void);
100-
#else
101-
static inline void set_kernel_text_rw(void) { }
102-
static inline void set_kernel_text_ro(void) { }
103-
#endif
10498

10599
#ifdef CONFIG_DEBUG_RODATA_TEST
106100
int rodata_test(void);

0 commit comments

Comments
 (0)