linux/mm/kasan
Andrey Konovalov 22d82affc0 kasan: fix type cast in memory_is_poisoned_n
commit 05c56e7b43 upstream.

Commit bb6e04a173 ("kasan: use internal prototypes matching gcc-13
builtins") introduced a bug into the memory_is_poisoned_n implementation:
it effectively removed the cast to a signed integer type after applying
KASAN_GRANULE_MASK.

As a result, KASAN started failing to properly check memset, memcpy, and
other similar functions.

Fix the bug by adding the cast back (through an additional signed integer
variable to make the code more readable).

Link: https://lkml.kernel.org/r/8c9e0251c2b8b81016255709d4ec42942dcaf018.1688431866.git.andreyknvl@google.com
Fixes: bb6e04a173 ("kasan: use internal prototypes matching gcc-13 builtins")
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2023-07-23 13:53:54 +02:00
..
common.c kasan: use internal prototypes matching gcc-13 builtins 2023-07-23 13:53:54 +02:00
generic.c kasan: fix type cast in memory_is_poisoned_n 2023-07-23 13:53:54 +02:00
hw_tags.c kasan: hw_tags: avoid invalid virt_to_page() 2023-05-02 17:23:27 -07:00
init.c kasan: use MAX_PTRS_PER_* for early shadow tables 2021-06-29 10:53:53 -07:00
kasan.h kasan, slub: fix HW_TAGS zeroing with slub_debug 2023-07-23 13:53:54 +02:00
kasan_test.c printk: export console trace point for kcsan/kasan/kfence/kmsan 2023-04-18 16:30:11 -07:00
kasan_test_module.c kasan: migrate workqueue_uaf test to kunit 2022-11-08 17:37:14 -08:00
Makefile kasan: test: fix test for new meminstrinsic instrumentation 2023-03-02 21:54:22 -08:00
quarantine.c kasan: fix lockdep report invalid wait context 2023-04-21 14:51:59 -07:00
report.c kasan: use internal prototypes matching gcc-13 builtins 2023-07-23 13:53:54 +02:00
report_generic.c kasan: use internal prototypes matching gcc-13 builtins 2023-07-23 13:53:54 +02:00
report_hw_tags.c kasan: use internal prototypes matching gcc-13 builtins 2023-07-23 13:53:54 +02:00
report_sw_tags.c kasan: use internal prototypes matching gcc-13 builtins 2023-07-23 13:53:54 +02:00
report_tags.c kasan: infer allocation size by scanning metadata 2023-02-09 16:51:40 -08:00
shadow.c kasan: use internal prototypes matching gcc-13 builtins 2023-07-23 13:53:54 +02:00
sw_tags.c kasan: use internal prototypes matching gcc-13 builtins 2023-07-23 13:53:54 +02:00
tags.c kasan: dynamically allocate stack ring entries 2022-10-03 14:03:02 -07:00