lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANpmjNPpbSxWdaw=N_-gnweok9XtaJ-Pqcg15Z=Kko9sUffwhQ@mail.gmail.com>
Date: Wed, 7 May 2025 18:10:08 +0200
From: Marco Elver <elver@...gle.com>
To: Alexander Potapenko <glider@...gle.com>
Cc: dvyukov@...gle.com, bvanassche@....org, kent.overstreet@...ux.dev, 
	iii@...ux.ibm.com, akpm@...ux-foundation.org, linux-kernel@...r.kernel.org, 
	kasan-dev@...glegroups.com
Subject: Re: [PATCH 5/5] kmsan: rework kmsan_in_runtime() handling in kmsan_report()

On Wed, 7 May 2025 at 18:00, Alexander Potapenko <glider@...gle.com> wrote:
>
> kmsan_report() calls used to require entering/leaving the runtime around
> them. To simplify the things, drop this requirement and move calls to
> kmsan_enter_runtime()/kmsan_leave_runtime() into kmsan_report().
>
> Cc: Marco Elver <elver@...gle.com>
> Cc: Bart Van Assche <bvanassche@....org>
> Cc: Kent Overstreet <kent.overstreet@...ux.dev>
> Signed-off-by: Alexander Potapenko <glider@...gle.com>

Acked-by: Marco Elver <elver@...gle.com>

> ---
>  mm/kmsan/core.c            | 8 --------
>  mm/kmsan/instrumentation.c | 4 ----
>  mm/kmsan/report.c          | 6 +++---
>  3 files changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/mm/kmsan/core.c b/mm/kmsan/core.c
> index a97dc90fa6a93..1ea711786c522 100644
> --- a/mm/kmsan/core.c
> +++ b/mm/kmsan/core.c
> @@ -274,11 +274,9 @@ void kmsan_internal_check_memory(void *addr, size_t size,
>                          * bytes before, report them.
>                          */
>                         if (cur_origin) {
> -                               kmsan_enter_runtime();
>                                 kmsan_report(cur_origin, addr, size,
>                                              cur_off_start, pos - 1, user_addr,
>                                              reason);
> -                               kmsan_leave_runtime();
>                         }
>                         cur_origin = 0;
>                         cur_off_start = -1;
> @@ -292,11 +290,9 @@ void kmsan_internal_check_memory(void *addr, size_t size,
>                                  * poisoned bytes before, report them.
>                                  */
>                                 if (cur_origin) {
> -                                       kmsan_enter_runtime();
>                                         kmsan_report(cur_origin, addr, size,
>                                                      cur_off_start, pos + i - 1,
>                                                      user_addr, reason);
> -                                       kmsan_leave_runtime();
>                                 }
>                                 cur_origin = 0;
>                                 cur_off_start = -1;
> @@ -312,11 +308,9 @@ void kmsan_internal_check_memory(void *addr, size_t size,
>                          */
>                         if (cur_origin != new_origin) {
>                                 if (cur_origin) {
> -                                       kmsan_enter_runtime();
>                                         kmsan_report(cur_origin, addr, size,
>                                                      cur_off_start, pos + i - 1,
>                                                      user_addr, reason);
> -                                       kmsan_leave_runtime();
>                                 }
>                                 cur_origin = new_origin;
>                                 cur_off_start = pos + i;
> @@ -326,10 +320,8 @@ void kmsan_internal_check_memory(void *addr, size_t size,
>         }
>         KMSAN_WARN_ON(pos != size);
>         if (cur_origin) {
> -               kmsan_enter_runtime();
>                 kmsan_report(cur_origin, addr, size, cur_off_start, pos - 1,
>                              user_addr, reason);
> -               kmsan_leave_runtime();
>         }
>  }
>
> diff --git a/mm/kmsan/instrumentation.c b/mm/kmsan/instrumentation.c
> index 02a405e55d6ca..69f0a57a401c4 100644
> --- a/mm/kmsan/instrumentation.c
> +++ b/mm/kmsan/instrumentation.c
> @@ -312,13 +312,9 @@ EXPORT_SYMBOL(__msan_unpoison_alloca);
>  void __msan_warning(u32 origin);
>  void __msan_warning(u32 origin)
>  {
> -       if (!kmsan_enabled || kmsan_in_runtime())
> -               return;
> -       kmsan_enter_runtime();
>         kmsan_report(origin, /*address*/ NULL, /*size*/ 0,
>                      /*off_first*/ 0, /*off_last*/ 0, /*user_addr*/ NULL,
>                      REASON_ANY);
> -       kmsan_leave_runtime();
>  }
>  EXPORT_SYMBOL(__msan_warning);
>
> diff --git a/mm/kmsan/report.c b/mm/kmsan/report.c
> index 94a3303fb65e0..d6853ce089541 100644
> --- a/mm/kmsan/report.c
> +++ b/mm/kmsan/report.c
> @@ -157,14 +157,14 @@ void kmsan_report(depot_stack_handle_t origin, void *address, int size,
>         unsigned long ua_flags;
>         bool is_uaf;
>
> -       if (!kmsan_enabled)
> +       if (!kmsan_enabled || kmsan_in_runtime())
>                 return;
>         if (current->kmsan_ctx.depth)
>                 return;
>         if (!origin)
>                 return;
>
> -       kmsan_disable_current();
> +       kmsan_enter_runtime();
>         ua_flags = user_access_save();
>         raw_spin_lock(&kmsan_report_lock);
>         pr_err("=====================================================\n");
> @@ -217,5 +217,5 @@ void kmsan_report(depot_stack_handle_t origin, void *address, int size,
>         if (panic_on_kmsan)
>                 panic("kmsan.panic set ...\n");
>         user_access_restore(ua_flags);
> -       kmsan_enable_current();
> +       kmsan_leave_runtime();
>  }
> --
> 2.49.0.967.g6a0df3ecc3-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ