lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202209251151.UrEU1dEQ-lkp@intel.com>
Date:   Sun, 25 Sep 2022 12:33:14 +0800
From:   kernel test robot <lkp@...el.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: arch/mips/loongson64/reset.c:93:25: sparse: sparse: incorrect type
 in argument 1 (different address spaces)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   105a36f3694edc680f3e9318cdd3c03722e42554
commit: f68f2ff91512c199ec24883001245912afc17873 fortify: Detect struct member overflows in memcpy() at compile-time
date:   7 months ago
config: mips-randconfig-s053-20220925
compiler: mips64el-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f68f2ff91512c199ec24883001245912afc17873
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout f68f2ff91512c199ec24883001245912afc17873
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=mips SHELL=/bin/bash arch/mips/loongson64/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

sparse warnings: (new ones prefixed by >>)
   arch/mips/loongson64/reset.c:85:43: sparse: sparse: cast removes address space '__user' of expression
>> arch/mips/loongson64/reset.c:93:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const * @@     got void [noderef] __user *buf @@
   arch/mips/loongson64/reset.c:93:25: sparse:     expected void const *
   arch/mips/loongson64/reset.c:93:25: sparse:     got void [noderef] __user *buf
>> arch/mips/loongson64/reset.c:93:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const * @@     got void [noderef] __user *buf @@
   arch/mips/loongson64/reset.c:93:25: sparse:     expected void const *
   arch/mips/loongson64/reset.c:93:25: sparse:     got void [noderef] __user *buf
   arch/mips/loongson64/reset.c:93:25: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const * @@     got void [noderef] __user *buf @@
   arch/mips/loongson64/reset.c:93:25: sparse:     expected void const *
   arch/mips/loongson64/reset.c:93:25: sparse:     got void [noderef] __user *buf

vim +93 arch/mips/loongson64/reset.c

6ce48897ce476b Huacai Chen 2021-04-13   69  
6ce48897ce476b Huacai Chen 2021-04-13   70  static int loongson_kexec_prepare(struct kimage *image)
6ce48897ce476b Huacai Chen 2021-04-13   71  {
6ce48897ce476b Huacai Chen 2021-04-13   72  	int i, argc = 0;
6ce48897ce476b Huacai Chen 2021-04-13   73  	unsigned int *argv;
6ce48897ce476b Huacai Chen 2021-04-13   74  	char *str, *ptr, *bootloader = "kexec";
6ce48897ce476b Huacai Chen 2021-04-13   75  
6ce48897ce476b Huacai Chen 2021-04-13   76  	/* argv at offset 0, argv[] at offset KEXEC_ARGV_SIZE/2 */
6ce48897ce476b Huacai Chen 2021-04-13   77  	if (image->type == KEXEC_TYPE_DEFAULT)
6ce48897ce476b Huacai Chen 2021-04-13   78  		argv = (unsigned int *)kexec_argv;
6ce48897ce476b Huacai Chen 2021-04-13   79  	else
6ce48897ce476b Huacai Chen 2021-04-13   80  		argv = (unsigned int *)kdump_argv;
6ce48897ce476b Huacai Chen 2021-04-13   81  
6ce48897ce476b Huacai Chen 2021-04-13   82  	argv[argc++] = (unsigned int)(KEXEC_ARGV_ADDR + KEXEC_ARGV_SIZE/2);
6ce48897ce476b Huacai Chen 2021-04-13   83  
6ce48897ce476b Huacai Chen 2021-04-13   84  	for (i = 0; i < image->nr_segments; i++) {
6ce48897ce476b Huacai Chen 2021-04-13   85  		if (!strncmp(bootloader, (char *)image->segment[i].buf,
6ce48897ce476b Huacai Chen 2021-04-13   86  				strlen(bootloader))) {
6ce48897ce476b Huacai Chen 2021-04-13   87  			/*
6ce48897ce476b Huacai Chen 2021-04-13   88  			 * convert command line string to array
6ce48897ce476b Huacai Chen 2021-04-13   89  			 * of parameters (as bootloader does).
6ce48897ce476b Huacai Chen 2021-04-13   90  			 */
6ce48897ce476b Huacai Chen 2021-04-13   91  			int offt;
6ce48897ce476b Huacai Chen 2021-04-13   92  			str = (char *)argv + KEXEC_ARGV_SIZE/2;
6ce48897ce476b Huacai Chen 2021-04-13  @93  			memcpy(str, image->segment[i].buf, KEXEC_ARGV_SIZE/2);
6ce48897ce476b Huacai Chen 2021-04-13   94  			ptr = strchr(str, ' ');
6ce48897ce476b Huacai Chen 2021-04-13   95  
6ce48897ce476b Huacai Chen 2021-04-13   96  			while (ptr && (argc < MAX_ARGS)) {
6ce48897ce476b Huacai Chen 2021-04-13   97  				*ptr = '\0';
6ce48897ce476b Huacai Chen 2021-04-13   98  				if (ptr[1] != ' ') {
6ce48897ce476b Huacai Chen 2021-04-13   99  					offt = (int)(ptr - str + 1);
6ce48897ce476b Huacai Chen 2021-04-13  100  					argv[argc] = KEXEC_ARGV_ADDR + KEXEC_ARGV_SIZE/2 + offt;
6ce48897ce476b Huacai Chen 2021-04-13  101  					argc++;
6ce48897ce476b Huacai Chen 2021-04-13  102  				}
6ce48897ce476b Huacai Chen 2021-04-13  103  				ptr = strchr(ptr + 1, ' ');
6ce48897ce476b Huacai Chen 2021-04-13  104  			}
6ce48897ce476b Huacai Chen 2021-04-13  105  			break;
6ce48897ce476b Huacai Chen 2021-04-13  106  		}
6ce48897ce476b Huacai Chen 2021-04-13  107  	}
6ce48897ce476b Huacai Chen 2021-04-13  108  
6ce48897ce476b Huacai Chen 2021-04-13  109  	if (image->type == KEXEC_TYPE_DEFAULT)
6ce48897ce476b Huacai Chen 2021-04-13  110  		kexec_argc = argc;
6ce48897ce476b Huacai Chen 2021-04-13  111  	else
6ce48897ce476b Huacai Chen 2021-04-13  112  		kdump_argc = argc;
6ce48897ce476b Huacai Chen 2021-04-13  113  
6ce48897ce476b Huacai Chen 2021-04-13  114  	/* kexec/kdump need a safe page to save reboot_code_buffer */
6ce48897ce476b Huacai Chen 2021-04-13  115  	image->control_code_page = virt_to_page((void *)KEXEC_CTRL_CODE);
6ce48897ce476b Huacai Chen 2021-04-13  116  
6ce48897ce476b Huacai Chen 2021-04-13  117  	return 0;
6ce48897ce476b Huacai Chen 2021-04-13  118  }
6ce48897ce476b Huacai Chen 2021-04-13  119  

:::::: The code at line 93 was first introduced by commit
:::::: 6ce48897ce476bed86fde28752c27596e8753277 MIPS: Loongson64: Add kexec/kdump support

:::::: TO: Huacai Chen <chenhc@...ote.com>
:::::: CC: Thomas Bogendoerfer <tsbogend@...ha.franken.de>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (174332 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ