Skip to content
Commit 19e85d93 authored by Alexander Potapenko's avatar Alexander Potapenko Committed by Greg Kroah-Hartman
Browse files

kmsan: do not wipe out origin when doing partial unpoisoning

commit 2ef3cec4 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: f80be457 ("kmsan: add KMSAN runtime core")
Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
Reported-by: default avatarBrian Johannesmeyer <bjohannesmeyer@gmail.com>
  Link: https://lore.kernel.org/lkml/20240524232804.1984355-1-bjohannesmeyer@gmail.com/T/


Reviewed-by: default avatarMarco Elver <elver@google.com>
Tested-by: default avatarBrian Johannesmeyer <bjohannesmeyer@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 99ed145f
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment