kernel/stackleak.c:33:50: sparse: sparse: incorrect type in argument 3 (different address spaces)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2faac9a98f010cf5b342fa89ac489c4586364e6e
commit: 0df8bdd5e3b3e557ce2c2575fce0c64c5dd1045a stackleak: move stack_erasing sysctl to stackleak.c
date:   1 year, 2 months ago
config: arm64-randconfig-s032-20230321 (https://download.01.org/0day-ci/archive/20230322/202303220449.l6Q32ILq-lkp@xxxxxxxxx/config)
compiler: aarch64-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=0df8bdd5e3b3e557ce2c2575fce0c64c5dd1045a
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 0df8bdd5e3b3e557ce2c2575fce0c64c5dd1045a
        # 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=arm64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202303220449.l6Q32ILq-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> kernel/stackleak.c:33:50: sparse: sparse: incorrect type in argument 3 (different address spaces) @@     expected void * @@     got void [noderef] __user *buffer @@
   kernel/stackleak.c:33:50: sparse:     expected void *
   kernel/stackleak.c:33:50: sparse:     got void [noderef] __user *buffer
>> kernel/stackleak.c:53:35: sparse: sparse: incorrect type in initializer (incompatible argument 3 (different address spaces)) @@     expected int ( [usertype] *proc_handler )( ... ) @@     got int ( * )( ... ) @@
   kernel/stackleak.c:53:35: sparse:     expected int ( [usertype] *proc_handler )( ... )
   kernel/stackleak.c:53:35: sparse:     got int ( * )( ... )

vim +33 kernel/stackleak.c

964c9dff0091893 Alexander Popov 2018-08-17  22  
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  23  #ifdef CONFIG_SYSCTL
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  24  static int stack_erasing_sysctl(struct ctl_table *table, int write,
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  25  			void __user *buffer, size_t *lenp, loff_t *ppos)
964c9dff0091893 Alexander Popov 2018-08-17  26  {
964c9dff0091893 Alexander Popov 2018-08-17  27  	int ret = 0;
964c9dff0091893 Alexander Popov 2018-08-17  28  	int state = !static_branch_unlikely(&stack_erasing_bypass);
964c9dff0091893 Alexander Popov 2018-08-17  29  	int prev_state = state;
964c9dff0091893 Alexander Popov 2018-08-17  30  
964c9dff0091893 Alexander Popov 2018-08-17  31  	table->data = &state;
964c9dff0091893 Alexander Popov 2018-08-17  32  	table->maxlen = sizeof(int);
964c9dff0091893 Alexander Popov 2018-08-17 @33  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
964c9dff0091893 Alexander Popov 2018-08-17  34  	state = !!state;
964c9dff0091893 Alexander Popov 2018-08-17  35  	if (ret || !write || state == prev_state)
964c9dff0091893 Alexander Popov 2018-08-17  36  		return ret;
964c9dff0091893 Alexander Popov 2018-08-17  37  
964c9dff0091893 Alexander Popov 2018-08-17  38  	if (state)
964c9dff0091893 Alexander Popov 2018-08-17  39  		static_branch_disable(&stack_erasing_bypass);
964c9dff0091893 Alexander Popov 2018-08-17  40  	else
964c9dff0091893 Alexander Popov 2018-08-17  41  		static_branch_enable(&stack_erasing_bypass);
964c9dff0091893 Alexander Popov 2018-08-17  42  
964c9dff0091893 Alexander Popov 2018-08-17  43  	pr_warn("stackleak: kernel stack erasing is %s\n",
964c9dff0091893 Alexander Popov 2018-08-17  44  					state ? "enabled" : "disabled");
964c9dff0091893 Alexander Popov 2018-08-17  45  	return ret;
964c9dff0091893 Alexander Popov 2018-08-17  46  }
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  47  static struct ctl_table stackleak_sysctls[] = {
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  48  	{
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  49  		.procname	= "stack_erasing",
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  50  		.data		= NULL,
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  51  		.maxlen		= sizeof(int),
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  52  		.mode		= 0600,
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21 @53  		.proc_handler	= stack_erasing_sysctl,
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  54  		.extra1		= SYSCTL_ZERO,
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  55  		.extra2		= SYSCTL_ONE,
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  56  	},
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  57  	{}
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  58  };
0df8bdd5e3b3e55 Xiaoming Ni     2022-01-21  59  

:::::: The code at line 33 was first introduced by commit
:::::: 964c9dff0091893a9a74a88edf984c6da0b779f7 stackleak: Allow runtime disabling of kernel stack erasing

:::::: TO: Alexander Popov <alex.popov@xxxxxxxxx>
:::::: CC: Kees Cook <keescook@xxxxxxxxxxxx>

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux