include/linux/kasan-checks.h:38:27: warning: 'space_args' may be used uninitialized

From: kernel test robot
Date: Fri Sep 15 2023 - 16:44:31 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 9fdfb15a3dbf818e06be514f4abbfc071004cbe7
commit: 5aa4ac64e6add3e40d5049e31275b2822daf885d LoongArch: Add KASAN (Kernel Address Sanitizer) support
date: 9 days ago
config: loongarch-randconfig-002-20230916 (https://download.01.org/0day-ci/archive/20230916/202309160440.jECtzdr6-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230916/202309160440.jECtzdr6-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309160440.jECtzdr6-lkp@xxxxxxxxx/

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

In file included from include/asm-generic/rwonce.h:26,
from ./arch/loongarch/include/generated/asm/rwonce.h:1,
from include/linux/compiler.h:246,
from include/linux/export.h:5,
from include/linux/linkage.h:7,
from include/linux/kernel.h:17,
from fs/btrfs/ioctl.c:6:
In function 'instrument_copy_from_user_before',
inlined from '_copy_from_user' at include/linux/uaccess.h:148:3,
inlined from 'copy_from_user' at include/linux/uaccess.h:183:7,
inlined from 'btrfs_ioctl_space_info' at fs/btrfs/ioctl.c:2993:6:
>> include/linux/kasan-checks.h:38:27: warning: 'space_args' may be used uninitialized [-Wmaybe-uninitialized]
38 | #define kasan_check_write __kasan_check_write
include/linux/instrumented.h:129:9: note: in expansion of macro 'kasan_check_write'
129 | kasan_check_write(to, n);
| ^~~~~~~~~~~~~~~~~
include/linux/kasan-checks.h: In function 'btrfs_ioctl_space_info':
include/linux/kasan-checks.h:20:6: note: by argument 1 of type 'const volatile void *' to '__kasan_check_write' declared here
20 | bool __kasan_check_write(const volatile void *p, unsigned int size);
| ^~~~~~~~~~~~~~~~~~~
fs/btrfs/ioctl.c:2975:39: note: 'space_args' declared here
2975 | struct btrfs_ioctl_space_args space_args;
| ^~~~~~~~~~


vim +/space_args +38 include/linux/kasan-checks.h

7d8ad890dad00f Marco Elver 2019-07-11 31
7d8ad890dad00f Marco Elver 2019-07-11 32 /*
7d8ad890dad00f Marco Elver 2019-07-11 33 * kasan_check_*: Only available when the particular compilation unit has KASAN
7d8ad890dad00f Marco Elver 2019-07-11 34 * instrumentation enabled. May be used in header files.
7d8ad890dad00f Marco Elver 2019-07-11 35 */
7d8ad890dad00f Marco Elver 2019-07-11 36 #ifdef __SANITIZE_ADDRESS__
7d8ad890dad00f Marco Elver 2019-07-11 37 #define kasan_check_read __kasan_check_read
7d8ad890dad00f Marco Elver 2019-07-11 @38 #define kasan_check_write __kasan_check_write
64f8ebaf115bcd Andrey Ryabinin 2016-05-20 39 #else
b5f6e0fc7d60e0 Marco Elver 2019-07-11 40 static inline bool kasan_check_read(const volatile void *p, unsigned int size)
b5f6e0fc7d60e0 Marco Elver 2019-07-11 41 {
b5f6e0fc7d60e0 Marco Elver 2019-07-11 42 return true;
b5f6e0fc7d60e0 Marco Elver 2019-07-11 43 }
b5f6e0fc7d60e0 Marco Elver 2019-07-11 44 static inline bool kasan_check_write(const volatile void *p, unsigned int size)
b5f6e0fc7d60e0 Marco Elver 2019-07-11 45 {
b5f6e0fc7d60e0 Marco Elver 2019-07-11 46 return true;
b5f6e0fc7d60e0 Marco Elver 2019-07-11 47 }
64f8ebaf115bcd Andrey Ryabinin 2016-05-20 48 #endif
64f8ebaf115bcd Andrey Ryabinin 2016-05-20 49

:::::: The code at line 38 was first introduced by commit
:::::: 7d8ad890dad00f6cd64bfb44d9be4fceb10cf819 mm/kasan: introduce __kasan_check_{read,write}

:::::: TO: Marco Elver <elver@xxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki