* lib/test_kasan_module.c:25:6: warning: variable 'unused' set but not used
@ 2021-04-04 18:16 kernel test robot
2021-04-05 19:29 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2021-04-04 18:16 UTC (permalink / raw)
To: Andrey Konovalov
Cc: kbuild-all, linux-kernel, Marco Elver, Alexander Potapenko,
Andrew Morton, Linux Memory Management List
[-- Attachment #1: Type: text/plain, Size: 5344 bytes --]
Hi Andrey,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 2023a53bdf41b7646b1d384b6816af06309f73a5
commit: 5d92bdffd2d53f98de683229c0ad7d028703fdba kasan: rename CONFIG_TEST_KASAN_MODULE
date: 6 weeks ago
config: arm-randconfig-r024-20210404 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5d92bdffd2d53f98de683229c0ad7d028703fdba
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 5d92bdffd2d53f98de683229c0ad7d028703fdba
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
lib/test_kasan_module.c: In function 'copy_user_test':
>> lib/test_kasan_module.c:25:6: warning: variable 'unused' set but not used [-Wunused-but-set-variable]
25 | int unused;
| ^~~~~~
vim +/unused +25 lib/test_kasan_module.c
73228c7ecc5e40 Patricia Alfonso 2020-10-13 19
73228c7ecc5e40 Patricia Alfonso 2020-10-13 20 static noinline void __init copy_user_test(void)
73228c7ecc5e40 Patricia Alfonso 2020-10-13 21 {
73228c7ecc5e40 Patricia Alfonso 2020-10-13 22 char *kmem;
73228c7ecc5e40 Patricia Alfonso 2020-10-13 23 char __user *usermem;
73228c7ecc5e40 Patricia Alfonso 2020-10-13 24 size_t size = 10;
73228c7ecc5e40 Patricia Alfonso 2020-10-13 @25 int unused;
73228c7ecc5e40 Patricia Alfonso 2020-10-13 26
73228c7ecc5e40 Patricia Alfonso 2020-10-13 27 kmem = kmalloc(size, GFP_KERNEL);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 28 if (!kmem)
73228c7ecc5e40 Patricia Alfonso 2020-10-13 29 return;
73228c7ecc5e40 Patricia Alfonso 2020-10-13 30
73228c7ecc5e40 Patricia Alfonso 2020-10-13 31 usermem = (char __user *)vm_mmap(NULL, 0, PAGE_SIZE,
73228c7ecc5e40 Patricia Alfonso 2020-10-13 32 PROT_READ | PROT_WRITE | PROT_EXEC,
73228c7ecc5e40 Patricia Alfonso 2020-10-13 33 MAP_ANONYMOUS | MAP_PRIVATE, 0);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 34 if (IS_ERR(usermem)) {
73228c7ecc5e40 Patricia Alfonso 2020-10-13 35 pr_err("Failed to allocate user memory\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 36 kfree(kmem);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 37 return;
73228c7ecc5e40 Patricia Alfonso 2020-10-13 38 }
73228c7ecc5e40 Patricia Alfonso 2020-10-13 39
73228c7ecc5e40 Patricia Alfonso 2020-10-13 40 pr_info("out-of-bounds in copy_from_user()\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 41 unused = copy_from_user(kmem, usermem, size + 1 + OOB_TAG_OFF);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 42
73228c7ecc5e40 Patricia Alfonso 2020-10-13 43 pr_info("out-of-bounds in copy_to_user()\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 44 unused = copy_to_user(usermem, kmem, size + 1 + OOB_TAG_OFF);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 45
73228c7ecc5e40 Patricia Alfonso 2020-10-13 46 pr_info("out-of-bounds in __copy_from_user()\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 47 unused = __copy_from_user(kmem, usermem, size + 1 + OOB_TAG_OFF);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 48
73228c7ecc5e40 Patricia Alfonso 2020-10-13 49 pr_info("out-of-bounds in __copy_to_user()\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 50 unused = __copy_to_user(usermem, kmem, size + 1 + OOB_TAG_OFF);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 51
73228c7ecc5e40 Patricia Alfonso 2020-10-13 52 pr_info("out-of-bounds in __copy_from_user_inatomic()\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 53 unused = __copy_from_user_inatomic(kmem, usermem, size + 1 + OOB_TAG_OFF);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 54
73228c7ecc5e40 Patricia Alfonso 2020-10-13 55 pr_info("out-of-bounds in __copy_to_user_inatomic()\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 56 unused = __copy_to_user_inatomic(usermem, kmem, size + 1 + OOB_TAG_OFF);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 57
73228c7ecc5e40 Patricia Alfonso 2020-10-13 58 pr_info("out-of-bounds in strncpy_from_user()\n");
73228c7ecc5e40 Patricia Alfonso 2020-10-13 59 unused = strncpy_from_user(kmem, usermem, size + 1 + OOB_TAG_OFF);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 60
73228c7ecc5e40 Patricia Alfonso 2020-10-13 61 vm_munmap((unsigned long)usermem, PAGE_SIZE);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 62 kfree(kmem);
73228c7ecc5e40 Patricia Alfonso 2020-10-13 63 }
73228c7ecc5e40 Patricia Alfonso 2020-10-13 64
:::::: The code at line 25 was first introduced by commit
:::::: 73228c7ecc5e40c0851c4703c5ec6ed38123e989 KASAN: port KASAN Tests to KUnit
:::::: TO: Patricia Alfonso <trishalfonso@google.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37694 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: lib/test_kasan_module.c:25:6: warning: variable 'unused' set but not used
2021-04-04 18:16 lib/test_kasan_module.c:25:6: warning: variable 'unused' set but not used kernel test robot
@ 2021-04-05 19:29 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2021-04-05 19:29 UTC (permalink / raw)
To: kernel test robot
Cc: Andrey Konovalov, kbuild-all, linux-kernel, Marco Elver,
Alexander Potapenko, Linux Memory Management List
On Mon, 5 Apr 2021 02:16:25 +0800 kernel test robot <lkp@intel.com> wrote:
> Hi Andrey,
>
> First bad commit (maybe != root cause):
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 2023a53bdf41b7646b1d384b6816af06309f73a5
> commit: 5d92bdffd2d53f98de683229c0ad7d028703fdba kasan: rename CONFIG_TEST_KASAN_MODULE
> date: 6 weeks ago
> config: arm-randconfig-r024-20210404 (attached as .config)
> compiler: arm-linux-gnueabi-gcc (GCC) 9.3.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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5d92bdffd2d53f98de683229c0ad7d028703fdba
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 5d92bdffd2d53f98de683229c0ad7d028703fdba
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> lib/test_kasan_module.c: In function 'copy_user_test':
> >> lib/test_kasan_module.c:25:6: warning: variable 'unused' set but not used [-Wunused-but-set-variable]
> 25 | int unused;
> | ^~~~~~
Fair enough ;)
--- a/lib/test_kasan_module.c~a
+++ a/lib/test_kasan_module.c
@@ -22,7 +22,7 @@ static noinline void __init copy_user_te
char *kmem;
char __user *usermem;
size_t size = 10;
- int unused;
+ int __maybe_unused unused;
kmem = kmalloc(size, GFP_KERNEL);
if (!kmem)
_
I guess we could test the copy_*_user return values are as expected,
but that isn't the point?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-05 19:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-04 18:16 lib/test_kasan_module.c:25:6: warning: variable 'unused' set but not used kernel test robot
2021-04-05 19:29 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).