Re: [driver-core:driver-core-testing 30/34] fs/kernfs/file.c:160:46: sparse: sparse: incorrect type in argument 1 (different address spaces)

Greg Kroah-Hartman
2022-04-27T07:53:47Z

On Wed, Apr 27, 2022 at 04:17:29AM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git driver-core-testing
> head: 26360a8c9732cff2ee5bc2f180e9716b63e9f650
> commit: 07b42a72474e4ab59d6acb451f7816664095d7c0 [30/34] kernfs: make ->attr.open RCU protected.
> config: alpha-randconfig-s032-20220425 (https://download.01.org/0day-ci/archive/20220427/202204270438.Uex7Kt3b-lkp@intel.com/config)
> compiler: alpha-linux-gcc (GCC) 11.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.4-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?id=07b42a72474e4ab59d6acb451f7816664095d7c0
> git remote add driver-core https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
> git fetch --no-tags driver-core driver-core-testing
> git checkout 07b42a72474e4ab59d6acb451f7816664095d7c0
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha SHELL=/bin/bash fs/kernfs/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
> >> fs/kernfs/file.c:160:46: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct atomic_t const [usertype] *v @@ got struct atomic_t [noderef] __rcu * @@
> fs/kernfs/file.c:160:46: sparse: expected struct atomic_t const [usertype] *v
> fs/kernfs/file.c:160:46: sparse: got struct atomic_t [noderef] __rcu *
> fs/kernfs/file.c:204:46: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct atomic_t const [usertype] *v @@ got struct atomic_t [noderef] __rcu * @@
> fs/kernfs/file.c:204:46: sparse: expected struct atomic_t const [usertype] *v
> fs/kernfs/file.c:204:46: sparse: got struct atomic_t [noderef] __rcu *
>
> vim +160 fs/kernfs/file.c
>
> 414985ae23c031e Tejun Heo 2013-11-28 155
> 414985ae23c031e Tejun Heo 2013-11-28 156 static int kernfs_seq_show(struct seq_file *sf, void *v)
> 414985ae23c031e Tejun Heo 2013-11-28 157 {
> c525aaddc366df2 Tejun Heo 2013-12-11 158 struct kernfs_open_file *of = sf->private;
> 414985ae23c031e Tejun Heo 2013-11-28 159
> adc5e8b58f4886d Tejun Heo 2013-12-11 @160 of->event = atomic_read(&of->kn->attr.open->event);
> 414985ae23c031e Tejun Heo 2013-11-28 161
> adc5e8b58f4886d Tejun Heo 2013-12-11 162 return of->kn->attr.ops->seq_show(sf, v);
> 414985ae23c031e Tejun Heo 2013-11-28 163 }
> 414985ae23c031e Tejun Heo 2013-11-28 164
>
> :::::: The code at line 160 was first introduced by commit
> :::::: adc5e8b58f4886d45f79f4ff41a09001a76a6b12 kernfs: drop s_ prefix from kernfs_node members
>
> :::::: TO: Tejun Heo <tj@kernel.org>
> :::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>

Imran, I'm going to go drop this change from my tree and let you
resubmit it after it's been fixed up (you need to grab the rcu reference
on attr.open here.)

thanks,

greg k-h