mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
kasan: fix a2 allocation and remove explicit cast in atomic tests
Address the additional feedback since4e76c8cc33
kasan: add atomic tests (""kasan: add atomic tests") by removing an explicit cast and fixing the size as well as the check of the allocation of `a2`. Link: https://lkml.kernel.org/r/20240224105414.211995-1-paul.heidekrueger@tum.de Link: https://lore.kernel.org/all/20240131210041.686657-1-paul.heidekrueger@tum.de/T/#u Fixes:4e76c8cc33
("kasan: add atomic tests") Signed-off-by: Paul Heidekrüger <paul.heidekrueger@tum.de> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=214055 Reviewed-by: Marco Elver <elver@google.com> Tested-by: Marco Elver <elver@google.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
dc24559472
commit
8cc92a6793
1 changed files with 3 additions and 3 deletions
|
@ -700,7 +700,7 @@ static void kmalloc_uaf3(struct kunit *test)
|
||||||
|
|
||||||
static void kasan_atomics_helper(struct kunit *test, void *unsafe, void *safe)
|
static void kasan_atomics_helper(struct kunit *test, void *unsafe, void *safe)
|
||||||
{
|
{
|
||||||
int *i_unsafe = (int *)unsafe;
|
int *i_unsafe = unsafe;
|
||||||
|
|
||||||
KUNIT_EXPECT_KASAN_FAIL(test, READ_ONCE(*i_unsafe));
|
KUNIT_EXPECT_KASAN_FAIL(test, READ_ONCE(*i_unsafe));
|
||||||
KUNIT_EXPECT_KASAN_FAIL(test, WRITE_ONCE(*i_unsafe, 42));
|
KUNIT_EXPECT_KASAN_FAIL(test, WRITE_ONCE(*i_unsafe, 42));
|
||||||
|
@ -766,8 +766,8 @@ static void kasan_atomics(struct kunit *test)
|
||||||
*/
|
*/
|
||||||
a1 = kzalloc(48, GFP_KERNEL);
|
a1 = kzalloc(48, GFP_KERNEL);
|
||||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a1);
|
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a1);
|
||||||
a2 = kzalloc(sizeof(int), GFP_KERNEL);
|
a2 = kzalloc(sizeof(atomic_long_t), GFP_KERNEL);
|
||||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a1);
|
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a2);
|
||||||
|
|
||||||
/* Use atomics to access the redzone. */
|
/* Use atomics to access the redzone. */
|
||||||
kasan_atomics_helper(test, a1 + 48, a2);
|
kasan_atomics_helper(test, a1 + 48, a2);
|
||||||
|
|
Loading…
Reference in a new issue