diff mbox series

kasan: test: support async (again) and asymm modes for HW_TAGS

Message ID 51ae4a56205a41953971113ab2c264c7e2e5d969.1644938763.git.andreyknvl@google.com (mailing list archive)
State New
Headers show
Series kasan: test: support async (again) and asymm modes for HW_TAGS | expand

Commit Message

andrey.konovalov@linux.dev Feb. 15, 2022, 3:27 p.m. UTC
From: Andrey Konovalov <andreyknvl@google.com>

Async mode support has already been implemented in commit
e80a76aa1a91 ("kasan, arm64: tests supports for HW_TAGS async mode")
but then got accidentally broken in
commit 99734b535d9b ("kasan: detect false-positives in tests").

Restore the changes removed by the latter patch and adapt them for
asymm mode: add a sync_fault flag to kunit_kasan_expectation that
only get set if the MTE fault was synchronous, and reenable MTE
on such faults in tests.

Also rename kunit_kasan_expectation to kunit_kasan_status and move its
definition to mm/kasan/kasan.h from include/linux/kasan.h, as this
structure is only internally used by KASAN.

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
 include/linux/kasan.h |  5 -----
 lib/test_kasan.c      | 39 ++++++++++++++++++++++-----------------
 mm/kasan/hw_tags.c    | 18 +++++++++---------
 mm/kasan/kasan.h      | 14 ++++++++++++--
 mm/kasan/report.c     | 17 +++++++++--------
 5 files changed, 52 insertions(+), 41 deletions(-)

Comments

kernel test robot Feb. 15, 2022, 10:57 p.m. UTC | #1
Hi,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.17-rc4 next-20220215]
[cannot apply to hnaz-mm/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/andrey-konovalov-linux-dev/kasan-test-support-async-again-and-asymm-modes-for-HW_TAGS/20220215-232923
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d567f5db412ed52de0b3b3efca4a451263de6108
config: arm64-randconfig-r036-20220214 (https://download.01.org/0day-ci/archive/20220216/202202160627.SICieucW-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 37f422f4ac31c8b8041c6b62065263314282dab6)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/50334edb33a25643468715fbfc0e6d4a7d594432
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review andrey-konovalov-linux-dev/kasan-test-support-async-again-and-asymm-modes-for-HW_TAGS/20220215-232923
        git checkout 50334edb33a25643468715fbfc0e6d4a7d594432
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash mm/kasan/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> mm/kasan/report.c:360:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->report_found, true);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:313:10: note: expanded from macro '__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
                   ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
>> mm/kasan/report.c:360:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->report_found, true);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:313:39: note: expanded from macro '__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
                                                ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
>> mm/kasan/report.c:360:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->report_found, true);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:314:10: note: expanded from macro '__native_word'
            sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
                   ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
>> mm/kasan/report.c:360:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->report_found, true);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:314:38: note: expanded from macro '__native_word'
            sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
                                               ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
>> mm/kasan/report.c:360:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->report_found, true);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:48: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                                         ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
>> mm/kasan/report.c:360:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->report_found, true);
                      ~~~~~~^
   include/asm-generic/rwonce.h:61:15: note: expanded from macro 'WRITE_ONCE'
           __WRITE_ONCE(x, val);                                           \
                        ^
   include/asm-generic/rwonce.h:55:20: note: expanded from macro '__WRITE_ONCE'
           *(volatile typeof(x) *)&(x) = (val);                            \
                             ^
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
>> mm/kasan/report.c:360:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->report_found, true);
                      ~~~~~~^
   include/asm-generic/rwonce.h:61:15: note: expanded from macro 'WRITE_ONCE'
           __WRITE_ONCE(x, val);                                           \
                        ^
   include/asm-generic/rwonce.h:55:27: note: expanded from macro '__WRITE_ONCE'
           *(volatile typeof(x) *)&(x) = (val);                            \
                                    ^
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
   mm/kasan/report.c:361:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->sync_fault, sync);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:313:10: note: expanded from macro '__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
                   ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
   mm/kasan/report.c:361:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->sync_fault, sync);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:313:39: note: expanded from macro '__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
                                                ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
   mm/kasan/report.c:361:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->sync_fault, sync);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:314:10: note: expanded from macro '__native_word'
            sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
                   ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
                                ^~~~~~~~~
   include/linux/compiler_types.h:326:9: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                         ^~~~~~~~~
   mm/kasan/report.c:350:9: note: forward declaration of 'struct kunit_kasan_status'
           struct kunit_kasan_status *status;
                  ^
   mm/kasan/report.c:361:19: error: incomplete definition of type 'struct kunit_kasan_status'
           WRITE_ONCE(status->sync_fault, sync);
                      ~~~~~~^
   include/asm-generic/rwonce.h:60:33: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
                                          ^
   include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                            ^
   include/linux/compiler_types.h:314:38: note: expanded from macro '__native_word'
            sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
                                               ^
   include/linux/compiler_types.h:346:22: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                               ^~~~~~~~~
   include/linux/compiler_types.h:334:23: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)


vim +360 mm/kasan/report.c

   345	
   346	#if IS_ENABLED(CONFIG_KUNIT)
   347	static void kasan_update_kunit_status(struct kunit *cur_test, bool sync)
   348	{
   349		struct kunit_resource *resource;
   350		struct kunit_kasan_status *status;
   351	
   352		resource = kunit_find_named_resource(cur_test, "kasan_status");
   353	
   354		if (!resource) {
   355			kunit_set_failure(cur_test);
   356			return;
   357		}
   358	
   359		status = (struct kunit_kasan_status *)resource->data;
 > 360		WRITE_ONCE(status->report_found, true);
   361		WRITE_ONCE(status->sync_fault, sync);
   362		kunit_put_resource(resource);
   363	}
   364	#endif /* IS_ENABLED(CONFIG_KUNIT) */
   365	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Feb. 15, 2022, 11:48 p.m. UTC | #2
Hi,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.17-rc4 next-20220215]
[cannot apply to hnaz-mm/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/andrey-konovalov-linux-dev/kasan-test-support-async-again-and-asymm-modes-for-HW_TAGS/20220215-232923
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d567f5db412ed52de0b3b3efca4a451263de6108
config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20220216/202202160721.IhkGJaXa-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/50334edb33a25643468715fbfc0e6d4a7d594432
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review andrey-konovalov-linux-dev/kasan-test-support-async-again-and-asymm-modes-for-HW_TAGS/20220215-232923
        git checkout 50334edb33a25643468715fbfc0e6d4a7d594432
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash lib// mm/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from <command-line>:
   mm/kasan/report.c: In function 'kasan_update_kunit_status':
>> mm/kasan/report.c:360:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     360 |         WRITE_ONCE(status->report_found, true);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:360:9: note: in expansion of macro 'WRITE_ONCE'
     360 |         WRITE_ONCE(status->report_found, true);
         |         ^~~~~~~~~~
>> mm/kasan/report.c:360:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     360 |         WRITE_ONCE(status->report_found, true);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:360:9: note: in expansion of macro 'WRITE_ONCE'
     360 |         WRITE_ONCE(status->report_found, true);
         |         ^~~~~~~~~~
>> mm/kasan/report.c:360:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     360 |         WRITE_ONCE(status->report_found, true);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:360:9: note: in expansion of macro 'WRITE_ONCE'
     360 |         WRITE_ONCE(status->report_found, true);
         |         ^~~~~~~~~~
>> mm/kasan/report.c:360:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     360 |         WRITE_ONCE(status->report_found, true);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:360:9: note: in expansion of macro 'WRITE_ONCE'
     360 |         WRITE_ONCE(status->report_found, true);
         |         ^~~~~~~~~~
>> mm/kasan/report.c:360:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     360 |         WRITE_ONCE(status->report_found, true);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:360:9: note: in expansion of macro 'WRITE_ONCE'
     360 |         WRITE_ONCE(status->report_found, true);
         |         ^~~~~~~~~~
   In file included from ./arch/arm/include/generated/asm/rwonce.h:1,
                    from include/linux/compiler.h:255,
                    from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from mm/kasan/report.c:12:
>> mm/kasan/report.c:360:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     360 |         WRITE_ONCE(status->report_found, true);
         |                          ^~
   include/asm-generic/rwonce.h:55:27: note: in definition of macro '__WRITE_ONCE'
      55 |         *(volatile typeof(x) *)&(x) = (val);                            \
         |                           ^
   mm/kasan/report.c:360:9: note: in expansion of macro 'WRITE_ONCE'
     360 |         WRITE_ONCE(status->report_found, true);
         |         ^~~~~~~~~~
>> mm/kasan/report.c:360:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     360 |         WRITE_ONCE(status->report_found, true);
         |                          ^~
   include/asm-generic/rwonce.h:55:34: note: in definition of macro '__WRITE_ONCE'
      55 |         *(volatile typeof(x) *)&(x) = (val);                            \
         |                                  ^
   mm/kasan/report.c:360:9: note: in expansion of macro 'WRITE_ONCE'
     360 |         WRITE_ONCE(status->report_found, true);
         |         ^~~~~~~~~~
   In file included from <command-line>:
   mm/kasan/report.c:361:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:361:9: note: in expansion of macro 'WRITE_ONCE'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |         ^~~~~~~~~~
   mm/kasan/report.c:361:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:361:9: note: in expansion of macro 'WRITE_ONCE'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |         ^~~~~~~~~~
   mm/kasan/report.c:361:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:361:9: note: in expansion of macro 'WRITE_ONCE'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |         ^~~~~~~~~~
   mm/kasan/report.c:361:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:60:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      60 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/kasan/report.c:361:9: note: in expansion of macro 'WRITE_ONCE'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |         ^~~~~~~~~~
   mm/kasan/report.c:361:26: error: invalid use of undefined type 'struct kunit_kasan_status'
     361 |         WRITE_ONCE(status->sync_fault, sync);
         |                          ^~
   include/linux/compiler_types.h:326:23: note: in definition of macro '__compiletime_assert'
     326 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
--
   lib/test_kasan.c: In function 'kasan_test_init':
>> lib/test_kasan.c:56:20: error: invalid use of undefined type 'struct kunit_kasan_status'
      56 |         test_status.report_found = false;
         |                    ^
   lib/test_kasan.c:57:20: error: invalid use of undefined type 'struct kunit_kasan_status'
      57 |         test_status.sync_fault = false;
         |                    ^
   In file included from lib/test_kasan.c:25:
   lib/test_kasan.c: In function 'kasan_test_exit':
   lib/test_kasan.c:66:45: error: invalid use of undefined type 'struct kunit_kasan_status'
      66 |         KUNIT_EXPECT_FALSE(test, test_status.report_found);
         |                                             ^
   include/kunit/test.h:782:28: note: in definition of macro 'KUNIT_ASSERTION'
     782 |                            pass,                                               \
         |                            ^~~~
   include/kunit/test.h:841:9: note: in expansion of macro 'KUNIT_UNARY_ASSERTION'
     841 |         KUNIT_UNARY_ASSERTION(test,                                            \
         |         ^~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:849:9: note: in expansion of macro 'KUNIT_FALSE_MSG_ASSERTION'
     849 |         KUNIT_FALSE_MSG_ASSERTION(test, assert_type, condition, NULL)
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1341:9: note: in expansion of macro 'KUNIT_FALSE_ASSERTION'
    1341 |         KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
         |         ^~~~~~~~~~~~~~~~~~~~~
   lib/test_kasan.c:66:9: note: in expansion of macro 'KUNIT_EXPECT_FALSE'
      66 |         KUNIT_EXPECT_FALSE(test, test_status.report_found);
         |         ^~~~~~~~~~~~~~~~~~
   lib/test_kasan.c: In function 'kmalloc_oob_right':
   lib/test_kasan.c:94:55: error: invalid use of undefined type 'struct kunit_kasan_status'
      94 |         KUNIT_EXPECT_FALSE(test, READ_ONCE(test_status.report_found));  \
         |                                                       ^
   include/kunit/test.h:782:28: note: in definition of macro 'KUNIT_ASSERTION'
     782 |                            pass,                                               \
         |                            ^~~~
   include/kunit/test.h:841:9: note: in expansion of macro 'KUNIT_UNARY_ASSERTION'
     841 |         KUNIT_UNARY_ASSERTION(test,                                            \
         |         ^~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:849:9: note: in expansion of macro 'KUNIT_FALSE_MSG_ASSERTION'
     849 |         KUNIT_FALSE_MSG_ASSERTION(test, assert_type, condition, NULL)
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1341:9: note: in expansion of macro 'KUNIT_FALSE_ASSERTION'
    1341 |         KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
         |         ^~~~~~~~~~~~~~~~~~~~~
   lib/test_kasan.c:94:9: note: in expansion of macro 'KUNIT_EXPECT_FALSE'
      94 |         KUNIT_EXPECT_FALSE(test, READ_ONCE(test_status.report_found));  \
         |         ^~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:334:9: note: in expansion of macro '__compiletime_assert'
     334 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:49:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      49 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/test_kasan.c:94:34: note: in expansion of macro 'READ_ONCE'
      94 |         KUNIT_EXPECT_FALSE(test, READ_ONCE(test_status.report_found));  \
         |                                  ^~~~~~~~~
   lib/test_kasan.c:138:17: note: in expansion of macro 'KUNIT_EXPECT_KASAN_FAIL'
     138 |                 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size] = 'x');
         |                 ^~~~~~~~~~~~~~~~~~~~~~~
   lib/test_kasan.c:94:55: error: invalid use of undefined type 'struct kunit_kasan_status'
      94 |         KUNIT_EXPECT_FALSE(test, READ_ONCE(test_status.report_found));  \
         |                                                       ^
   include/kunit/test.h:782:28: note: in definition of macro 'KUNIT_ASSERTION'
     782 |                            pass,                                               \
         |                            ^~~~
   include/kunit/test.h:841:9: note: in expansion of macro 'KUNIT_UNARY_ASSERTION'
     841 |         KUNIT_UNARY_ASSERTION(test,                                            \
         |         ^~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:849:9: note: in expansion of macro 'KUNIT_FALSE_MSG_ASSERTION'
     849 |         KUNIT_FALSE_MSG_ASSERTION(test, assert_type, condition, NULL)
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1341:9: note: in expansion of macro 'KUNIT_FALSE_ASSERTION'
    1341 |         KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
         |         ^~~~~~~~~~~~~~~~~~~~~
   lib/test_kasan.c:94:9: note: in expansion of macro 'KUNIT_EXPECT_FALSE'
      94 |         KUNIT_EXPECT_FALSE(test, READ_ONCE(test_status.report_found));  \
         |         ^~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:334:9: note: in expansion of macro '__compiletime_assert'
     334 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:346:9: note: in expansion of macro '_compiletime_assert'
     346 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |         ^~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
      36 |         compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
         |                            ^~~~~~~~~~~~~
   include/asm-generic/rwonce.h:49:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
      49 |         compiletime_assert_rwonce_type(x);                              \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/test_kasan.c:94:34: note: in expansion of macro 'READ_ONCE'
      94 |         KUNIT_EXPECT_FALSE(test, READ_ONCE(test_status.report_found));  \


vim +360 mm/kasan/report.c

   345	
   346	#if IS_ENABLED(CONFIG_KUNIT)
   347	static void kasan_update_kunit_status(struct kunit *cur_test, bool sync)
   348	{
   349		struct kunit_resource *resource;
   350		struct kunit_kasan_status *status;
   351	
   352		resource = kunit_find_named_resource(cur_test, "kasan_status");
   353	
   354		if (!resource) {
   355			kunit_set_failure(cur_test);
   356			return;
   357		}
   358	
   359		status = (struct kunit_kasan_status *)resource->data;
 > 360		WRITE_ONCE(status->report_found, true);
   361		WRITE_ONCE(status->sync_fault, sync);
   362		kunit_put_resource(resource);
   363	}
   364	#endif /* IS_ENABLED(CONFIG_KUNIT) */
   365	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index 4a45562d8893..d9c3f9e79d7d 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -18,11 +18,6 @@  struct task_struct;
 #include <linux/linkage.h>
 #include <asm/kasan.h>
 
-/* kasan_data struct is used in KUnit tests for KASAN expected failures */
-struct kunit_kasan_expectation {
-	bool report_found;
-};
-
 #endif
 
 #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 26a5c9007653..f90ed146ed23 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -36,7 +36,7 @@  void *kasan_ptr_result;
 int kasan_int_result;
 
 static struct kunit_resource resource;
-static struct kunit_kasan_expectation fail_data;
+static struct kunit_kasan_status test_status;
 static bool multishot;
 
 /*
@@ -53,58 +53,63 @@  static int kasan_test_init(struct kunit *test)
 	}
 
 	multishot = kasan_save_enable_multi_shot();
-	fail_data.report_found = false;
+	test_status.report_found = false;
+	test_status.sync_fault = false;
 	kunit_add_named_resource(test, NULL, NULL, &resource,
-					"kasan_data", &fail_data);
+					"kasan_status", &test_status);
 	return 0;
 }
 
 static void kasan_test_exit(struct kunit *test)
 {
 	kasan_restore_multi_shot(multishot);
-	KUNIT_EXPECT_FALSE(test, fail_data.report_found);
+	KUNIT_EXPECT_FALSE(test, test_status.report_found);
 }
 
 /**
  * KUNIT_EXPECT_KASAN_FAIL() - check that the executed expression produces a
  * KASAN report; causes a test failure otherwise. This relies on a KUnit
- * resource named "kasan_data". Do not use this name for KUnit resources
+ * resource named "kasan_status". Do not use this name for KUnit resources
  * outside of KASAN tests.
  *
- * For hardware tag-based KASAN in sync mode, when a tag fault happens, tag
+ * For hardware tag-based KASAN, when a synchronous tag fault happens, tag
  * checking is auto-disabled. When this happens, this test handler reenables
  * tag checking. As tag checking can be only disabled or enabled per CPU,
  * this handler disables migration (preemption).
  *
- * Since the compiler doesn't see that the expression can change the fail_data
+ * Since the compiler doesn't see that the expression can change the test_status
  * 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.
+ * In between KUNIT_EXPECT_KASAN_FAIL checks, test_status.report_found is kept
+ * as false. This allows detecting KASAN reports that happen outside of the
+ * checks by asserting !test_status.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_sync_fault_possible())				\
 		migrate_disable();					\
-	KUNIT_EXPECT_FALSE(test, READ_ONCE(fail_data.report_found));	\
+	KUNIT_EXPECT_FALSE(test, READ_ONCE(test_status.report_found));	\
 	barrier();							\
 	expression;							\
 	barrier();							\
-	if (!READ_ONCE(fail_data.report_found)) {			\
+	if (kasan_async_fault_possible())				\
+		kasan_force_async_fault();				\
+	if (!READ_ONCE(test_status.report_found)) {			\
 		KUNIT_FAIL(test, KUNIT_SUBTEST_INDENT "KASAN failure "	\
 				"expected in \"" #expression		\
 				 "\", but none occurred");		\
 	}								\
-	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS)) {				\
-		if (READ_ONCE(fail_data.report_found))			\
-			kasan_enable_tagging_sync();			\
+	if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&				\
+	    kasan_sync_fault_possible()) {				\
+		if (READ_ONCE(test_status.report_found) &&		\
+		    READ_ONCE(test_status.sync_fault))			\
+			kasan_enable_tagging();				\
 		migrate_enable();					\
 	}								\
-	WRITE_ONCE(fail_data.report_found, false);			\
+	WRITE_ONCE(test_status.report_found, false);			\
 } while (0)
 
 #define KASAN_TEST_NEEDS_CONFIG_ON(test, config) do {			\
diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
index 7355cb534e4f..97c68c9de042 100644
--- a/mm/kasan/hw_tags.c
+++ b/mm/kasan/hw_tags.c
@@ -132,12 +132,7 @@  void kasan_init_hw_tags_cpu(void)
 	 * Enable async or asymm modes only when explicitly requested
 	 * through the command line.
 	 */
-	if (kasan_arg_mode == KASAN_ARG_MODE_ASYNC)
-		hw_enable_tagging_async();
-	else if (kasan_arg_mode == KASAN_ARG_MODE_ASYMM)
-		hw_enable_tagging_asymm();
-	else
-		hw_enable_tagging_sync();
+	kasan_enable_tagging();
 }
 
 /* kasan_init_hw_tags() is called once on boot CPU. */
@@ -226,11 +221,16 @@  void kasan_free_pages(struct page *page, unsigned int order)
 
 #if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
 
-void kasan_enable_tagging_sync(void)
+void kasan_enable_tagging(void)
 {
-	hw_enable_tagging_sync();
+	if (kasan_arg_mode == KASAN_ARG_MODE_ASYNC)
+		hw_enable_tagging_async();
+	else if (kasan_arg_mode == KASAN_ARG_MODE_ASYMM)
+		hw_enable_tagging_asymm();
+	else
+		hw_enable_tagging_sync();
 }
-EXPORT_SYMBOL_GPL(kasan_enable_tagging_sync);
+EXPORT_SYMBOL_GPL(kasan_enable_tagging);
 
 void kasan_force_async_fault(void)
 {
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index c17fa8d26ffe..49d8df9cf2c6 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -7,6 +7,16 @@ 
 #include <linux/kfence.h>
 #include <linux/stackdepot.h>
 
+#ifdef CONFIG_KASAN_KUNIT_TEST
+
+/* Used in KUnit-compatible KASAN tests. */
+struct kunit_kasan_status {
+	bool report_found;
+	bool sync_fault;
+};
+
+#endif
+
 #ifdef CONFIG_KASAN_HW_TAGS
 
 #include <linux/static_key.h>
@@ -340,12 +350,12 @@  static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
 
 #if defined(CONFIG_KASAN_HW_TAGS) && IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
 
-void kasan_enable_tagging_sync(void);
+void kasan_enable_tagging(void);
 void kasan_force_async_fault(void);
 
 #else /* CONFIG_KASAN_HW_TAGS || CONFIG_KASAN_KUNIT_TEST */
 
-static inline void kasan_enable_tagging_sync(void) { }
+static inline void kasan_enable_tagging(void) { }
 static inline void kasan_force_async_fault(void) { }
 
 #endif /* CONFIG_KASAN_HW_TAGS || CONFIG_KASAN_KUNIT_TEST */
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 3ad9624dcc56..c5a8adc570c0 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -344,20 +344,21 @@  static bool report_enabled(void)
 }
 
 #if IS_ENABLED(CONFIG_KUNIT)
-static void kasan_update_kunit_status(struct kunit *cur_test)
+static void kasan_update_kunit_status(struct kunit *cur_test, bool sync)
 {
 	struct kunit_resource *resource;
-	struct kunit_kasan_expectation *kasan_data;
+	struct kunit_kasan_status *status;
 
-	resource = kunit_find_named_resource(cur_test, "kasan_data");
+	resource = kunit_find_named_resource(cur_test, "kasan_status");
 
 	if (!resource) {
 		kunit_set_failure(cur_test);
 		return;
 	}
 
-	kasan_data = (struct kunit_kasan_expectation *)resource->data;
-	WRITE_ONCE(kasan_data->report_found, true);
+	status = (struct kunit_kasan_status *)resource->data;
+	WRITE_ONCE(status->report_found, true);
+	WRITE_ONCE(status->sync_fault, sync);
 	kunit_put_resource(resource);
 }
 #endif /* IS_ENABLED(CONFIG_KUNIT) */
@@ -371,7 +372,7 @@  void kasan_report_invalid_free(void *object, unsigned long ip)
 
 #if IS_ENABLED(CONFIG_KUNIT)
 	if (current->kunit_test)
-		kasan_update_kunit_status(current->kunit_test);
+		kasan_update_kunit_status(current->kunit_test, true);
 #endif /* IS_ENABLED(CONFIG_KUNIT) */
 
 	start_report(&flags);
@@ -391,7 +392,7 @@  void kasan_report_async(void)
 
 #if IS_ENABLED(CONFIG_KUNIT)
 	if (current->kunit_test)
-		kasan_update_kunit_status(current->kunit_test);
+		kasan_update_kunit_status(current->kunit_test, false);
 #endif /* IS_ENABLED(CONFIG_KUNIT) */
 
 	start_report(&flags);
@@ -413,7 +414,7 @@  static void __kasan_report(unsigned long addr, size_t size, bool is_write,
 
 #if IS_ENABLED(CONFIG_KUNIT)
 	if (current->kunit_test)
-		kasan_update_kunit_status(current->kunit_test);
+		kasan_update_kunit_status(current->kunit_test, true);
 #endif /* IS_ENABLED(CONFIG_KUNIT) */
 
 	disable_trace_on_warning();