Skip to content

Add KFENCE support for LoongArch

Enze Li linux-mm loongarch 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 2 repliesIn review
  2. v24 patches 11 repliesSuperseded
  3. v14 patches 16 repliesSuperseded

Changes in v3 from the cover letter

* Address Huacai's comments.
* Fix a bug that Jackie Liu pointed out.
* Rewrite arch_stack_walk() with the suggestion of Jinyang He.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KFENCE: Defer the assignment of the local variable addrmm/kfence/core.c+3 -20 replies
2/4LoongArch: mm: Add page table mapped mode supportarch/loongarch/include/asm/page.h arch/loongarch/include/asm/pgtable.h arch/loongarch/mm/pgtable.c+17 -10 replies
3/4LoongArch: Get stack without NMI when providing regs parameterarch/loongarch/kernel/stacktrace.c+10 -80 replies
4/4LoongArch: Add KFENCE supportarch/loongarch/Kconfig arch/loongarch/include/asm/kfence.h arch/loongarch/include/asm/pgtable.h +1 more+93 -90 replies

Reviews trailers per patch

1 of 4 patches has a Reviewed-by or Acked-by.

PatchJinyang HeMarco Elver
1/4A-b
2/4
3/4Co-authored-by
4/4

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 0/4 v3] Add KFENCE support for LoongArch

Hi all,

This patchset adds KFENCE support on LoongArch.

To run the testcases, you will need to enable the following options,

-> Kernel hacking
[*] Tracers
[*] Support for tracing block IO actions (NEW)
-> Kernel Testing and Coverage
<*> KUnit - Enable support for unit tests

and then,

-> Kernel hacking
-> Memory Debugging
[*] KFENCE: low-overhead sampling-based memory safety error detector (NEW)
<*> KFENCE integration test suite (NEW)

With these options enabled, KFENCE will be tested during kernel startup. And normally, you might get the following feedback,

========================================================

[   35.326363 ] # kfence: pass:23 fail:0 skip:2 total:25
[   35.326486 ] # Totals: pass:23 fail:0 skip:2 total:25
[   35.326621 ] ok 1 kfence

========================================================

you might notice that 2 testcases have been skipped. If you tend to run all testcases, please enable CONFIG_INIT_ON_FREE_DEFAULT_ON, you can find it here,

-> Security options
-> Kernel hardening options
-> Memory initialization
[*] Enable heap memory zeroing on free by default

and you might get all testcases passed.
========================================================

[   35.531860 ] # kfence: pass:25 fail:0 skip:0 total:25
[   35.531999 ] # Totals: pass:25 fail:0 skip:0 total:25
[   35.532135 ] ok 1 kfence

========================================================

v3:
* Address Huacai's comments.
* Fix a bug that Jackie Liu pointed out.
* Rewrite arch_stack_walk() with the suggestion of Jinyang He.

v2:
* Address Huacai's comments.
* Fix typos in commit message.

Thanks,
Enze

Enze Li (4):
KFENCE: Defer the assignment of the local variable addr
LoongArch: mm: Add page table mapped mode support
LoongArch: Get stack without NMI when providing regs parameter
LoongArch: Add KFENCE support

 arch/loongarch/Kconfig               |  1 +
 arch/loongarch/include/asm/kfence.h  | 66 ++++++++++++++++++++++++++++
 arch/loongarch/include/asm/page.h    |  8 +++-
 arch/loongarch/include/asm/pgtable.h | 16 ++++++-
 arch/loongarch/kernel/stacktrace.c   | 18 ++++----
 arch/loongarch/mm/fault.c            | 22 ++++++----
 arch/loongarch/mm/pgtable.c          |  7 +++
 mm/kfence/core.c                     |  5 ++-
 8 files changed, 123 insertions(+), 20 deletions(-)
 create mode 100644 arch/loongarch/include/asm/kfence.h
Signature · 1 line
2.34.1