Skip to content

riscv: improve self-protection

Jisheng Zhang linux-riscv lkml 3 versions – In review

Get series with b4
b4 am 20210413001110.7209bae6@xhacker

Versions newest first · linked by author and title

  1. v3 Latest10 patches 3 repliesIn review
  2. v29 patches 8 repliesSuperseded
  3. v19 patches 7 repliesSuperseded

Changes in v3 from the cover letter

- collect Reviewed-by tag
- add one patch to remove unnecessary setup_zero_page()

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10riscv: mm: Remove setup_zero_page()arch/riscv/mm/init.c+0 -61 reply
2/10riscv: add __init section marker to some functionsarch/riscv/kernel/cpufeature.c arch/riscv/kernel/traps.c arch/riscv/mm/init.c +2 more+8 -81 reply
3/10riscv: Mark some global variables __ro_after_initarch/riscv/kernel/sbi.c arch/riscv/kernel/smp.c arch/riscv/kernel/time.c +2 more+12 -120 replies
4/10riscv: Constify sys_call_tablearch/riscv/include/asm/syscall.h arch/riscv/kernel/syscall_table.c+2 -20 replies
5/10riscv: Constify sbi_ipi_opsarch/riscv/include/asm/smp.h arch/riscv/kernel/sbi.c arch/riscv/kernel/smp.c+5 -50 replies
6/10riscv: kprobes: Implement alloc_insn_page()arch/riscv/kernel/probes/kprobes.c+8 -00 replies
7/10riscv: bpf: Write protect JIT codearch/riscv/net/bpf_jit_core.c+1 -00 replies
8/10riscv: bpf: Avoid breaking W^X on RV64arch/riscv/net/bpf_jit_comp64.c+1 -10 replies
9/10riscv: module: Create module allocations without exec permissionsarch/riscv/kernel/module.c+8 -20 replies
10/10riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMUarch/riscv/Kconfig+1 -00 replies

Reviews trailers per patch

8 of 10 patches have a Reviewed-by or Acked-by.

PatchAnup Patel
1/10R-b
2/10R-b
3/10R-b
4/10R-b
5/10R-b
6/10R-b
7/10
8/10
9/10R-b
10/10R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/10] riscv: improve self-protection

From: Jisheng Zhang <[email protected]>

patch1 removes the non-necessary setup_zero_page()
patch2 is a trivial improvement patch to move some functions to .init section

Then following patches improve self-protection by:

Marking some variables __ro_after_init
Constifing some variables
Enabling ARCH_HAS_STRICT_MODULE_RWX

Hi Anup,

I kept the __init modification to trap_init(), I will cook a trivial series to provide a __weak but NULL trap_init() implementation in init/main.c then remove all NULL implementation from all arch.

Thanks

Since v2:
- collect Reviewed-by tag
- add one patch to remove unnecessary setup_zero_page()

Since v1:
- no need to move bpf_jit_alloc_exec() and bpf_jit_free_exec() to core because RV32 uses the default module_alloc() for jit code which also meets W^X after patch8
- fix a build error caused by local debug code clean up

Jisheng Zhang (10):
riscv: mm: Remove setup_zero_page()
riscv: add __init section marker to some functions
riscv: Mark some global variables __ro_after_init
riscv: Constify sys_call_table
riscv: Constify sbi_ipi_ops
riscv: kprobes: Implement alloc_insn_page()
riscv: bpf: Write protect JIT code
riscv: bpf: Avoid breaking W^X on RV64
riscv: module: Create module allocations without exec permissions
riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU

 arch/riscv/Kconfig                 |  1 +
 arch/riscv/include/asm/smp.h       |  4 ++--
 arch/riscv/include/asm/syscall.h   |  2 +-
 arch/riscv/kernel/cpufeature.c     |  2 +-
 arch/riscv/kernel/module.c         | 10 ++++++++--
 arch/riscv/kernel/probes/kprobes.c |  8 ++++++++
 arch/riscv/kernel/sbi.c            | 10 +++++-----
 arch/riscv/kernel/smp.c            |  6 +++---
 arch/riscv/kernel/syscall_table.c  |  2 +-
 arch/riscv/kernel/time.c           |  2 +-
 arch/riscv/kernel/traps.c          |  2 +-
 arch/riscv/kernel/vdso.c           |  4 ++--
 arch/riscv/mm/init.c               | 16 +++++-----------
 arch/riscv/mm/kasan_init.c         |  6 +++---
 arch/riscv/mm/ptdump.c             |  2 +-
 arch/riscv/net/bpf_jit_comp64.c    |  2 +-
 arch/riscv/net/bpf_jit_core.c      |  1 +
 17 files changed, 45 insertions(+), 35 deletions(-)
Signature · 1 line
2.31.0