[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <386ffda192eb4a26f68c526c496afd48a5cd87ce.1732016064.git.ptesarik@suse.com>
Date: Tue, 19 Nov 2024 12:37:39 +0100
From: Petr Tesarik <ptesarik@...e.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook <kees@...nel.org>,
Jinbum Park <jinb.park7@...il.com>
Cc: linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Petr Tesarik <ptesarik@...e.com>
Subject: [PATCH v2 2/2] mm/rodata_test: verify test data is unchanged, rather than non-zero
Verify that the test variable holds the initialization value, rather than
any non-zero value.
Signed-off-by: Petr Tesarik <ptesarik@...e.com>
---
mm/rodata_test.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/rodata_test.c b/mm/rodata_test.c
index 3b60425d80fe..e7173fcd210c 100644
--- a/mm/rodata_test.c
+++ b/mm/rodata_test.c
@@ -12,7 +12,8 @@
#include <linux/mm.h>
#include <asm/sections.h>
-static const int rodata_test_data = 0xC3;
+#define TEST_VALUE 0xC3
+static const int rodata_test_data = TEST_VALUE;
void rodata_test(void)
{
@@ -20,7 +21,7 @@ void rodata_test(void)
/* test 1: read the value */
/* If this test fails, some previous testrun has clobbered the state */
- if (!READ_ONCE(rodata_test_data)) {
+ if (unlikely(READ_ONCE(rodata_test_data) != TEST_VALUE)) {
pr_err("test 1 fails (start data)\n");
return;
}
@@ -33,7 +34,7 @@ void rodata_test(void)
}
/* test 3: check the value hasn't changed */
- if (READ_ONCE(rodata_test_data) == zero) {
+ if (unlikely(READ_ONCE(rodata_test_data) != TEST_VALUE)) {
pr_err("test data was changed\n");
return;
}
--
2.46.1
Powered by blists - more mailing lists