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: <202011091740.3SS3xdme-lkp@intel.com>
Date:   Mon, 9 Nov 2020 17:54:50 +0800
From:   kernel test robot <lkp@...el.com>
To:     Luc Van Oostenryck <luc.vanoostenryck@...il.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Subject: arch/arm/kernel/swp_emulate.c:198:14: sparse: sparse: incorrect type
 in argument 1 (different base types)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f8394f232b1eab649ce2df5c5f15b0e528c92091
commit: e5fc436f06eef54ef512ea55a9db8eb9f2e76959 sparse: use static inline for __chk_{user,io}_ptr()
date:   2 months ago
config: arm-randconfig-s031-20201105 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.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.3-76-gf680124b-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5fc436f06eef54ef512ea55a9db8eb9f2e76959
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout e5fc436f06eef54ef512ea55a9db8eb9f2e76959
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm 

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


"sparse warnings: (new ones prefixed by >>)"
>> arch/arm/kernel/swp_emulate.c:198:14: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int @@
>> arch/arm/kernel/swp_emulate.c:198:14: sparse:     expected void const volatile [noderef] __user *ptr
   arch/arm/kernel/swp_emulate.c:198:14: sparse:     got unsigned int

vim +198 arch/arm/kernel/swp_emulate.c

64d2dc384e41e2b Leif Lindholm  2010-09-16  153  
64d2dc384e41e2b Leif Lindholm  2010-09-16  154  /*
64d2dc384e41e2b Leif Lindholm  2010-09-16  155   * swp_handler logs the id of calling process, dissects the instruction, sanity
64d2dc384e41e2b Leif Lindholm  2010-09-16  156   * checks the memory location, calls emulate_swpX for the actual operation and
64d2dc384e41e2b Leif Lindholm  2010-09-16  157   * deals with fixup/error handling before returning
64d2dc384e41e2b Leif Lindholm  2010-09-16  158   */
64d2dc384e41e2b Leif Lindholm  2010-09-16  159  static int swp_handler(struct pt_regs *regs, unsigned int instr)
64d2dc384e41e2b Leif Lindholm  2010-09-16  160  {
64d2dc384e41e2b Leif Lindholm  2010-09-16  161  	unsigned int address, destreg, data, type;
64d2dc384e41e2b Leif Lindholm  2010-09-16  162  	unsigned int res = 0;
64d2dc384e41e2b Leif Lindholm  2010-09-16  163  
a8b0ca17b80e92f Peter Zijlstra 2011-06-27  164  	perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, regs->ARM_pc);
64d2dc384e41e2b Leif Lindholm  2010-09-16  165  
c245dcd326fb9f8 Leif Lindholm  2011-12-12  166  	res = arm_check_condition(instr, regs->ARM_cpsr);
c245dcd326fb9f8 Leif Lindholm  2011-12-12  167  	switch (res) {
c245dcd326fb9f8 Leif Lindholm  2011-12-12  168  	case ARM_OPCODE_CONDTEST_PASS:
c245dcd326fb9f8 Leif Lindholm  2011-12-12  169  		break;
c245dcd326fb9f8 Leif Lindholm  2011-12-12  170  	case ARM_OPCODE_CONDTEST_FAIL:
c245dcd326fb9f8 Leif Lindholm  2011-12-12  171  		/* Condition failed - return to next instruction */
c245dcd326fb9f8 Leif Lindholm  2011-12-12  172  		regs->ARM_pc += 4;
c245dcd326fb9f8 Leif Lindholm  2011-12-12  173  		return 0;
c245dcd326fb9f8 Leif Lindholm  2011-12-12  174  	case ARM_OPCODE_CONDTEST_UNCOND:
c245dcd326fb9f8 Leif Lindholm  2011-12-12  175  		/* If unconditional encoding - not a SWP, undef */
c245dcd326fb9f8 Leif Lindholm  2011-12-12  176  		return -EFAULT;
c245dcd326fb9f8 Leif Lindholm  2011-12-12  177  	default:
c245dcd326fb9f8 Leif Lindholm  2011-12-12  178  		return -EINVAL;
c245dcd326fb9f8 Leif Lindholm  2011-12-12  179  	}
c245dcd326fb9f8 Leif Lindholm  2011-12-12  180  
64d2dc384e41e2b Leif Lindholm  2010-09-16  181  	if (current->pid != previous_pid) {
64d2dc384e41e2b Leif Lindholm  2010-09-16  182  		pr_debug("\"%s\" (%ld) uses deprecated SWP{B} instruction\n",
64d2dc384e41e2b Leif Lindholm  2010-09-16  183  			 current->comm, (unsigned long)current->pid);
64d2dc384e41e2b Leif Lindholm  2010-09-16  184  		previous_pid = current->pid;
64d2dc384e41e2b Leif Lindholm  2010-09-16  185  	}
64d2dc384e41e2b Leif Lindholm  2010-09-16  186  
64d2dc384e41e2b Leif Lindholm  2010-09-16  187  	address = regs->uregs[EXTRACT_REG_NUM(instr, RN_OFFSET)];
64d2dc384e41e2b Leif Lindholm  2010-09-16  188  	data	= regs->uregs[EXTRACT_REG_NUM(instr, RT2_OFFSET)];
64d2dc384e41e2b Leif Lindholm  2010-09-16  189  	destreg = EXTRACT_REG_NUM(instr, RT_OFFSET);
64d2dc384e41e2b Leif Lindholm  2010-09-16  190  
64d2dc384e41e2b Leif Lindholm  2010-09-16  191  	type = instr & TYPE_SWPB;
64d2dc384e41e2b Leif Lindholm  2010-09-16  192  
64d2dc384e41e2b Leif Lindholm  2010-09-16  193  	pr_debug("addr in r%d->0x%08x, dest is r%d, source in r%d->0x%08x)\n",
64d2dc384e41e2b Leif Lindholm  2010-09-16  194  		 EXTRACT_REG_NUM(instr, RN_OFFSET), address,
64d2dc384e41e2b Leif Lindholm  2010-09-16  195  		 destreg, EXTRACT_REG_NUM(instr, RT2_OFFSET), data);
64d2dc384e41e2b Leif Lindholm  2010-09-16  196  
64d2dc384e41e2b Leif Lindholm  2010-09-16  197  	/* Check access in reasonable access range for both SWP and SWPB */
96d4f267e40f950 Linus Torvalds 2019-01-03 @198  	if (!access_ok((address & ~3), 4)) {
64d2dc384e41e2b Leif Lindholm  2010-09-16  199  		pr_debug("SWP{B} emulation: access to %p not allowed!\n",
64d2dc384e41e2b Leif Lindholm  2010-09-16  200  			 (void *)address);
64d2dc384e41e2b Leif Lindholm  2010-09-16  201  		res = -EFAULT;
64d2dc384e41e2b Leif Lindholm  2010-09-16  202  	} else {
64d2dc384e41e2b Leif Lindholm  2010-09-16  203  		res = emulate_swpX(address, &data, type);
64d2dc384e41e2b Leif Lindholm  2010-09-16  204  	}
64d2dc384e41e2b Leif Lindholm  2010-09-16  205  
64d2dc384e41e2b Leif Lindholm  2010-09-16  206  	if (res == 0) {
64d2dc384e41e2b Leif Lindholm  2010-09-16  207  		/*
64d2dc384e41e2b Leif Lindholm  2010-09-16  208  		 * On successful emulation, revert the adjustment to the PC
64d2dc384e41e2b Leif Lindholm  2010-09-16  209  		 * made in kernel/traps.c in order to resume execution at the
64d2dc384e41e2b Leif Lindholm  2010-09-16  210  		 * instruction following the SWP{B}.
64d2dc384e41e2b Leif Lindholm  2010-09-16  211  		 */
64d2dc384e41e2b Leif Lindholm  2010-09-16  212  		regs->ARM_pc += 4;
64d2dc384e41e2b Leif Lindholm  2010-09-16  213  		regs->uregs[destreg] = data;
64d2dc384e41e2b Leif Lindholm  2010-09-16  214  	} else if (res == -EFAULT) {
64d2dc384e41e2b Leif Lindholm  2010-09-16  215  		/*
64d2dc384e41e2b Leif Lindholm  2010-09-16  216  		 * Memory errors do not mean emulation failed.
64d2dc384e41e2b Leif Lindholm  2010-09-16  217  		 * Set up signal info to return SEGV, then return OK
64d2dc384e41e2b Leif Lindholm  2010-09-16  218  		 */
64d2dc384e41e2b Leif Lindholm  2010-09-16  219  		set_segfault(regs, address);
64d2dc384e41e2b Leif Lindholm  2010-09-16  220  	}
64d2dc384e41e2b Leif Lindholm  2010-09-16  221  
64d2dc384e41e2b Leif Lindholm  2010-09-16  222  	return 0;
64d2dc384e41e2b Leif Lindholm  2010-09-16  223  }
64d2dc384e41e2b Leif Lindholm  2010-09-16  224  

:::::: The code at line 198 was first introduced by commit
:::::: 96d4f267e40f9509e8a66e2b39e8b95655617693 Remove 'type' argument from access_ok() function

:::::: TO: Linus Torvalds <torvalds@...ux-foundation.org>
:::::: CC: Linus Torvalds <torvalds@...ux-foundation.org>

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

Download attachment ".config.gz" of type "application/gzip" (32738 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ