[PATCH v5 0/2] riscv: fix text patching on minimal kernel configs

Xiaofeng Yuan <[email protected]>
Newsgroups org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
This series fixes two related issues that break kprobes and kernel text
patching on RISC-V configurations where CONFIG_STRICT_MODULE_RWX is not
available (e.g. CONFIG_MODULES=n).

Patch 1 makes the EXECMEM_KPROBES range writable when
CONFIG_STRICT_MODULE_RWX is disabled, so kprobe instruction slot writes
do not fault on read-only executable pages.

Patch 2 makes patch_map() skip the temporary fixmap mapping when the
kernel text is already writable, i.e. when CONFIG_STRICT_KERNEL_RWX is
disabled. The module text path is still gated on CONFIG_STRICT_MODULE_RWX.

Changes since v4:
- 2/2: gate the kernel text fixmap on CONFIG_STRICT_KERNEL_RWX instead of
  returning early on !CONFIG_STRICT_MODULE_RWX. The v4 early return broke
  configs with CONFIG_MODULES=n, where CONFIG_STRICT_MODULE_RWX is
  unavailable but CONFIG_STRICT_KERNEL_RWX is still enabled and the kernel
  text is read-only, causing a boot-time kernel panic on BPI-F3 and RZ/Five
  (reported by Klara Modin and Lad Prabhakar).

Xiaofeng Yuan (2):
  riscv: mm: make EXECMEM_KPROBES writable without
    CONFIG_STRICT_MODULE_RWX
  riscv: patch: skip fixmap mapping when kernel text is already writable

 arch/riscv/kernel/patch.c | 2 ++
 arch/riscv/mm/init.c      | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.43.0


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.