linux/mm/kmsan
Alexander Potapenko 9ff078f5ba kmsan: do not wipe out origin when doing partial unpoisoning
commit 2ef3cec44c upstream.

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.

Link: https://lkml.kernel.org/r/20240528104807.738758-1-glider@google.com
Fixes: f80be4571b ("kmsan: add KMSAN runtime core")
Signed-off-by: Alexander Potapenko <glider@google.com>
Reported-by: Brian Johannesmeyer <bjohannesmeyer@gmail.com>
  Link: https://lore.kernel.org/lkml/20240524232804.1984355-1-bjohannesmeyer@gmail.com/T/
Reviewed-by: Marco Elver <elver@google.com>
Tested-by: Brian Johannesmeyer <bjohannesmeyer@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-06-16 13:41:38 +02:00
..
core.c kmsan: do not wipe out origin when doing partial unpoisoning 2024-06-16 13:41:38 +02:00
hooks.c mm: kmsan: handle alloc failures in kmsan_ioremap_page_range() 2023-04-26 14:28:41 +02:00
init.c init: kmsan: call KMSAN initialization routines 2022-10-03 14:03:21 -07:00
instrumentation.c x86: fortify: kmsan: fix KMSAN fortify builds 2022-10-28 13:37:23 -07:00
kmsan_test.c kmsan: include linux/vmalloc.h 2023-01-04 11:28:59 +01:00
kmsan.h kmsan: core: kmsan_in_runtime() should return true in NMI context 2022-11-08 15:57:24 -08:00
Makefile kmsan: add tests for KMSAN 2022-10-03 14:03:22 -07:00
report.c
shadow.c mm: kmsan: handle alloc failures in kmsan_vmap_pages_range_noflush() 2023-04-26 14:28:41 +02:00