[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20240224105414.211995-1-paul.heidekrueger@tum.de>
Date: Sat, 24 Feb 2024 10:54:14 +0000
From: Paul Heidekrüger <paul.heidekrueger@....de>
To: akpm@...ux-foundation.org
Cc: andreyknvl@...il.com,
dvyukov@...gle.com,
elver@...gle.com,
glider@...gle.com,
kasan-dev@...glegroups.com,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
mark.rutland@....com,
paul.heidekrueger@....de,
ryabinin.a.a@...il.com,
vincenzo.frascino@....com
Subject: [PATCH] kasan: fix a2 allocation and remove explicit cast in atomic tests
Address the additional feedback since "kasan: add atomic tests"
(4e76c8cc3378a20923965e3345f40f6b8ae0bdba) by removing an explicit cast
and fixing the size as well as the check of the allocation of `a2`.
CC: Marco Elver <elver@...gle.com>
CC: Andrey Konovalov <andreyknvl@...il.com>
Link: https://lore.kernel.org/all/20240131210041.686657-1-paul.heidekrueger@tum.de/T/#u
Fixes: 4e76c8cc3378a20923965e3345f40f6b8ae0bdba
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=214055
Reviewed-by: Marco Elver <elver@...gle.com>
Tested-by: Marco Elver <elver@...gle.com>
Acked-by: Mark Rutland <mark.rutland@....com>
Reviewed-by: Andrey Konovalov <andreyknvl@...il.com>
Signed-off-by: Paul Heidekrüger <paul.heidekrueger@....de>
---
@Andrew:
I wasn't sure whether you'd be squashing this patch into v1 or
if it'll end up as a separate commit. Hope this works either way!
Changes PATCH v2 -> PATCH v3:
* Fix the wrong variable being used when checking a2 after allocation
* Add Andrey's reviewed-by tag
Changes PATCH v1 -> PATCH v2:
* Make explicit cast implicit as per Mark's feedback
* Increase the size of the "a2" allocation as per Andrey's feedback
* Add tags
Changes PATCH RFC v2 -> PATCH v1:
* Remove casts to void*
* Remove i_safe variable
* Add atomic_long_* test cases
* Carry over comment from kasan_bitops_tags()
Changes PATCH RFC v1 -> PATCH RFC v2:
* Adjust size of allocations to make kasan_atomics() work with all KASan modes
* Remove comments and move tests closer to the bitops tests
* For functions taking two addresses as an input, test each address in a separate function call.
* Rename variables for clarity
* Add tests for READ_ONCE(), WRITE_ONCE(), smp_load_acquire() and smp_store_release()
mm/kasan/kasan_test.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c
index 4ef2280c322c..7f0f87a2c3c4 100644
--- a/mm/kasan/kasan_test.c
+++ b/mm/kasan/kasan_test.c
@@ -1152,7 +1152,7 @@ static void kasan_bitops_tags(struct kunit *test)
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, WRITE_ONCE(*i_unsafe, 42));
@@ -1218,8 +1218,8 @@ static void kasan_atomics(struct kunit *test)
*/
a1 = kzalloc(48, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a1);
- a2 = kzalloc(sizeof(int), GFP_KERNEL);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a1);
+ a2 = kzalloc(sizeof(atomic_long_t), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a2);
/* Use atomics to access the redzone. */
kasan_atomics_helper(test, a1 + 48, a2);
--
2.40.1
Powered by blists - more mailing lists