|
|
Log in / Subscribe / Register

Add KFENCE support for LoongArch

From:  Enze Li <lienze-AT-kylinos.cn>
To:  chenhuacai-AT-kernel.org, kernel-AT-xen0n.name, loongarch-AT-lists.linux.dev, glider-AT-google.com, elver-AT-google.com, akpm-AT-linux-foundation.org, kasan-dev-AT-googlegroups.com, linux-mm-AT-kvack.org
Subject:  [PATCH 0/4 v2] Add KFENCE support for LoongArch
Date:  Tue, 25 Jul 2023 14:14:47 +0800
Message-ID:  <20230725061451.1231480-1-lienze@kylinos.cn>
Cc:  zhangqing-AT-loongson.cn, yangtiezhu-AT-loongson.cn, dvyukov-AT-google.com, Enze Li <lienze-AT-kylinos.cn>
Archive-link:  Article

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
========================================================

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

Thanks,
Enze

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

 arch/loongarch/Kconfig               |  1 +
 arch/loongarch/include/asm/kfence.h  | 62 ++++++++++++++++++++++++++++
 arch/loongarch/include/asm/page.h    | 19 ++++++++-
 arch/loongarch/include/asm/pgtable.h | 16 ++++++-
 arch/loongarch/kernel/stacktrace.c   | 20 ++++++---
 arch/loongarch/mm/fault.c            | 22 ++++++----
 arch/loongarch/mm/pgtable.c          |  6 +++
 mm/kfence/core.c                     |  5 ++-
 8 files changed, 133 insertions(+), 18 deletions(-)
 create mode 100644 arch/loongarch/include/asm/kfence.h

-- 
2.34.1




Copyright © 2023, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds