2024-02-05 06:09:38

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH 0/2] Update kasan docs and tests

Tiezhu Yang (2):
kasan: docs: Update descriptions about test file and module
kasan: Rename test_kasan_module_init to kasan_test_module_init

Documentation/dev-tools/kasan.rst | 20 +++++++++----------
.../translations/zh_CN/dev-tools/kasan.rst | 20 +++++++++----------
.../translations/zh_TW/dev-tools/kasan.rst | 20 +++++++++----------
mm/kasan/kasan_test_module.c | 4 ++--
4 files changed, 32 insertions(+), 32 deletions(-)

--
2.42.0



2024-02-05 06:09:52

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH 2/2] kasan: Rename test_kasan_module_init to kasan_test_module_init

After commit f7e01ab828fd ("kasan: move tests to mm/kasan/"),
the test module file is renamed from lib/test_kasan_module.c
to mm/kasan/kasan_test_module.c, in order to keep consistent,
rename test_kasan_module_init to kasan_test_module_init.

Signed-off-by: Tiezhu Yang <[email protected]>
---
mm/kasan/kasan_test_module.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/kasan/kasan_test_module.c b/mm/kasan/kasan_test_module.c
index 8b7b3ea2c74e..27ec22767e42 100644
--- a/mm/kasan/kasan_test_module.c
+++ b/mm/kasan/kasan_test_module.c
@@ -62,7 +62,7 @@ static noinline void __init copy_user_test(void)
kfree(kmem);
}

-static int __init test_kasan_module_init(void)
+static int __init kasan_test_module_init(void)
{
/*
* Temporarily enable multi-shot mode. Otherwise, KASAN would only
@@ -77,5 +77,5 @@ static int __init test_kasan_module_init(void)
return -EAGAIN;
}

-module_init(test_kasan_module_init);
+module_init(kasan_test_module_init);
MODULE_LICENSE("GPL");
--
2.42.0


2024-02-05 06:12:23

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH 1/2] kasan: docs: Update descriptions about test file and module

After commit f7e01ab828fd ("kasan: move tests to mm/kasan/"), the test
file is renamed to mm/kasan/kasan_test.c and the test module is renamed
to kasan_test.ko, so update the descriptions in the document.

While at it, update the line number and testcase number when the tests
kmalloc_large_oob_right and kmalloc_double_kzfree failed to sync with
the current code in mm/kasan/kasan_test.c.

Signed-off-by: Tiezhu Yang <[email protected]>
---
Documentation/dev-tools/kasan.rst | 20 +++++++++----------
.../translations/zh_CN/dev-tools/kasan.rst | 20 +++++++++----------
.../translations/zh_TW/dev-tools/kasan.rst | 20 +++++++++----------
3 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
index 858c77fe7dc4..a5a6dbe9029f 100644
--- a/Documentation/dev-tools/kasan.rst
+++ b/Documentation/dev-tools/kasan.rst
@@ -169,7 +169,7 @@ Error reports
A typical KASAN report looks like this::

==================================================================
- BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
+ BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
Write of size 1 at addr ffff8801f44ec37b by task insmod/2760

CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
@@ -179,8 +179,8 @@ A typical KASAN report looks like this::
print_address_description+0x73/0x280
kasan_report+0x144/0x187
__asan_report_store1_noabort+0x17/0x20
- kmalloc_oob_right+0xa8/0xbc [test_kasan]
- kmalloc_tests_init+0x16/0x700 [test_kasan]
+ kmalloc_oob_right+0xa8/0xbc [kasan_test]
+ kmalloc_tests_init+0x16/0x700 [kasan_test]
do_one_initcall+0xa5/0x3ae
do_init_module+0x1b6/0x547
load_module+0x75df/0x8070
@@ -200,8 +200,8 @@ A typical KASAN report looks like this::
save_stack+0x43/0xd0
kasan_kmalloc+0xa7/0xd0
kmem_cache_alloc_trace+0xe1/0x1b0
- kmalloc_oob_right+0x56/0xbc [test_kasan]
- kmalloc_tests_init+0x16/0x700 [test_kasan]
+ kmalloc_oob_right+0x56/0xbc [kasan_test]
+ kmalloc_tests_init+0x16/0x700 [kasan_test]
do_one_initcall+0xa5/0x3ae
do_init_module+0x1b6/0x547
load_module+0x75df/0x8070
@@ -510,15 +510,15 @@ When a test passes::

When a test fails due to a failed ``kmalloc``::

- # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
+ # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
Expected ptr is not null, but is
- not ok 4 - kmalloc_large_oob_right
+ not ok 5 - kmalloc_large_oob_right

When a test fails due to a missing KASAN report::

- # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
+ # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
- not ok 44 - kmalloc_double_kzfree
+ not ok 28 - kmalloc_double_kzfree


At the end the cumulative status of all KASAN tests is printed. On success::
@@ -534,7 +534,7 @@ There are a few ways to run KUnit-compatible KASAN tests.
1. Loadable module

With ``CONFIG_KUNIT`` enabled, KASAN-KUnit tests can be built as a loadable
- module and run by loading ``test_kasan.ko`` with ``insmod`` or ``modprobe``.
+ module and run by loading ``kasan_test.ko`` with ``insmod`` or ``modprobe``.

2. Built-In

diff --git a/Documentation/translations/zh_CN/dev-tools/kasan.rst b/Documentation/translations/zh_CN/dev-tools/kasan.rst
index 8fdb20c9665b..2b1e8f74904b 100644
--- a/Documentation/translations/zh_CN/dev-tools/kasan.rst
+++ b/Documentation/translations/zh_CN/dev-tools/kasan.rst
@@ -137,7 +137,7 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
典型的KASAN报告如下所示::

==================================================================
- BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
+ BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
Write of size 1 at addr ffff8801f44ec37b by task insmod/2760

CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
@@ -147,8 +147,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
print_address_description+0x73/0x280
kasan_report+0x144/0x187
__asan_report_store1_noabort+0x17/0x20
- kmalloc_oob_right+0xa8/0xbc [test_kasan]
- kmalloc_tests_init+0x16/0x700 [test_kasan]
+ kmalloc_oob_right+0xa8/0xbc [kasan_test]
+ kmalloc_tests_init+0x16/0x700 [kasan_test]
do_one_initcall+0xa5/0x3ae
do_init_module+0x1b6/0x547
load_module+0x75df/0x8070
@@ -168,8 +168,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
save_stack+0x43/0xd0
kasan_kmalloc+0xa7/0xd0
kmem_cache_alloc_trace+0xe1/0x1b0
- kmalloc_oob_right+0x56/0xbc [test_kasan]
- kmalloc_tests_init+0x16/0x700 [test_kasan]
+ kmalloc_oob_right+0x56/0xbc [kasan_test]
+ kmalloc_tests_init+0x16/0x700 [kasan_test]
do_one_initcall+0xa5/0x3ae
do_init_module+0x1b6/0x547
load_module+0x75df/0x8070
@@ -421,15 +421,15 @@ KASAN连接到vmap基础架构以懒清理未使用的影子内存。

当由于 ``kmalloc`` 失败而导致测试失败时::

- # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
+ # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
Expected ptr is not null, but is
- not ok 4 - kmalloc_large_oob_right
+ not ok 5 - kmalloc_large_oob_right

当由于缺少KASAN报告而导致测试失败时::

- # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
+ # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
- not ok 44 - kmalloc_double_kzfree
+ not ok 28 - kmalloc_double_kzfree


最后打印所有KASAN测试的累积状态。成功::
@@ -445,7 +445,7 @@ KASAN连接到vmap基础架构以懒清理未使用的影子内存。
1. 可加载模块

启用 ``CONFIG_KUNIT`` 后,KASAN-KUnit测试可以构建为可加载模块,并通过使用
- ``insmod`` 或 ``modprobe`` 加载 ``test_kasan.ko`` 来运行。
+ ``insmod`` 或 ``modprobe`` 加载 ``kasan_test.ko`` 来运行。

2. 内置

diff --git a/Documentation/translations/zh_TW/dev-tools/kasan.rst b/Documentation/translations/zh_TW/dev-tools/kasan.rst
index 979eb84bc58f..ed342e67d8ed 100644
--- a/Documentation/translations/zh_TW/dev-tools/kasan.rst
+++ b/Documentation/translations/zh_TW/dev-tools/kasan.rst
@@ -137,7 +137,7 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
典型的KASAN報告如下所示::

==================================================================
- BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
+ BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
Write of size 1 at addr ffff8801f44ec37b by task insmod/2760

CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
@@ -147,8 +147,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
print_address_description+0x73/0x280
kasan_report+0x144/0x187
__asan_report_store1_noabort+0x17/0x20
- kmalloc_oob_right+0xa8/0xbc [test_kasan]
- kmalloc_tests_init+0x16/0x700 [test_kasan]
+ kmalloc_oob_right+0xa8/0xbc [kasan_test]
+ kmalloc_tests_init+0x16/0x700 [kasan_test]
do_one_initcall+0xa5/0x3ae
do_init_module+0x1b6/0x547
load_module+0x75df/0x8070
@@ -168,8 +168,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
save_stack+0x43/0xd0
kasan_kmalloc+0xa7/0xd0
kmem_cache_alloc_trace+0xe1/0x1b0
- kmalloc_oob_right+0x56/0xbc [test_kasan]
- kmalloc_tests_init+0x16/0x700 [test_kasan]
+ kmalloc_oob_right+0x56/0xbc [kasan_test]
+ kmalloc_tests_init+0x16/0x700 [kasan_test]
do_one_initcall+0xa5/0x3ae
do_init_module+0x1b6/0x547
load_module+0x75df/0x8070
@@ -421,15 +421,15 @@ KASAN連接到vmap基礎架構以懶清理未使用的影子內存。

當由於 ``kmalloc`` 失敗而導致測試失敗時::

- # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
+ # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
Expected ptr is not null, but is
- not ok 4 - kmalloc_large_oob_right
+ not ok 5 - kmalloc_large_oob_right

當由於缺少KASAN報告而導致測試失敗時::

- # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
+ # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
- not ok 44 - kmalloc_double_kzfree
+ not ok 28 - kmalloc_double_kzfree


最後打印所有KASAN測試的累積狀態。成功::
@@ -445,7 +445,7 @@ KASAN連接到vmap基礎架構以懶清理未使用的影子內存。
1. 可加載模塊

啓用 ``CONFIG_KUNIT`` 後,KASAN-KUnit測試可以構建爲可加載模塊,並通過使用
- ``insmod`` 或 ``modprobe`` 加載 ``test_kasan.ko`` 來運行。
+ ``insmod`` 或 ``modprobe`` 加載 ``kasan_test.ko`` 來運行。

2. 內置

--
2.42.0


2024-02-05 12:35:46

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH 1/2] kasan: docs: Update descriptions about test file and module

On Mon, 5 Feb 2024 at 07:09, Tiezhu Yang <[email protected]> wrote:
>
> After commit f7e01ab828fd ("kasan: move tests to mm/kasan/"), the test
> file is renamed to mm/kasan/kasan_test.c and the test module is renamed
> to kasan_test.ko, so update the descriptions in the document.
>
> While at it, update the line number and testcase number when the tests
> kmalloc_large_oob_right and kmalloc_double_kzfree failed to sync with
> the current code in mm/kasan/kasan_test.c.
>
> Signed-off-by: Tiezhu Yang <[email protected]>

Acked-by: Marco Elver <[email protected]>

Thanks for cleaning this up.

> ---
> Documentation/dev-tools/kasan.rst | 20 +++++++++----------
> .../translations/zh_CN/dev-tools/kasan.rst | 20 +++++++++----------
> .../translations/zh_TW/dev-tools/kasan.rst | 20 +++++++++----------
> 3 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
> index 858c77fe7dc4..a5a6dbe9029f 100644
> --- a/Documentation/dev-tools/kasan.rst
> +++ b/Documentation/dev-tools/kasan.rst
> @@ -169,7 +169,7 @@ Error reports
> A typical KASAN report looks like this::
>
> ==================================================================
> - BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
> + BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
> Write of size 1 at addr ffff8801f44ec37b by task insmod/2760
>
> CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
> @@ -179,8 +179,8 @@ A typical KASAN report looks like this::
> print_address_description+0x73/0x280
> kasan_report+0x144/0x187
> __asan_report_store1_noabort+0x17/0x20
> - kmalloc_oob_right+0xa8/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0xa8/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -200,8 +200,8 @@ A typical KASAN report looks like this::
> save_stack+0x43/0xd0
> kasan_kmalloc+0xa7/0xd0
> kmem_cache_alloc_trace+0xe1/0x1b0
> - kmalloc_oob_right+0x56/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0x56/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -510,15 +510,15 @@ When a test passes::
>
> When a test fails due to a failed ``kmalloc``::
>
> - # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
> + # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
> Expected ptr is not null, but is
> - not ok 4 - kmalloc_large_oob_right
> + not ok 5 - kmalloc_large_oob_right
>
> When a test fails due to a missing KASAN report::
>
> - # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
> + # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
> KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
> - not ok 44 - kmalloc_double_kzfree
> + not ok 28 - kmalloc_double_kzfree
>
>
> At the end the cumulative status of all KASAN tests is printed. On success::
> @@ -534,7 +534,7 @@ There are a few ways to run KUnit-compatible KASAN tests.
> 1. Loadable module
>
> With ``CONFIG_KUNIT`` enabled, KASAN-KUnit tests can be built as a loadable
> - module and run by loading ``test_kasan.ko`` with ``insmod`` or ``modprobe``.
> + module and run by loading ``kasan_test.ko`` with ``insmod`` or ``modprobe``.
>
> 2. Built-In
>
> diff --git a/Documentation/translations/zh_CN/dev-tools/kasan.rst b/Documentation/translations/zh_CN/dev-tools/kasan.rst
> index 8fdb20c9665b..2b1e8f74904b 100644
> --- a/Documentation/translations/zh_CN/dev-tools/kasan.rst
> +++ b/Documentation/translations/zh_CN/dev-tools/kasan.rst
> @@ -137,7 +137,7 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
> 典型的KASAN报告如下所示::
>
> ==================================================================
> - BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
> + BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
> Write of size 1 at addr ffff8801f44ec37b by task insmod/2760
>
> CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
> @@ -147,8 +147,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
> print_address_description+0x73/0x280
> kasan_report+0x144/0x187
> __asan_report_store1_noabort+0x17/0x20
> - kmalloc_oob_right+0xa8/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0xa8/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -168,8 +168,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
> save_stack+0x43/0xd0
> kasan_kmalloc+0xa7/0xd0
> kmem_cache_alloc_trace+0xe1/0x1b0
> - kmalloc_oob_right+0x56/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0x56/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -421,15 +421,15 @@ KASAN连接到vmap基础架构以懒清理未使用的影子内存。
>
> 当由于 ``kmalloc`` 失败而导致测试失败时::
>
> - # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
> + # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
> Expected ptr is not null, but is
> - not ok 4 - kmalloc_large_oob_right
> + not ok 5 - kmalloc_large_oob_right
>
> 当由于缺少KASAN报告而导致测试失败时::
>
> - # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
> + # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
> KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
> - not ok 44 - kmalloc_double_kzfree
> + not ok 28 - kmalloc_double_kzfree
>
>
> 最后打印所有KASAN测试的累积状态。成功::
> @@ -445,7 +445,7 @@ KASAN连接到vmap基础架构以懒清理未使用的影子内存。
> 1. 可加载模块
>
> 启用 ``CONFIG_KUNIT`` 后,KASAN-KUnit测试可以构建为可加载模块,并通过使用
> - ``insmod`` 或 ``modprobe`` 加载 ``test_kasan.ko`` 来运行。
> + ``insmod`` 或 ``modprobe`` 加载 ``kasan_test.ko`` 来运行。
>
> 2. 内置
>
> diff --git a/Documentation/translations/zh_TW/dev-tools/kasan.rst b/Documentation/translations/zh_TW/dev-tools/kasan.rst
> index 979eb84bc58f..ed342e67d8ed 100644
> --- a/Documentation/translations/zh_TW/dev-tools/kasan.rst
> +++ b/Documentation/translations/zh_TW/dev-tools/kasan.rst
> @@ -137,7 +137,7 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
> 典型的KASAN報告如下所示::
>
> ==================================================================
> - BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
> + BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
> Write of size 1 at addr ffff8801f44ec37b by task insmod/2760
>
> CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
> @@ -147,8 +147,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
> print_address_description+0x73/0x280
> kasan_report+0x144/0x187
> __asan_report_store1_noabort+0x17/0x20
> - kmalloc_oob_right+0xa8/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0xa8/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -168,8 +168,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
> save_stack+0x43/0xd0
> kasan_kmalloc+0xa7/0xd0
> kmem_cache_alloc_trace+0xe1/0x1b0
> - kmalloc_oob_right+0x56/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0x56/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -421,15 +421,15 @@ KASAN連接到vmap基礎架構以懶清理未使用的影子內存。
>
> 當由於 ``kmalloc`` 失敗而導致測試失敗時::
>
> - # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
> + # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
> Expected ptr is not null, but is
> - not ok 4 - kmalloc_large_oob_right
> + not ok 5 - kmalloc_large_oob_right
>
> 當由於缺少KASAN報告而導致測試失敗時::
>
> - # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
> + # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
> KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
> - not ok 44 - kmalloc_double_kzfree
> + not ok 28 - kmalloc_double_kzfree
>
>
> 最後打印所有KASAN測試的累積狀態。成功::
> @@ -445,7 +445,7 @@ KASAN連接到vmap基礎架構以懶清理未使用的影子內存。
> 1. 可加載模塊
>
> 啓用 ``CONFIG_KUNIT`` 後,KASAN-KUnit測試可以構建爲可加載模塊,並通過使用
> - ``insmod`` 或 ``modprobe`` 加載 ``test_kasan.ko`` 來運行。
> + ``insmod`` 或 ``modprobe`` 加載 ``kasan_test.ko`` 來運行。
>
> 2. 內置
>
> --
> 2.42.0
>

2024-02-05 13:00:56

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH 2/2] kasan: Rename test_kasan_module_init to kasan_test_module_init

On Mon, 5 Feb 2024 at 07:09, Tiezhu Yang <[email protected]> wrote:
>
> After commit f7e01ab828fd ("kasan: move tests to mm/kasan/"),
> the test module file is renamed from lib/test_kasan_module.c
> to mm/kasan/kasan_test_module.c, in order to keep consistent,
> rename test_kasan_module_init to kasan_test_module_init.
>
> Signed-off-by: Tiezhu Yang <[email protected]>

Seems reasonable:

Acked-by: Marco Elver <[email protected]>

> ---
> mm/kasan/kasan_test_module.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/kasan/kasan_test_module.c b/mm/kasan/kasan_test_module.c
> index 8b7b3ea2c74e..27ec22767e42 100644
> --- a/mm/kasan/kasan_test_module.c
> +++ b/mm/kasan/kasan_test_module.c
> @@ -62,7 +62,7 @@ static noinline void __init copy_user_test(void)
> kfree(kmem);
> }
>
> -static int __init test_kasan_module_init(void)
> +static int __init kasan_test_module_init(void)
> {
> /*
> * Temporarily enable multi-shot mode. Otherwise, KASAN would only
> @@ -77,5 +77,5 @@ static int __init test_kasan_module_init(void)
> return -EAGAIN;
> }
>
> -module_init(test_kasan_module_init);
> +module_init(kasan_test_module_init);
> MODULE_LICENSE("GPL");
> --
> 2.42.0
>
> --
> You received this message because you are subscribed to the Google Groups "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20240205060925.15594-3-yangtiezhu%40loongson.cn.

2024-02-05 21:59:10

by Andrey Konovalov

[permalink] [raw]
Subject: Re: [PATCH 2/2] kasan: Rename test_kasan_module_init to kasan_test_module_init

On Mon, Feb 5, 2024 at 7:09 AM Tiezhu Yang <[email protected]> wrote:
>
> After commit f7e01ab828fd ("kasan: move tests to mm/kasan/"),
> the test module file is renamed from lib/test_kasan_module.c
> to mm/kasan/kasan_test_module.c, in order to keep consistent,
> rename test_kasan_module_init to kasan_test_module_init.
>
> Signed-off-by: Tiezhu Yang <[email protected]>
> ---
> mm/kasan/kasan_test_module.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/kasan/kasan_test_module.c b/mm/kasan/kasan_test_module.c
> index 8b7b3ea2c74e..27ec22767e42 100644
> --- a/mm/kasan/kasan_test_module.c
> +++ b/mm/kasan/kasan_test_module.c
> @@ -62,7 +62,7 @@ static noinline void __init copy_user_test(void)
> kfree(kmem);
> }
>
> -static int __init test_kasan_module_init(void)
> +static int __init kasan_test_module_init(void)
> {
> /*
> * Temporarily enable multi-shot mode. Otherwise, KASAN would only
> @@ -77,5 +77,5 @@ static int __init test_kasan_module_init(void)
> return -EAGAIN;
> }
>
> -module_init(test_kasan_module_init);
> +module_init(kasan_test_module_init);
> MODULE_LICENSE("GPL");
> --
> 2.42.0
>

Reviewed-by: Andrey Konovalov <[email protected]>

Thanks!

2024-02-05 22:05:30

by Andrey Konovalov

[permalink] [raw]
Subject: Re: [PATCH 1/2] kasan: docs: Update descriptions about test file and module

On Mon, Feb 5, 2024 at 7:09 AM Tiezhu Yang <[email protected]> wrote:
>
> After commit f7e01ab828fd ("kasan: move tests to mm/kasan/"), the test
> file is renamed to mm/kasan/kasan_test.c and the test module is renamed
> to kasan_test.ko, so update the descriptions in the document.
>
> While at it, update the line number and testcase number when the tests
> kmalloc_large_oob_right and kmalloc_double_kzfree failed to sync with
> the current code in mm/kasan/kasan_test.c.
>
> Signed-off-by: Tiezhu Yang <[email protected]>
> ---
> Documentation/dev-tools/kasan.rst | 20 +++++++++----------
> .../translations/zh_CN/dev-tools/kasan.rst | 20 +++++++++----------
> .../translations/zh_TW/dev-tools/kasan.rst | 20 +++++++++----------
> 3 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
> index 858c77fe7dc4..a5a6dbe9029f 100644
> --- a/Documentation/dev-tools/kasan.rst
> +++ b/Documentation/dev-tools/kasan.rst
> @@ -169,7 +169,7 @@ Error reports
> A typical KASAN report looks like this::
>
> ==================================================================
> - BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
> + BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
> Write of size 1 at addr ffff8801f44ec37b by task insmod/2760
>
> CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
> @@ -179,8 +179,8 @@ A typical KASAN report looks like this::
> print_address_description+0x73/0x280
> kasan_report+0x144/0x187
> __asan_report_store1_noabort+0x17/0x20
> - kmalloc_oob_right+0xa8/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0xa8/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -200,8 +200,8 @@ A typical KASAN report looks like this::
> save_stack+0x43/0xd0
> kasan_kmalloc+0xa7/0xd0
> kmem_cache_alloc_trace+0xe1/0x1b0
> - kmalloc_oob_right+0x56/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0x56/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -510,15 +510,15 @@ When a test passes::
>
> When a test fails due to a failed ``kmalloc``::
>
> - # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
> + # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
> Expected ptr is not null, but is
> - not ok 4 - kmalloc_large_oob_right
> + not ok 5 - kmalloc_large_oob_right
>
> When a test fails due to a missing KASAN report::
>
> - # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
> + # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
> KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
> - not ok 44 - kmalloc_double_kzfree
> + not ok 28 - kmalloc_double_kzfree
>
>
> At the end the cumulative status of all KASAN tests is printed. On success::
> @@ -534,7 +534,7 @@ There are a few ways to run KUnit-compatible KASAN tests.
> 1. Loadable module
>
> With ``CONFIG_KUNIT`` enabled, KASAN-KUnit tests can be built as a loadable
> - module and run by loading ``test_kasan.ko`` with ``insmod`` or ``modprobe``.
> + module and run by loading ``kasan_test.ko`` with ``insmod`` or ``modprobe``.
>
> 2. Built-In
>
> diff --git a/Documentation/translations/zh_CN/dev-tools/kasan.rst b/Documentation/translations/zh_CN/dev-tools/kasan.rst
> index 8fdb20c9665b..2b1e8f74904b 100644
> --- a/Documentation/translations/zh_CN/dev-tools/kasan.rst
> +++ b/Documentation/translations/zh_CN/dev-tools/kasan.rst
> @@ -137,7 +137,7 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
> 典型的KASAN报告如下所示::
>
> ==================================================================
> - BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
> + BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
> Write of size 1 at addr ffff8801f44ec37b by task insmod/2760
>
> CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
> @@ -147,8 +147,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
> print_address_description+0x73/0x280
> kasan_report+0x144/0x187
> __asan_report_store1_noabort+0x17/0x20
> - kmalloc_oob_right+0xa8/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0xa8/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -168,8 +168,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行参数的影响。当它被启用
> save_stack+0x43/0xd0
> kasan_kmalloc+0xa7/0xd0
> kmem_cache_alloc_trace+0xe1/0x1b0
> - kmalloc_oob_right+0x56/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0x56/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -421,15 +421,15 @@ KASAN连接到vmap基础架构以懒清理未使用的影子内存。
>
> 当由于 ``kmalloc`` 失败而导致测试失败时::
>
> - # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
> + # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
> Expected ptr is not null, but is
> - not ok 4 - kmalloc_large_oob_right
> + not ok 5 - kmalloc_large_oob_right
>
> 当由于缺少KASAN报告而导致测试失败时::
>
> - # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
> + # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
> KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
> - not ok 44 - kmalloc_double_kzfree
> + not ok 28 - kmalloc_double_kzfree
>
>
> 最后打印所有KASAN测试的累积状态。成功::
> @@ -445,7 +445,7 @@ KASAN连接到vmap基础架构以懒清理未使用的影子内存。
> 1. 可加载模块
>
> 启用 ``CONFIG_KUNIT`` 后,KASAN-KUnit测试可以构建为可加载模块,并通过使用
> - ``insmod`` 或 ``modprobe`` 加载 ``test_kasan.ko`` 来运行。
> + ``insmod`` 或 ``modprobe`` 加载 ``kasan_test.ko`` 来运行。
>
> 2. 内置
>
> diff --git a/Documentation/translations/zh_TW/dev-tools/kasan.rst b/Documentation/translations/zh_TW/dev-tools/kasan.rst
> index 979eb84bc58f..ed342e67d8ed 100644
> --- a/Documentation/translations/zh_TW/dev-tools/kasan.rst
> +++ b/Documentation/translations/zh_TW/dev-tools/kasan.rst
> @@ -137,7 +137,7 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
> 典型的KASAN報告如下所示::
>
> ==================================================================
> - BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
> + BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [kasan_test]
> Write of size 1 at addr ffff8801f44ec37b by task insmod/2760
>
> CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
> @@ -147,8 +147,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
> print_address_description+0x73/0x280
> kasan_report+0x144/0x187
> __asan_report_store1_noabort+0x17/0x20
> - kmalloc_oob_right+0xa8/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0xa8/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -168,8 +168,8 @@ KASAN受到通用 ``panic_on_warn`` 命令行參數的影響。當它被啓用
> save_stack+0x43/0xd0
> kasan_kmalloc+0xa7/0xd0
> kmem_cache_alloc_trace+0xe1/0x1b0
> - kmalloc_oob_right+0x56/0xbc [test_kasan]
> - kmalloc_tests_init+0x16/0x700 [test_kasan]
> + kmalloc_oob_right+0x56/0xbc [kasan_test]
> + kmalloc_tests_init+0x16/0x700 [kasan_test]
> do_one_initcall+0xa5/0x3ae
> do_init_module+0x1b6/0x547
> load_module+0x75df/0x8070
> @@ -421,15 +421,15 @@ KASAN連接到vmap基礎架構以懶清理未使用的影子內存。
>
> 當由於 ``kmalloc`` 失敗而導致測試失敗時::
>
> - # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
> + # kmalloc_large_oob_right: ASSERTION FAILED at mm/kasan/kasan_test.c:245
> Expected ptr is not null, but is
> - not ok 4 - kmalloc_large_oob_right
> + not ok 5 - kmalloc_large_oob_right
>
> 當由於缺少KASAN報告而導致測試失敗時::
>
> - # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:974
> + # kmalloc_double_kzfree: EXPECTATION FAILED at mm/kasan/kasan_test.c:709
> KASAN failure expected in "kfree_sensitive(ptr)", but none occurred
> - not ok 44 - kmalloc_double_kzfree
> + not ok 28 - kmalloc_double_kzfree
>
>
> 最後打印所有KASAN測試的累積狀態。成功::
> @@ -445,7 +445,7 @@ KASAN連接到vmap基礎架構以懶清理未使用的影子內存。
> 1. 可加載模塊
>
> 啓用 ``CONFIG_KUNIT`` 後,KASAN-KUnit測試可以構建爲可加載模塊,並通過使用
> - ``insmod`` 或 ``modprobe`` 加載 ``test_kasan.ko`` 來運行。
> + ``insmod`` 或 ``modprobe`` 加載 ``kasan_test.ko`` 來運行。
>
> 2. 內置
>
> --
> 2.42.0

Reviewed-by: Andrey Konovalov <[email protected]>