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]
Date: Tue, 28 May 2024 14:38:05 +0200
From: Marco Elver <elver@...gle.com>
To: Alexander Potapenko <glider@...gle.com>
Cc: dvyukov@...gle.com, akpm@...ux-foundation.org, bjohannesmeyer@...il.com, 
	linux-kernel@...r.kernel.org, kasan-dev@...glegroups.com, linux-mm@...ck.org
Subject: Re: [PATCH 1/2] kmsan: do not wipe out origin when doing partial unpoisoning

On Tue, 28 May 2024 at 12:48, Alexander Potapenko <glider@...gle.com> wrote:
>
> As noticed by Brian, KMSAN should not be zeroing the origin when
> unpoisoning parts of a four-byte uninitialized value, e.g.:
>
>     char a[4];
>     kmsan_unpoison_memory(a, 1);
>
> This led to false negatives, as certain poisoned values could receive zero
> origins, preventing those values from being reported.
>
> To fix the problem, check that kmsan_internal_set_shadow_origin() writes
> zero origins only to slots which have zero shadow.
>
> Reported-by: Brian Johannesmeyer <bjohannesmeyer@...il.com>
> Link: https://lore.kernel.org/lkml/20240524232804.1984355-1-bjohannesmeyer@gmail.com/T/
> Fixes: f80be4571b19 ("kmsan: add KMSAN runtime core")
> Signed-off-by: Alexander Potapenko <glider@...gle.com>
> ---
>  mm/kmsan/core.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/mm/kmsan/core.c b/mm/kmsan/core.c
> index cf2d70e9c9a5f..95f859e38c533 100644
> --- a/mm/kmsan/core.c
> +++ b/mm/kmsan/core.c
> @@ -196,8 +196,7 @@ void kmsan_internal_set_shadow_origin(void *addr, size_t size, int b,
>                                       u32 origin, bool checked)
>  {
>         u64 address = (u64)addr;
> -       void *shadow_start;
> -       u32 *origin_start;
> +       u32 *shadow_start, *origin_start;
>         size_t pad = 0;
>
>         KMSAN_WARN_ON(!kmsan_metadata_is_contiguous(addr, size));
> @@ -225,8 +224,16 @@ void kmsan_internal_set_shadow_origin(void *addr, size_t size, int b,
>         origin_start =
>                 (u32 *)kmsan_get_metadata((void *)address, KMSAN_META_ORIGIN);
>
> -       for (int i = 0; i < size / KMSAN_ORIGIN_SIZE; i++)
> -               origin_start[i] = origin;
> +       /*
> +        * If the new origin is non-zero, assume that the shadow byte is also non-zero,
> +        * and unconditionally overwrite the old origin slot.
> +        * If the new origin is zero, overwrite the old origin slot iff the
> +        * corresponding shadow slot is zero.
> +        */
> +       for (int i = 0; i < size / KMSAN_ORIGIN_SIZE; i++) {
> +               if (origin || !shadow_start[i])
> +                       origin_start[i] = origin;
> +       }

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ