* [PATCH 0/5] kasan: assorted fixes and improvements
@ 2023-10-06 15:18 andrey.konovalov
2023-10-06 15:18 ` [PATCH 1/5] arm64, kasan: update comment in kasan_init andrey.konovalov
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: andrey.konovalov @ 2023-10-06 15:18 UTC (permalink / raw)
To: Marco Elver, Alexander Potapenko
Cc: Andrey Konovalov, Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
Andrew Morton, linux-mm, linux-kernel, Andrey Konovalov
From: Andrey Konovalov <andreyknvl@google.com>
Andrey Konovalov (5):
arm64, kasan: update comment in kasan_init
kasan: unify printk prefixes
kasan: use unchecked __memset internally
kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment
Documentation: *san: drop "the" from article titles
Documentation/dev-tools/kasan.rst | 7 +++++--
Documentation/dev-tools/kcsan.rst | 4 ++--
Documentation/dev-tools/kmsan.rst | 6 +++---
arch/arm64/mm/kasan_init.c | 6 +++++-
mm/kasan/kasan_test.c | 11 ++++++-----
mm/kasan/kasan_test_module.c | 2 +-
mm/kasan/quarantine.c | 4 +++-
mm/kasan/report.c | 4 ++--
mm/kasan/report_generic.c | 6 +++---
mm/kasan/shadow.c | 2 +-
10 files changed, 31 insertions(+), 21 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/5] arm64, kasan: update comment in kasan_init
2023-10-06 15:18 [PATCH 0/5] kasan: assorted fixes and improvements andrey.konovalov
@ 2023-10-06 15:18 ` andrey.konovalov
2023-10-06 15:18 ` [PATCH 2/5] kasan: unify printk prefixes andrey.konovalov
` (3 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: andrey.konovalov @ 2023-10-06 15:18 UTC (permalink / raw)
To: Marco Elver, Alexander Potapenko
Cc: Andrey Konovalov, Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
Andrew Morton, linux-mm, linux-kernel, Andrey Konovalov
From: Andrey Konovalov <andreyknvl@google.com>
Update the comment in kasan_init to also mention the Hardware Tag-Based
KASAN mode.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
arch/arm64/mm/kasan_init.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c
index f17d066e85eb..555285ebd5af 100644
--- a/arch/arm64/mm/kasan_init.c
+++ b/arch/arm64/mm/kasan_init.c
@@ -300,7 +300,11 @@ void __init kasan_init(void)
kasan_init_shadow();
kasan_init_depth();
#if defined(CONFIG_KASAN_GENERIC)
- /* CONFIG_KASAN_SW_TAGS also requires kasan_init_sw_tags(). */
+ /*
+ * Generic KASAN is now fully initialized.
+ * Software and Hardware Tag-Based modes still require
+ * kasan_init_sw_tags() and kasan_init_hw_tags() correspondingly.
+ */
pr_info("KernelAddressSanitizer initialized (generic)\n");
#endif
}
--
2.25.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/5] kasan: unify printk prefixes
2023-10-06 15:18 [PATCH 0/5] kasan: assorted fixes and improvements andrey.konovalov
2023-10-06 15:18 ` [PATCH 1/5] arm64, kasan: update comment in kasan_init andrey.konovalov
@ 2023-10-06 15:18 ` andrey.konovalov
2023-10-09 8:43 ` Marco Elver
2023-10-06 15:18 ` [PATCH 3/5] kasan: use unchecked __memset internally andrey.konovalov
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: andrey.konovalov @ 2023-10-06 15:18 UTC (permalink / raw)
To: Marco Elver, Alexander Potapenko
Cc: Andrey Konovalov, Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
Andrew Morton, linux-mm, linux-kernel, Andrey Konovalov
From: Andrey Konovalov <andreyknvl@google.com>
Unify prefixes for printk messages in mm/kasan/.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
mm/kasan/kasan_test.c | 2 +-
mm/kasan/kasan_test_module.c | 2 +-
mm/kasan/quarantine.c | 4 +++-
mm/kasan/report_generic.c | 6 +++---
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c
index b61cc6a42541..c707d6c6e019 100644
--- a/mm/kasan/kasan_test.c
+++ b/mm/kasan/kasan_test.c
@@ -5,7 +5,7 @@
* Author: Andrey Ryabinin <a.ryabinin@samsung.com>
*/
-#define pr_fmt(fmt) "kasan_test: " fmt
+#define pr_fmt(fmt) "kasan: test: " fmt
#include <kunit/test.h>
#include <linux/bitops.h>
diff --git a/mm/kasan/kasan_test_module.c b/mm/kasan/kasan_test_module.c
index 7be7bed456ef..8b7b3ea2c74e 100644
--- a/mm/kasan/kasan_test_module.c
+++ b/mm/kasan/kasan_test_module.c
@@ -5,7 +5,7 @@
* Author: Andrey Ryabinin <a.ryabinin@samsung.com>
*/
-#define pr_fmt(fmt) "kasan test: %s " fmt, __func__
+#define pr_fmt(fmt) "kasan: test: " fmt
#include <linux/mman.h>
#include <linux/module.h>
diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c
index 152dca73f398..ca4529156735 100644
--- a/mm/kasan/quarantine.c
+++ b/mm/kasan/quarantine.c
@@ -8,6 +8,8 @@
* Based on code by Dmitry Chernenkov.
*/
+#define pr_fmt(fmt) "kasan: " fmt
+
#include <linux/gfp.h>
#include <linux/hash.h>
#include <linux/kernel.h>
@@ -414,7 +416,7 @@ static int __init kasan_cpu_quarantine_init(void)
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mm/kasan:online",
kasan_cpu_online, kasan_cpu_offline);
if (ret < 0)
- pr_err("kasan cpu quarantine register failed [%d]\n", ret);
+ pr_err("cpu quarantine register failed [%d]\n", ret);
return ret;
}
late_initcall(kasan_cpu_quarantine_init);
diff --git a/mm/kasan/report_generic.c b/mm/kasan/report_generic.c
index 51a1e8a8877f..99cbcd73cff7 100644
--- a/mm/kasan/report_generic.c
+++ b/mm/kasan/report_generic.c
@@ -220,7 +220,7 @@ static bool __must_check tokenize_frame_descr(const char **frame_descr,
const size_t tok_len = sep - *frame_descr;
if (tok_len + 1 > max_tok_len) {
- pr_err("KASAN internal error: frame description too long: %s\n",
+ pr_err("internal error: frame description too long: %s\n",
*frame_descr);
return false;
}
@@ -233,7 +233,7 @@ static bool __must_check tokenize_frame_descr(const char **frame_descr,
*frame_descr = sep + 1;
if (value != NULL && kstrtoul(token, 10, value)) {
- pr_err("KASAN internal error: not a valid number: %s\n", token);
+ pr_err("internal error: not a valid number: %s\n", token);
return false;
}
@@ -323,7 +323,7 @@ static bool __must_check get_address_stack_frame_info(const void *addr,
frame = (const unsigned long *)(mem_ptr + KASAN_GRANULE_SIZE);
if (frame[0] != KASAN_CURRENT_STACK_FRAME_MAGIC) {
- pr_err("KASAN internal error: frame info validation failed; invalid marker: %lu\n",
+ pr_err("internal error: frame has invalid marker: %lu\n",
frame[0]);
return false;
}
--
2.25.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/5] kasan: use unchecked __memset internally
2023-10-06 15:18 [PATCH 0/5] kasan: assorted fixes and improvements andrey.konovalov
2023-10-06 15:18 ` [PATCH 1/5] arm64, kasan: update comment in kasan_init andrey.konovalov
2023-10-06 15:18 ` [PATCH 2/5] kasan: unify printk prefixes andrey.konovalov
@ 2023-10-06 15:18 ` andrey.konovalov
2023-10-09 8:45 ` Marco Elver
2023-10-06 15:18 ` [PATCH 4/5] kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment andrey.konovalov
2023-10-06 15:18 ` [PATCH 5/5] Documentation: *san: drop "the" from article titles andrey.konovalov
4 siblings, 1 reply; 13+ messages in thread
From: andrey.konovalov @ 2023-10-06 15:18 UTC (permalink / raw)
To: Marco Elver, Alexander Potapenko
Cc: Andrey Konovalov, Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
Andrew Morton, linux-mm, linux-kernel, Andrey Konovalov
From: Andrey Konovalov <andreyknvl@google.com>
KASAN code is supposed to use the unchecked __memset implementation when
accessing its metadata.
Change uses of memset to __memset in mm/kasan/.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
mm/kasan/report.c | 4 ++--
mm/kasan/shadow.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index ca4b6ff080a6..12557ffee90b 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -538,7 +538,7 @@ void kasan_report_invalid_free(void *ptr, unsigned long ip, enum kasan_report_ty
start_report(&flags, true);
- memset(&info, 0, sizeof(info));
+ __memset(&info, 0, sizeof(info));
info.type = type;
info.access_addr = ptr;
info.access_size = 0;
@@ -576,7 +576,7 @@ bool kasan_report(const void *addr, size_t size, bool is_write,
start_report(&irq_flags, true);
- memset(&info, 0, sizeof(info));
+ __memset(&info, 0, sizeof(info));
info.type = KASAN_REPORT_ACCESS;
info.access_addr = addr;
info.access_size = size;
diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c
index dd772f9d0f08..d687f09a7ae3 100644
--- a/mm/kasan/shadow.c
+++ b/mm/kasan/shadow.c
@@ -324,7 +324,7 @@ static int kasan_populate_vmalloc_pte(pte_t *ptep, unsigned long addr,
if (!page)
return -ENOMEM;
- memset((void *)page, KASAN_VMALLOC_INVALID, PAGE_SIZE);
+ __memset((void *)page, KASAN_VMALLOC_INVALID, PAGE_SIZE);
pte = pfn_pte(PFN_DOWN(__pa(page)), PAGE_KERNEL);
spin_lock(&init_mm.page_table_lock);
--
2.25.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/5] kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment
2023-10-06 15:18 [PATCH 0/5] kasan: assorted fixes and improvements andrey.konovalov
` (2 preceding siblings ...)
2023-10-06 15:18 ` [PATCH 3/5] kasan: use unchecked __memset internally andrey.konovalov
@ 2023-10-06 15:18 ` andrey.konovalov
2023-10-09 8:47 ` Marco Elver
2023-10-06 15:18 ` [PATCH 5/5] Documentation: *san: drop "the" from article titles andrey.konovalov
4 siblings, 1 reply; 13+ messages in thread
From: andrey.konovalov @ 2023-10-06 15:18 UTC (permalink / raw)
To: Marco Elver, Alexander Potapenko
Cc: Andrey Konovalov, Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
Andrew Morton, linux-mm, linux-kernel, Andrey Konovalov,
kernel test robot
From: Andrey Konovalov <andreyknvl@google.com>
Update the comment for KUNIT_EXPECT_KASAN_FAIL to describe the parameters
this macro accepts.
Also drop the mention of the "kasan_status" KUnit resource, as it no
longer exists.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308171757.7V5YUcje-lkp@intel.com/
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
mm/kasan/kasan_test.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c
index c707d6c6e019..2030c7ff7de9 100644
--- a/mm/kasan/kasan_test.c
+++ b/mm/kasan/kasan_test.c
@@ -91,10 +91,11 @@ static void kasan_test_exit(struct kunit *test)
}
/**
- * KUNIT_EXPECT_KASAN_FAIL() - check that the executed expression produces a
- * KASAN report; causes a test failure otherwise. This relies on a KUnit
- * resource named "kasan_status". Do not use this name for KUnit resources
- * outside of KASAN tests.
+ * KUNIT_EXPECT_KASAN_FAIL - check that the executed expression produces a
+ * KASAN report; causes a KUnit test failure otherwise.
+ *
+ * @test: Currently executing KUnit test.
+ * @expression: Expression that must produce a KASAN report.
*
* For hardware tag-based KASAN, when a synchronous tag fault happens, tag
* checking is auto-disabled. When this happens, this test handler reenables
--
2.25.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 5/5] Documentation: *san: drop "the" from article titles
2023-10-06 15:18 [PATCH 0/5] kasan: assorted fixes and improvements andrey.konovalov
` (3 preceding siblings ...)
2023-10-06 15:18 ` [PATCH 4/5] kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment andrey.konovalov
@ 2023-10-06 15:18 ` andrey.konovalov
2023-10-07 7:01 ` Marco Elver
4 siblings, 1 reply; 13+ messages in thread
From: andrey.konovalov @ 2023-10-06 15:18 UTC (permalink / raw)
To: Marco Elver, Alexander Potapenko
Cc: Andrey Konovalov, Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
Andrew Morton, linux-mm, linux-kernel, Andrey Konovalov
From: Andrey Konovalov <andreyknvl@google.com>
Drop "the" from the titles of documentation articles for KASAN, KCSAN,
and KMSAN, as it is redundant.
Also add SPDX-License-Identifier for kasan.rst.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
Documentation/dev-tools/kasan.rst | 7 +++++--
Documentation/dev-tools/kcsan.rst | 4 ++--
Documentation/dev-tools/kmsan.rst | 6 +++---
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
index 382818a7197a..858c77fe7dc4 100644
--- a/Documentation/dev-tools/kasan.rst
+++ b/Documentation/dev-tools/kasan.rst
@@ -1,5 +1,8 @@
-The Kernel Address Sanitizer (KASAN)
-====================================
+.. SPDX-License-Identifier: GPL-2.0
+.. Copyright (C) 2023, Google LLC.
+
+Kernel Address Sanitizer (KASAN)
+================================
Overview
--------
diff --git a/Documentation/dev-tools/kcsan.rst b/Documentation/dev-tools/kcsan.rst
index 3ae866dcc924..94b6802ab0ab 100644
--- a/Documentation/dev-tools/kcsan.rst
+++ b/Documentation/dev-tools/kcsan.rst
@@ -1,8 +1,8 @@
.. SPDX-License-Identifier: GPL-2.0
.. Copyright (C) 2019, Google LLC.
-The Kernel Concurrency Sanitizer (KCSAN)
-========================================
+Kernel Concurrency Sanitizer (KCSAN)
+====================================
The Kernel Concurrency Sanitizer (KCSAN) is a dynamic race detector, which
relies on compile-time instrumentation, and uses a watchpoint-based sampling
diff --git a/Documentation/dev-tools/kmsan.rst b/Documentation/dev-tools/kmsan.rst
index 55fa82212eb2..323eedad53cd 100644
--- a/Documentation/dev-tools/kmsan.rst
+++ b/Documentation/dev-tools/kmsan.rst
@@ -1,9 +1,9 @@
.. SPDX-License-Identifier: GPL-2.0
.. Copyright (C) 2022, Google LLC.
-===================================
-The Kernel Memory Sanitizer (KMSAN)
-===================================
+===============================
+Kernel Memory Sanitizer (KMSAN)
+===============================
KMSAN is a dynamic error detector aimed at finding uses of uninitialized
values. It is based on compiler instrumentation, and is quite similar to the
--
2.25.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/5] Documentation: *san: drop "the" from article titles
2023-10-06 15:18 ` [PATCH 5/5] Documentation: *san: drop "the" from article titles andrey.konovalov
@ 2023-10-07 7:01 ` Marco Elver
2023-10-09 19:44 ` Andrey Konovalov
0 siblings, 1 reply; 13+ messages in thread
From: Marco Elver @ 2023-10-07 7:01 UTC (permalink / raw)
To: andrey.konovalov
Cc: Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Andrey Ryabinin, kasan-dev, Andrew Morton, linux-mm,
linux-kernel, Andrey Konovalov
On Fri, 6 Oct 2023 at 17:18, <andrey.konovalov@linux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@google.com>
>
> Drop "the" from the titles of documentation articles for KASAN, KCSAN,
> and KMSAN, as it is redundant.
>
> Also add SPDX-License-Identifier for kasan.rst.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> Documentation/dev-tools/kasan.rst | 7 +++++--
> Documentation/dev-tools/kcsan.rst | 4 ++--
> Documentation/dev-tools/kmsan.rst | 6 +++---
UBSan also has it: https://docs.kernel.org/dev-tools/ubsan.html
Reviewed-by: Marco Elver <elver@google.com>
> 3 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
> index 382818a7197a..858c77fe7dc4 100644
> --- a/Documentation/dev-tools/kasan.rst
> +++ b/Documentation/dev-tools/kasan.rst
> @@ -1,5 +1,8 @@
> -The Kernel Address Sanitizer (KASAN)
> -====================================
> +.. SPDX-License-Identifier: GPL-2.0
> +.. Copyright (C) 2023, Google LLC.
> +
> +Kernel Address Sanitizer (KASAN)
> +================================
>
> Overview
> --------
> diff --git a/Documentation/dev-tools/kcsan.rst b/Documentation/dev-tools/kcsan.rst
> index 3ae866dcc924..94b6802ab0ab 100644
> --- a/Documentation/dev-tools/kcsan.rst
> +++ b/Documentation/dev-tools/kcsan.rst
> @@ -1,8 +1,8 @@
> .. SPDX-License-Identifier: GPL-2.0
> .. Copyright (C) 2019, Google LLC.
>
> -The Kernel Concurrency Sanitizer (KCSAN)
> -========================================
> +Kernel Concurrency Sanitizer (KCSAN)
> +====================================
>
> The Kernel Concurrency Sanitizer (KCSAN) is a dynamic race detector, which
> relies on compile-time instrumentation, and uses a watchpoint-based sampling
> diff --git a/Documentation/dev-tools/kmsan.rst b/Documentation/dev-tools/kmsan.rst
> index 55fa82212eb2..323eedad53cd 100644
> --- a/Documentation/dev-tools/kmsan.rst
> +++ b/Documentation/dev-tools/kmsan.rst
> @@ -1,9 +1,9 @@
> .. SPDX-License-Identifier: GPL-2.0
> .. Copyright (C) 2022, Google LLC.
>
> -===================================
> -The Kernel Memory Sanitizer (KMSAN)
> -===================================
> +===============================
> +Kernel Memory Sanitizer (KMSAN)
> +===============================
>
> KMSAN is a dynamic error detector aimed at finding uses of uninitialized
> values. It is based on compiler instrumentation, and is quite similar to the
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/5] kasan: unify printk prefixes
2023-10-06 15:18 ` [PATCH 2/5] kasan: unify printk prefixes andrey.konovalov
@ 2023-10-09 8:43 ` Marco Elver
0 siblings, 0 replies; 13+ messages in thread
From: Marco Elver @ 2023-10-09 8:43 UTC (permalink / raw)
To: andrey.konovalov
Cc: Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Andrey Ryabinin, kasan-dev, Andrew Morton, linux-mm,
linux-kernel, Andrey Konovalov
On Fri, 6 Oct 2023 at 17:18, <andrey.konovalov@linux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@google.com>
>
> Unify prefixes for printk messages in mm/kasan/.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Marco Elver <elver@google.com>
> ---
> mm/kasan/kasan_test.c | 2 +-
> mm/kasan/kasan_test_module.c | 2 +-
> mm/kasan/quarantine.c | 4 +++-
> mm/kasan/report_generic.c | 6 +++---
> 4 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c
> index b61cc6a42541..c707d6c6e019 100644
> --- a/mm/kasan/kasan_test.c
> +++ b/mm/kasan/kasan_test.c
> @@ -5,7 +5,7 @@
> * Author: Andrey Ryabinin <a.ryabinin@samsung.com>
> */
>
> -#define pr_fmt(fmt) "kasan_test: " fmt
> +#define pr_fmt(fmt) "kasan: test: " fmt
>
> #include <kunit/test.h>
> #include <linux/bitops.h>
> diff --git a/mm/kasan/kasan_test_module.c b/mm/kasan/kasan_test_module.c
> index 7be7bed456ef..8b7b3ea2c74e 100644
> --- a/mm/kasan/kasan_test_module.c
> +++ b/mm/kasan/kasan_test_module.c
> @@ -5,7 +5,7 @@
> * Author: Andrey Ryabinin <a.ryabinin@samsung.com>
> */
>
> -#define pr_fmt(fmt) "kasan test: %s " fmt, __func__
> +#define pr_fmt(fmt) "kasan: test: " fmt
>
> #include <linux/mman.h>
> #include <linux/module.h>
> diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c
> index 152dca73f398..ca4529156735 100644
> --- a/mm/kasan/quarantine.c
> +++ b/mm/kasan/quarantine.c
> @@ -8,6 +8,8 @@
> * Based on code by Dmitry Chernenkov.
> */
>
> +#define pr_fmt(fmt) "kasan: " fmt
> +
> #include <linux/gfp.h>
> #include <linux/hash.h>
> #include <linux/kernel.h>
> @@ -414,7 +416,7 @@ static int __init kasan_cpu_quarantine_init(void)
> ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mm/kasan:online",
> kasan_cpu_online, kasan_cpu_offline);
> if (ret < 0)
> - pr_err("kasan cpu quarantine register failed [%d]\n", ret);
> + pr_err("cpu quarantine register failed [%d]\n", ret);
> return ret;
> }
> late_initcall(kasan_cpu_quarantine_init);
> diff --git a/mm/kasan/report_generic.c b/mm/kasan/report_generic.c
> index 51a1e8a8877f..99cbcd73cff7 100644
> --- a/mm/kasan/report_generic.c
> +++ b/mm/kasan/report_generic.c
> @@ -220,7 +220,7 @@ static bool __must_check tokenize_frame_descr(const char **frame_descr,
> const size_t tok_len = sep - *frame_descr;
>
> if (tok_len + 1 > max_tok_len) {
> - pr_err("KASAN internal error: frame description too long: %s\n",
> + pr_err("internal error: frame description too long: %s\n",
> *frame_descr);
> return false;
> }
> @@ -233,7 +233,7 @@ static bool __must_check tokenize_frame_descr(const char **frame_descr,
> *frame_descr = sep + 1;
>
> if (value != NULL && kstrtoul(token, 10, value)) {
> - pr_err("KASAN internal error: not a valid number: %s\n", token);
> + pr_err("internal error: not a valid number: %s\n", token);
> return false;
> }
>
> @@ -323,7 +323,7 @@ static bool __must_check get_address_stack_frame_info(const void *addr,
>
> frame = (const unsigned long *)(mem_ptr + KASAN_GRANULE_SIZE);
> if (frame[0] != KASAN_CURRENT_STACK_FRAME_MAGIC) {
> - pr_err("KASAN internal error: frame info validation failed; invalid marker: %lu\n",
> + pr_err("internal error: frame has invalid marker: %lu\n",
> frame[0]);
> return false;
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/5] kasan: use unchecked __memset internally
2023-10-06 15:18 ` [PATCH 3/5] kasan: use unchecked __memset internally andrey.konovalov
@ 2023-10-09 8:45 ` Marco Elver
2023-10-09 19:50 ` Andrey Konovalov
0 siblings, 1 reply; 13+ messages in thread
From: Marco Elver @ 2023-10-09 8:45 UTC (permalink / raw)
To: andrey.konovalov
Cc: Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Andrey Ryabinin, kasan-dev, Andrew Morton, linux-mm,
linux-kernel, Andrey Konovalov
On Fri, 6 Oct 2023 at 17:18, <andrey.konovalov@linux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@google.com>
>
> KASAN code is supposed to use the unchecked __memset implementation when
> accessing its metadata.
>
> Change uses of memset to __memset in mm/kasan/.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Do we need a "Fixes" tag?
Reviewed-by: Marco Elver <elver@google.com>
> ---
> mm/kasan/report.c | 4 ++--
> mm/kasan/shadow.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> index ca4b6ff080a6..12557ffee90b 100644
> --- a/mm/kasan/report.c
> +++ b/mm/kasan/report.c
> @@ -538,7 +538,7 @@ void kasan_report_invalid_free(void *ptr, unsigned long ip, enum kasan_report_ty
>
> start_report(&flags, true);
>
> - memset(&info, 0, sizeof(info));
> + __memset(&info, 0, sizeof(info));
> info.type = type;
> info.access_addr = ptr;
> info.access_size = 0;
> @@ -576,7 +576,7 @@ bool kasan_report(const void *addr, size_t size, bool is_write,
>
> start_report(&irq_flags, true);
>
> - memset(&info, 0, sizeof(info));
> + __memset(&info, 0, sizeof(info));
> info.type = KASAN_REPORT_ACCESS;
> info.access_addr = addr;
> info.access_size = size;
> diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c
> index dd772f9d0f08..d687f09a7ae3 100644
> --- a/mm/kasan/shadow.c
> +++ b/mm/kasan/shadow.c
> @@ -324,7 +324,7 @@ static int kasan_populate_vmalloc_pte(pte_t *ptep, unsigned long addr,
> if (!page)
> return -ENOMEM;
>
> - memset((void *)page, KASAN_VMALLOC_INVALID, PAGE_SIZE);
> + __memset((void *)page, KASAN_VMALLOC_INVALID, PAGE_SIZE);
> pte = pfn_pte(PFN_DOWN(__pa(page)), PAGE_KERNEL);
>
> spin_lock(&init_mm.page_table_lock);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/5] kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment
2023-10-06 15:18 ` [PATCH 4/5] kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment andrey.konovalov
@ 2023-10-09 8:47 ` Marco Elver
2023-10-09 19:42 ` Andrey Konovalov
0 siblings, 1 reply; 13+ messages in thread
From: Marco Elver @ 2023-10-09 8:47 UTC (permalink / raw)
To: andrey.konovalov
Cc: Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Andrey Ryabinin, kasan-dev, Andrew Morton, linux-mm,
linux-kernel, Andrey Konovalov, kernel test robot
On Fri, 6 Oct 2023 at 17:18, <andrey.konovalov@linux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@google.com>
>
> Update the comment for KUNIT_EXPECT_KASAN_FAIL to describe the parameters
> this macro accepts.
>
> Also drop the mention of the "kasan_status" KUnit resource, as it no
> longer exists.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202308171757.7V5YUcje-lkp@intel.com/
"Closes" isn't a valid tag? Reported-by + Link should be enough to attribute.
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Marco Elver <elver@google.com>
> ---
> mm/kasan/kasan_test.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c
> index c707d6c6e019..2030c7ff7de9 100644
> --- a/mm/kasan/kasan_test.c
> +++ b/mm/kasan/kasan_test.c
> @@ -91,10 +91,11 @@ static void kasan_test_exit(struct kunit *test)
> }
>
> /**
> - * KUNIT_EXPECT_KASAN_FAIL() - check that the executed expression produces a
> - * KASAN report; causes a test failure otherwise. This relies on a KUnit
> - * resource named "kasan_status". Do not use this name for KUnit resources
> - * outside of KASAN tests.
> + * KUNIT_EXPECT_KASAN_FAIL - check that the executed expression produces a
> + * KASAN report; causes a KUnit test failure otherwise.
> + *
> + * @test: Currently executing KUnit test.
> + * @expression: Expression that must produce a KASAN report.
> *
> * For hardware tag-based KASAN, when a synchronous tag fault happens, tag
> * checking is auto-disabled. When this happens, this test handler reenables
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/5] kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment
2023-10-09 8:47 ` Marco Elver
@ 2023-10-09 19:42 ` Andrey Konovalov
0 siblings, 0 replies; 13+ messages in thread
From: Andrey Konovalov @ 2023-10-09 19:42 UTC (permalink / raw)
To: Marco Elver
Cc: andrey.konovalov, Alexander Potapenko, Dmitry Vyukov,
Andrey Ryabinin, kasan-dev, Andrew Morton, linux-mm,
linux-kernel, Andrey Konovalov, kernel test robot
On Mon, Oct 9, 2023 at 10:48 AM Marco Elver <elver@google.com> wrote:
>
> On Fri, 6 Oct 2023 at 17:18, <andrey.konovalov@linux.dev> wrote:
> >
> > From: Andrey Konovalov <andreyknvl@google.com>
> >
> > Update the comment for KUNIT_EXPECT_KASAN_FAIL to describe the parameters
> > this macro accepts.
> >
> > Also drop the mention of the "kasan_status" KUnit resource, as it no
> > longer exists.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202308171757.7V5YUcje-lkp@intel.com/
>
> "Closes" isn't a valid tag? Reported-by + Link should be enough to attribute.
I believe it is: the robot asks to use it, see the link. (I think this
tag is also used by syzbot btw.)
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
>
> Reviewed-by: Marco Elver <elver@google.com>
Thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/5] Documentation: *san: drop "the" from article titles
2023-10-07 7:01 ` Marco Elver
@ 2023-10-09 19:44 ` Andrey Konovalov
0 siblings, 0 replies; 13+ messages in thread
From: Andrey Konovalov @ 2023-10-09 19:44 UTC (permalink / raw)
To: Marco Elver
Cc: andrey.konovalov, Alexander Potapenko, Dmitry Vyukov,
Andrey Ryabinin, kasan-dev, Andrew Morton, linux-mm,
linux-kernel, Andrey Konovalov
On Sat, Oct 7, 2023 at 9:01 AM Marco Elver <elver@google.com> wrote:
>
> On Fri, 6 Oct 2023 at 17:18, <andrey.konovalov@linux.dev> wrote:
> >
> > From: Andrey Konovalov <andreyknvl@google.com>
> >
> > Drop "the" from the titles of documentation articles for KASAN, KCSAN,
> > and KMSAN, as it is redundant.
> >
> > Also add SPDX-License-Identifier for kasan.rst.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > ---
> > Documentation/dev-tools/kasan.rst | 7 +++++--
> > Documentation/dev-tools/kcsan.rst | 4 ++--
> > Documentation/dev-tools/kmsan.rst | 6 +++---
>
> UBSan also has it: https://docs.kernel.org/dev-tools/ubsan.html
Ah, right, forgot that one. I'll send a fix up next week.
(Once again I wonder if we should rename UBSAN to KUBSAN. :)
> Reviewed-by: Marco Elver <elver@google.com>
Thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/5] kasan: use unchecked __memset internally
2023-10-09 8:45 ` Marco Elver
@ 2023-10-09 19:50 ` Andrey Konovalov
0 siblings, 0 replies; 13+ messages in thread
From: Andrey Konovalov @ 2023-10-09 19:50 UTC (permalink / raw)
To: Marco Elver
Cc: andrey.konovalov, Alexander Potapenko, Dmitry Vyukov,
Andrey Ryabinin, kasan-dev, Andrew Morton, linux-mm,
linux-kernel, Andrey Konovalov
On Mon, Oct 9, 2023 at 10:46 AM Marco Elver <elver@google.com> wrote:
>
> On Fri, 6 Oct 2023 at 17:18, <andrey.konovalov@linux.dev> wrote:
> >
> > From: Andrey Konovalov <andreyknvl@google.com>
> >
> > KASAN code is supposed to use the unchecked __memset implementation when
> > accessing its metadata.
> >
> > Change uses of memset to __memset in mm/kasan/.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
>
> Do we need a "Fixes" tag?
Good idea, let's add them:
Fixes: 59e6e098d1c1 ("kasan: introduce kasan_complete_mode_report_info")
Fixes: 3c5c3cfb9ef4 ("kasan: support backing vmalloc space with real
shadow memory")
> Reviewed-by: Marco Elver <elver@google.com>
Thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-10-09 19:50 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-06 15:18 [PATCH 0/5] kasan: assorted fixes and improvements andrey.konovalov
2023-10-06 15:18 ` [PATCH 1/5] arm64, kasan: update comment in kasan_init andrey.konovalov
2023-10-06 15:18 ` [PATCH 2/5] kasan: unify printk prefixes andrey.konovalov
2023-10-09 8:43 ` Marco Elver
2023-10-06 15:18 ` [PATCH 3/5] kasan: use unchecked __memset internally andrey.konovalov
2023-10-09 8:45 ` Marco Elver
2023-10-09 19:50 ` Andrey Konovalov
2023-10-06 15:18 ` [PATCH 4/5] kasan: fix and update KUNIT_EXPECT_KASAN_FAIL comment andrey.konovalov
2023-10-09 8:47 ` Marco Elver
2023-10-09 19:42 ` Andrey Konovalov
2023-10-06 15:18 ` [PATCH 5/5] Documentation: *san: drop "the" from article titles andrey.konovalov
2023-10-07 7:01 ` Marco Elver
2023-10-09 19:44 ` Andrey Konovalov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox