* [PATCH 0/2] kmsan: fix sparse warnings
@ 2024-06-27 14:57 Ilya Leoshkevich
2024-06-27 14:57 ` [PATCH 1/2] kmsan: add missing __user tags Ilya Leoshkevich
2024-06-27 14:57 ` [PATCH 2/2] kmsan: do not pass NULL pointers as 0 Ilya Leoshkevich
0 siblings, 2 replies; 5+ messages in thread
From: Ilya Leoshkevich @ 2024-06-27 14:57 UTC (permalink / raw)
To: Alexander Potapenko, Marco Elver, Dmitry Vyukov, Andrew Morton
Cc: kasan-dev, linux-mm, linux-kernel, Ilya Leoshkevich
Hi,
Kernel test robot reported several sparse warnings in the KMSAN code
base [1]. They belong to two broad classes; fix each in a separate
commit.
Best regards,
Ilya
[1] https://lore.kernel.org/linux-mm/202406272033.KejtfLkw-lkp@intel.com/
Ilya Leoshkevich (2):
kmsan: add missing __user tags
kmsan: do not pass NULL pointers as 0
mm/kmsan/core.c | 4 ++--
mm/kmsan/hooks.c | 15 ++++++++-------
mm/kmsan/instrumentation.c | 4 ++--
mm/kmsan/kmsan.h | 6 +++---
mm/kmsan/report.c | 2 +-
5 files changed, 16 insertions(+), 15 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] kmsan: add missing __user tags
2024-06-27 14:57 [PATCH 0/2] kmsan: fix sparse warnings Ilya Leoshkevich
@ 2024-06-27 14:57 ` Ilya Leoshkevich
2024-06-28 7:55 ` Alexander Potapenko
2024-06-27 14:57 ` [PATCH 2/2] kmsan: do not pass NULL pointers as 0 Ilya Leoshkevich
1 sibling, 1 reply; 5+ messages in thread
From: Ilya Leoshkevich @ 2024-06-27 14:57 UTC (permalink / raw)
To: Alexander Potapenko, Marco Elver, Dmitry Vyukov, Andrew Morton
Cc: kasan-dev, linux-mm, linux-kernel, Ilya Leoshkevich, kernel test robot
sparse complains that __user pointers are being passed to functions
that expect non-__user ones. In all cases, these functions are in fact
working with user pointers, only the tag is missing. Add it.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406272033.KejtfLkw-lkp@intel.com/
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
mm/kmsan/core.c | 4 ++--
mm/kmsan/kmsan.h | 6 +++---
mm/kmsan/report.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/kmsan/core.c b/mm/kmsan/core.c
index 81b22220711a..a495debf1436 100644
--- a/mm/kmsan/core.c
+++ b/mm/kmsan/core.c
@@ -249,8 +249,8 @@ struct page *kmsan_vmalloc_to_page_or_null(void *vaddr)
return NULL;
}
-void kmsan_internal_check_memory(void *addr, size_t size, const void *user_addr,
- int reason)
+void kmsan_internal_check_memory(void *addr, size_t size,
+ const void __user *user_addr, int reason)
{
depot_stack_handle_t cur_origin = 0, new_origin = 0;
unsigned long addr64 = (unsigned long)addr;
diff --git a/mm/kmsan/kmsan.h b/mm/kmsan/kmsan.h
index 91a360a31e85..29555a8bc315 100644
--- a/mm/kmsan/kmsan.h
+++ b/mm/kmsan/kmsan.h
@@ -73,7 +73,7 @@ void kmsan_print_origin(depot_stack_handle_t origin);
* @off_last corresponding to different @origin values.
*/
void kmsan_report(depot_stack_handle_t origin, void *address, int size,
- int off_first, int off_last, const void *user_addr,
+ int off_first, int off_last, const void __user *user_addr,
enum kmsan_bug_reason reason);
DECLARE_PER_CPU(struct kmsan_ctx, kmsan_percpu_ctx);
@@ -163,8 +163,8 @@ depot_stack_handle_t kmsan_internal_chain_origin(depot_stack_handle_t id);
void kmsan_internal_task_create(struct task_struct *task);
bool kmsan_metadata_is_contiguous(void *addr, size_t size);
-void kmsan_internal_check_memory(void *addr, size_t size, const void *user_addr,
- int reason);
+void kmsan_internal_check_memory(void *addr, size_t size,
+ const void __user *user_addr, int reason);
struct page *kmsan_vmalloc_to_page_or_null(void *vaddr);
void kmsan_setup_meta(struct page *page, struct page *shadow,
diff --git a/mm/kmsan/report.c b/mm/kmsan/report.c
index 92e73ec61435..94a3303fb65e 100644
--- a/mm/kmsan/report.c
+++ b/mm/kmsan/report.c
@@ -148,7 +148,7 @@ void kmsan_print_origin(depot_stack_handle_t origin)
}
void kmsan_report(depot_stack_handle_t origin, void *address, int size,
- int off_first, int off_last, const void *user_addr,
+ int off_first, int off_last, const void __user *user_addr,
enum kmsan_bug_reason reason)
{
unsigned long stack_entries[KMSAN_STACK_DEPTH];
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] kmsan: do not pass NULL pointers as 0
2024-06-27 14:57 [PATCH 0/2] kmsan: fix sparse warnings Ilya Leoshkevich
2024-06-27 14:57 ` [PATCH 1/2] kmsan: add missing __user tags Ilya Leoshkevich
@ 2024-06-27 14:57 ` Ilya Leoshkevich
2024-06-28 8:03 ` Alexander Potapenko
1 sibling, 1 reply; 5+ messages in thread
From: Ilya Leoshkevich @ 2024-06-27 14:57 UTC (permalink / raw)
To: Alexander Potapenko, Marco Elver, Dmitry Vyukov, Andrew Morton
Cc: kasan-dev, linux-mm, linux-kernel, Ilya Leoshkevich, kernel test robot
sparse complains about passing NULL pointers as 0. Fix all instances.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406272033.KejtfLkw-lkp@intel.com/
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
mm/kmsan/hooks.c | 15 ++++++++-------
mm/kmsan/instrumentation.c | 4 ++--
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c
index 26d86dfdc819..3ea50f09311f 100644
--- a/mm/kmsan/hooks.c
+++ b/mm/kmsan/hooks.c
@@ -303,7 +303,8 @@ void kmsan_handle_urb(const struct urb *urb, bool is_out)
if (is_out)
kmsan_internal_check_memory(urb->transfer_buffer,
urb->transfer_buffer_length,
- /*user_addr*/ 0, REASON_SUBMIT_URB);
+ /*user_addr*/ NULL,
+ REASON_SUBMIT_URB);
else
kmsan_internal_unpoison_memory(urb->transfer_buffer,
urb->transfer_buffer_length,
@@ -316,14 +317,14 @@ static void kmsan_handle_dma_page(const void *addr, size_t size,
{
switch (dir) {
case DMA_BIDIRECTIONAL:
- kmsan_internal_check_memory((void *)addr, size, /*user_addr*/ 0,
- REASON_ANY);
+ kmsan_internal_check_memory((void *)addr, size,
+ /*user_addr*/ NULL, REASON_ANY);
kmsan_internal_unpoison_memory((void *)addr, size,
/*checked*/ false);
break;
case DMA_TO_DEVICE:
- kmsan_internal_check_memory((void *)addr, size, /*user_addr*/ 0,
- REASON_ANY);
+ kmsan_internal_check_memory((void *)addr, size,
+ /*user_addr*/ NULL, REASON_ANY);
break;
case DMA_FROM_DEVICE:
kmsan_internal_unpoison_memory((void *)addr, size,
@@ -418,8 +419,8 @@ void kmsan_check_memory(const void *addr, size_t size)
{
if (!kmsan_enabled)
return;
- return kmsan_internal_check_memory((void *)addr, size, /*user_addr*/ 0,
- REASON_ANY);
+ return kmsan_internal_check_memory((void *)addr, size,
+ /*user_addr*/ NULL, REASON_ANY);
}
EXPORT_SYMBOL(kmsan_check_memory);
diff --git a/mm/kmsan/instrumentation.c b/mm/kmsan/instrumentation.c
index 94b49fac9d8b..02a405e55d6c 100644
--- a/mm/kmsan/instrumentation.c
+++ b/mm/kmsan/instrumentation.c
@@ -315,8 +315,8 @@ void __msan_warning(u32 origin)
if (!kmsan_enabled || kmsan_in_runtime())
return;
kmsan_enter_runtime();
- kmsan_report(origin, /*address*/ 0, /*size*/ 0,
- /*off_first*/ 0, /*off_last*/ 0, /*user_addr*/ 0,
+ kmsan_report(origin, /*address*/ NULL, /*size*/ 0,
+ /*off_first*/ 0, /*off_last*/ 0, /*user_addr*/ NULL,
REASON_ANY);
kmsan_leave_runtime();
}
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] kmsan: add missing __user tags
2024-06-27 14:57 ` [PATCH 1/2] kmsan: add missing __user tags Ilya Leoshkevich
@ 2024-06-28 7:55 ` Alexander Potapenko
0 siblings, 0 replies; 5+ messages in thread
From: Alexander Potapenko @ 2024-06-28 7:55 UTC (permalink / raw)
To: Ilya Leoshkevich
Cc: Marco Elver, Dmitry Vyukov, Andrew Morton, kasan-dev, linux-mm,
linux-kernel, kernel test robot
On Thu, Jun 27, 2024 at 5:14 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> sparse complains that __user pointers are being passed to functions
> that expect non-__user ones. In all cases, these functions are in fact
> working with user pointers, only the tag is missing. Add it.
Thanks!
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202406272033.KejtfLkw-lkp@intel.com/
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] kmsan: do not pass NULL pointers as 0
2024-06-27 14:57 ` [PATCH 2/2] kmsan: do not pass NULL pointers as 0 Ilya Leoshkevich
@ 2024-06-28 8:03 ` Alexander Potapenko
0 siblings, 0 replies; 5+ messages in thread
From: Alexander Potapenko @ 2024-06-28 8:03 UTC (permalink / raw)
To: Ilya Leoshkevich
Cc: Marco Elver, Dmitry Vyukov, Andrew Morton, kasan-dev, linux-mm,
linux-kernel, kernel test robot
On Thu, Jun 27, 2024 at 5:14 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> sparse complains about passing NULL pointers as 0. Fix all instances.
Thanks a lot for fixing this!
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202406272033.KejtfLkw-lkp@intel.com/
Rant: I noticed recently that checkpatch.pl aggressively demands
having the Closes: tag follow Reported-by:, even when it is not
strictly necessary per
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes.
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-28 8:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-27 14:57 [PATCH 0/2] kmsan: fix sparse warnings Ilya Leoshkevich
2024-06-27 14:57 ` [PATCH 1/2] kmsan: add missing __user tags Ilya Leoshkevich
2024-06-28 7:55 ` Alexander Potapenko
2024-06-27 14:57 ` [PATCH 2/2] kmsan: do not pass NULL pointers as 0 Ilya Leoshkevich
2024-06-28 8:03 ` Alexander Potapenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox