From: andrey.konovalov@linux.dev
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Marco Elver <elver@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Alexander Potapenko <glider@google.com>,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 6/8] kasan: test: clean up ksize_uaf
Date: Thu, 12 Aug 2021 16:56:41 +0200 [thread overview]
Message-ID: <a1fc34faca4650f4a6e4dfb3f8d8d82c82eb953a.1628779805.git.andreyknvl@gmail.com> (raw)
In-Reply-To: <cover.1628779805.git.andreyknvl@gmail.com>
From: Andrey Konovalov <andreyknvl@gmail.com>
Some KASAN tests use global variables to store function returns values
so that the compiler doesn't optimize away these functions.
ksize_uaf() doesn't call any functions, so it doesn't need to use
kasan_int_result. Use volatile accesses instead, to be consistent with
other similar tests.
Signed-off-by: Andrey Konovalov <andreyknvl@gmail.com>
---
lib/test_kasan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 1dcba6dbfc97..30f2cde96e81 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -737,8 +737,8 @@ static void ksize_uaf(struct kunit *test)
kfree(ptr);
KUNIT_EXPECT_KASAN_FAIL(test, ksize(ptr));
- KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = *ptr);
- KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = *(ptr + size));
+ KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[0]);
+ KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[size]);
}
static void kasan_stack_oob(struct kunit *test)
--
2.25.1
next prev parent reply other threads:[~2021-08-12 14:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-12 14:53 [PATCH v2 0/8] kasan: test: avoid crashing the kernel with HW_TAGS andrey.konovalov
2021-08-12 14:53 ` [PATCH v2 1/8] kasan: test: rework kmalloc_oob_right andrey.konovalov
2021-08-12 14:53 ` [PATCH v2 2/8] kasan: test: avoid writing invalid memory andrey.konovalov
2021-08-12 14:53 ` [PATCH v2 3/8] kasan: test: avoid corrupting memory via memset andrey.konovalov
2021-08-12 14:53 ` [PATCH v2 4/8] kasan: test: disable kmalloc_memmove_invalid_size for HW_TAGS andrey.konovalov
2021-08-12 14:53 ` [PATCH v2 5/8] kasan: test: only do kmalloc_uaf_memset for generic mode andrey.konovalov
2021-08-12 14:56 ` andrey.konovalov [this message]
2021-08-12 15:00 ` [PATCH v2 7/8] kasan: test: avoid corrupting memory in copy_user_test andrey.konovalov
2021-08-12 15:05 ` [PATCH v2 8/8] kasan: test: avoid corrupting memory in kasan_rcu_uaf andrey.konovalov
2021-08-12 15:05 ` [PATCH v2 0/8] kasan: test: avoid crashing the kernel with HW_TAGS Andrey Konovalov
2021-08-12 15:44 ` Marco Elver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a1fc34faca4650f4a6e4dfb3f8d8d82c82eb953a.1628779805.git.andreyknvl@gmail.com \
--to=andrey.konovalov@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox