Skip to contentSkip to conversation

linux-next: manual merge of the akpm-current tree with the arm64 tree

DISCUSSION Stephen Rothwell 2 participants 2 messages Apr 13, 2021 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hi all,

Today's linux-next merge of the akpm-current tree got a conflict in:

lib/test_kasan.c

between commits:

2603f8a78dfb ("kasan: Add KASAN mode kernel parameter") e80a76aa1a91 ("kasan, arm64: tests supports for HW_TAGS async mode")

from the arm64 tree and commit:

c616ba7e0d63 ("kasan: detect false-positives in tests")

from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Signature · 72 lines
Cheers,
Stephen Rothwell

diff --cc lib/test_kasan.c
index 785e724ce0d8,bf9225002a7e..000000000000
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@@ -78,33 -83,30 +83,35 @@@ static void kasan_test_exit(struct kuni
   * fields, it can reorder or optimize away the accesses to those fields.
   * Use READ/WRITE_ONCE() for the accesses and compiler barriers around the
   * expression to prevent that.
+  *
+  * In between KUNIT_EXPECT_KASAN_FAIL checks, fail_data.report_found is kept as
+  * false. This allows detecting KASAN reports that happen outside of the checks
+  * by asserting !fail_data.report_found at the start of KUNIT_EXPECT_KASAN_FAIL
+  * and in kasan_test_exit.
   */
- #define KUNIT_EXPECT_KASAN_FAIL(test, expression) do {		\
- 	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&			\
- 	    !kasan_async_mode_enabled())			\
- 		migrate_disable();				\
- 	WRITE_ONCE(fail_data.report_expected, true);		\
- 	WRITE_ONCE(fail_data.report_found, false);		\
- 	kunit_add_named_resource(test,				\
- 				NULL,				\
- 				NULL,				\
- 				&resource,			\
- 				"kasan_data", &fail_data);	\
- 	barrier();						\
- 	expression;						\
- 	barrier();						\
- 	if (kasan_async_mode_enabled())				\
- 		kasan_force_async_fault();			\
- 	barrier();						\
- 	KUNIT_EXPECT_EQ(test,					\
- 			READ_ONCE(fail_data.report_expected),	\
- 			READ_ONCE(fail_data.report_found));	\
- 	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&			\
- 	    !kasan_async_mode_enabled()) {			\
- 		if (READ_ONCE(fail_data.report_found))		\
- 			kasan_enable_tagging_sync();		\
- 		migrate_enable();				\
- 	}							\
+ #define KUNIT_EXPECT_KASAN_FAIL(test, expression) do {			\
 -	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS))				\
++	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&				\
++	    !kasan_async_mode_enabled())				\
+ 		migrate_disable();					\
+ 	KUNIT_EXPECT_FALSE(test, READ_ONCE(fail_data.report_found));	\
+ 	WRITE_ONCE(fail_data.report_expected, true);			\
+ 	barrier();							\
+ 	expression;							\
+ 	barrier();							\
++	if (kasan_async_mode_enabled())					\
++		kasan_force_async_fault();				\
++	barrier();							\
+ 	KUNIT_EXPECT_EQ(test,						\
+ 			READ_ONCE(fail_data.report_expected),		\
+ 			READ_ONCE(fail_data.report_found));		\
 -	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS)) {				\
++	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&				\
++	    !kasan_async_mode_enabled()) {				\
+ 		if (READ_ONCE(fail_data.report_found))			\
 -			kasan_enable_tagging();				\
++			kasan_enable_tagging_sync();			\
+ 		migrate_enable();					\
+ 	}								\
+ 	WRITE_ONCE(fail_data.report_found, false);			\
+ 	WRITE_ONCE(fail_data.report_expected, false);			\
  } while (0)
  
  #define KASAN_TEST_NEEDS_CONFIG_ON(test, config) do {			\
#1 lore raw
Quoted 59 lines · Stephen Rothwell
lib/test_kasan.c +22 -26
diff --cc lib/test_kasan.c
index 785e724ce0d8,bf9225002a7e..000000000000
@@@ -78,33 -83,30 +83,35 @@@ static void kasan_test_exit(struct kuni
   * fields, it can reorder or optimize away the accesses to those fields.
   * Use READ/WRITE_ONCE() for the accesses and compiler barriers around the
   * expression to prevent that.
+  *
+  * In between KUNIT_EXPECT_KASAN_FAIL checks, fail_data.report_found is kept as
+  * false. This allows detecting KASAN reports that happen outside of the checks
+  * by asserting !fail_data.report_found at the start of KUNIT_EXPECT_KASAN_FAIL
+  * and in kasan_test_exit.
   */
- #define KUNIT_EXPECT_KASAN_FAIL(test, expression) do {		\
- 	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&			\
- 	    !kasan_async_mode_enabled())			\
- 		migrate_disable();				\
- 	WRITE_ONCE(fail_data.report_expected, true);		\
- 	WRITE_ONCE(fail_data.report_found, false);		\
- 	kunit_add_named_resource(test,				\
- 				NULL,				\
- 				NULL,				\
- 				&resource,			\
- 				"kasan_data", &fail_data);	\
- 	barrier();						\
- 	expression;						\
- 	barrier();						\
- 	if (kasan_async_mode_enabled())				\
- 		kasan_force_async_fault();			\
- 	barrier();						\
- 	KUNIT_EXPECT_EQ(test,					\
- 			READ_ONCE(fail_data.report_expected),	\
- 			READ_ONCE(fail_data.report_found));	\
- 	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&			\
- 	    !kasan_async_mode_enabled()) {			\
- 		if (READ_ONCE(fail_data.report_found))		\
- 			kasan_enable_tagging_sync();		\
- 		migrate_enable();				\
- 	}							\
+ #define KUNIT_EXPECT_KASAN_FAIL(test, expression) do {			\
 -	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS))				\
++	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&				\
++	    !kasan_async_mode_enabled())				\
+ 		migrate_disable();					\
+ 	KUNIT_EXPECT_FALSE(test, READ_ONCE(fail_data.report_found));	\
+ 	WRITE_ONCE(fail_data.report_expected, true);			\
+ 	barrier();							\
+ 	expression;							\
+ 	barrier();							\
++	if (kasan_async_mode_enabled())					\
++		kasan_force_async_fault();				\
++	barrier();							\
+ 	KUNIT_EXPECT_EQ(test,						\
+ 			READ_ONCE(fail_data.report_expected),		\
+ 			READ_ONCE(fail_data.report_found));		\
 -	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS)) {				\
++	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&				\
++	    !kasan_async_mode_enabled()) {				\

lib/test_kasan.c

Quoted 10 lines
lib/test_kasan.c +6 -0
+ 		if (READ_ONCE(fail_data.report_found))			\
 -			kasan_enable_tagging();				\
++			kasan_enable_tagging_sync();			\
+ 		migrate_enable();					\
+ 	}								\
+ 	WRITE_ONCE(fail_data.report_found, false);			\
+ 	WRITE_ONCE(fail_data.report_expected, false);			\
  } while (0)
 
  #define KASAN_TEST_NEEDS_CONFIG_ON(test, config) do {			\

Thanks Stephen. The resolution looks correct.

Andrew, if you'd rather I dropped the MTE async mode support from the arm64 tree please let me know. Thanks.

https://lore.kernel.org/r/[email protected]/

Signature · 1 line
Catalin