Skip to content

Commit

Permalink
lkl: handle ro_after_init properlly
Browse files Browse the repository at this point in the history
Since section ro_after_init contains writable data located inside
.rodata section (which is read-only), resulting rodata section is
writable.  Since we don't have implementation of mark_rodata_ro() in our
arch, those section keep writable forever.

So this commit moves data.ro_after_init section from rodata to the
end of sections so that rodata section will be read-only.

Without this commit there is no issue, but valgrind somehow puzzled with
malformed sections when ro_after_init section used, and results
unresolved symbols after a valgrind run.

This commit fixes torvalds#349.

Fixes: d2ec3f7 ("pty: make ptmx file ops read-only after init")

The commit uses (d07a980, s390: add
proper __ro_after_init support) as a reference.

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
  • Loading branch information
thehajime committed Feb 7, 2018
1 parent d98f6b8 commit 8141273
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/lkl/include/asm/vmlinux.lds.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef _LKL_VMLINUX_LDS_H
#define _LKL_VMLINUX_LDS_H

/* we encode our own __ro_after_init section */
#define RO_AFTER_INIT_DATA

#ifdef __MINGW32__
#define RODATA_SECTION .rdata
#endif
Expand Down
3 changes: 3 additions & 0 deletions arch/lkl/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ SECTIONS
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
VMLINUX_SYMBOL(_edata) = .;

VMLINUX_SYMBOL(__start_ro_after_init) = .;
.data..ro_after_init : { *(.data..ro_after_init)}
EXCEPTION_TABLE(16)
VMLINUX_SYMBOL(__end_ro_after_init) = .;
NOTES

BSS_SECTION(0, 0, 0)
Expand Down

0 comments on commit 8141273

Please sign in to comment.