[linux-next:master 5214/6860] kernel/sys.c:1896:19: sparse: sparse: incorrect type in initializer (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/next/linux-next.git master
head:   8ca403f3e7a23c4513046ad8d107adfbe4703362
commit: 9cf1d7d830f4a586dfa4ddcaf9eae3959e0708ef [5214/6860] ARC: cmpxchg/xchg: rewrite as macros to make type safe
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 10.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-348-gf0e6938b-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9cf1d7d830f4a586dfa4ddcaf9eae3959e0708ef
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout 9cf1d7d830f4a586dfa4ddcaf9eae3959e0708ef
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arc 

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


sparse warnings: (new ones prefixed by >>)
>> kernel/sys.c:1896:19: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected struct file [noderef] __rcu *_val_ @@     got struct file *[assigned] file @@
   kernel/sys.c:1896:19: sparse:     expected struct file [noderef] __rcu *_val_
   kernel/sys.c:1896:19: sparse:     got struct file *[assigned] file
   kernel/sys.c:1896:17: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct file *old_exe @@     got struct file [noderef] __rcu *[assigned] _val_ @@
   kernel/sys.c:1896:17: sparse:     expected struct file *old_exe
   kernel/sys.c:1896:17: sparse:     got struct file [noderef] __rcu *[assigned] _val_
   kernel/sys.c:1067:32: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct task_struct *p1 @@     got struct task_struct [noderef] __rcu *real_parent @@
   kernel/sys.c:1067:32: sparse:     expected struct task_struct *p1
   kernel/sys.c:1067:32: sparse:     got struct task_struct [noderef] __rcu *real_parent
   kernel/sys.c: note: in included file (through include/linux/rcuwait.h, include/linux/percpu-rwsem.h, include/linux/fs.h, ...):
   include/linux/sched/signal.h:714:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct spinlock [usertype] *lock @@     got struct spinlock [noderef] __rcu * @@
   include/linux/sched/signal.h:714:37: sparse:     expected struct spinlock [usertype] *lock
   include/linux/sched/signal.h:714:37: sparse:     got struct spinlock [noderef] __rcu *
--
>> net/ipv4/tcp_cong.c:238:24: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected struct tcp_congestion_ops const [noderef] __rcu *_val_ @@     got struct tcp_congestion_ops *[assigned] ca @@
   net/ipv4/tcp_cong.c:238:24: sparse:     expected struct tcp_congestion_ops const [noderef] __rcu *_val_
   net/ipv4/tcp_cong.c:238:24: sparse:     got struct tcp_congestion_ops *[assigned] ca
   net/ipv4/tcp_cong.c:238:22: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct tcp_congestion_ops const *prev @@     got struct tcp_congestion_ops const [noderef] __rcu *[assigned] _val_ @@
   net/ipv4/tcp_cong.c:238:22: sparse:     expected struct tcp_congestion_ops const *prev
   net/ipv4/tcp_cong.c:238:22: sparse:     got struct tcp_congestion_ops const [noderef] __rcu *[assigned] _val_

vim +1896 kernel/sys.c

^1da177e4c3f41 Linus Torvalds        2005-04-16  1845  
6e399cd144d850 Davidlohr Bueso       2015-04-16  1846  static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1847  {
2903ff019b346a Al Viro               2012-08-28  1848  	struct fd exe;
6e399cd144d850 Davidlohr Bueso       2015-04-16  1849  	struct file *old_exe, *exe_file;
496ad9aa8ef448 Al Viro               2013-01-23  1850  	struct inode *inode;
2903ff019b346a Al Viro               2012-08-28  1851  	int err;
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1852  
2903ff019b346a Al Viro               2012-08-28  1853  	exe = fdget(fd);
2903ff019b346a Al Viro               2012-08-28  1854  	if (!exe.file)
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1855  		return -EBADF;
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1856  
496ad9aa8ef448 Al Viro               2013-01-23  1857  	inode = file_inode(exe.file);
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1858  
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1859  	/*
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1860  	 * Because the original mm->exe_file points to executable file, make
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1861  	 * sure that this one is executable as well, to avoid breaking an
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1862  	 * overall picture.
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1863  	 */
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1864  	err = -EACCES;
90f8572b0f021f Eric W. Biederman     2015-06-29  1865  	if (!S_ISREG(inode->i_mode) || path_noexec(&exe.file->f_path))
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1866  		goto exit;
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1867  
02f92b3868a1b3 Christian Brauner     2021-01-21  1868  	err = file_permission(exe.file, MAY_EXEC);
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1869  	if (err)
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1870  		goto exit;
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1871  
bafb282df29c15 Konstantin Khlebnikov 2012-06-07  1872  	/*
4229fb1dc6843c Konstantin Khlebnikov 2012-07-11  1873  	 * Forbid mm->exe_file change if old file still mapped.
bafb282df29c15 Konstantin Khlebnikov 2012-06-07  1874  	 */
6e399cd144d850 Davidlohr Bueso       2015-04-16  1875  	exe_file = get_mm_exe_file(mm);
bafb282df29c15 Konstantin Khlebnikov 2012-06-07  1876  	err = -EBUSY;
6e399cd144d850 Davidlohr Bueso       2015-04-16  1877  	if (exe_file) {
4229fb1dc6843c Konstantin Khlebnikov 2012-07-11  1878  		struct vm_area_struct *vma;
4229fb1dc6843c Konstantin Khlebnikov 2012-07-11  1879  
d8ed45c5dcd455 Michel Lespinasse     2020-06-08  1880  		mmap_read_lock(mm);
6e399cd144d850 Davidlohr Bueso       2015-04-16  1881  		for (vma = mm->mmap; vma; vma = vma->vm_next) {
6e399cd144d850 Davidlohr Bueso       2015-04-16  1882  			if (!vma->vm_file)
6e399cd144d850 Davidlohr Bueso       2015-04-16  1883  				continue;
6e399cd144d850 Davidlohr Bueso       2015-04-16  1884  			if (path_equal(&vma->vm_file->f_path,
6e399cd144d850 Davidlohr Bueso       2015-04-16  1885  				       &exe_file->f_path))
6e399cd144d850 Davidlohr Bueso       2015-04-16  1886  				goto exit_err;
6e399cd144d850 Davidlohr Bueso       2015-04-16  1887  		}
6e399cd144d850 Davidlohr Bueso       2015-04-16  1888  
d8ed45c5dcd455 Michel Lespinasse     2020-06-08  1889  		mmap_read_unlock(mm);
6e399cd144d850 Davidlohr Bueso       2015-04-16  1890  		fput(exe_file);
bafb282df29c15 Konstantin Khlebnikov 2012-06-07  1891  	}
bafb282df29c15 Konstantin Khlebnikov 2012-06-07  1892  
4229fb1dc6843c Konstantin Khlebnikov 2012-07-11  1893  	err = 0;
6e399cd144d850 Davidlohr Bueso       2015-04-16  1894  	/* set the new file, lockless */
6e399cd144d850 Davidlohr Bueso       2015-04-16  1895  	get_file(exe.file);
6e399cd144d850 Davidlohr Bueso       2015-04-16 @1896  	old_exe = xchg(&mm->exe_file, exe.file);
6e399cd144d850 Davidlohr Bueso       2015-04-16  1897  	if (old_exe)
6e399cd144d850 Davidlohr Bueso       2015-04-16  1898  		fput(old_exe);
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1899  exit:
2903ff019b346a Al Viro               2012-08-28  1900  	fdput(exe);
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1901  	return err;
6e399cd144d850 Davidlohr Bueso       2015-04-16  1902  exit_err:
d8ed45c5dcd455 Michel Lespinasse     2020-06-08  1903  	mmap_read_unlock(mm);
6e399cd144d850 Davidlohr Bueso       2015-04-16  1904  	fput(exe_file);
6e399cd144d850 Davidlohr Bueso       2015-04-16  1905  	goto exit;
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1906  }
b32dfe377102ce Cyrill Gorcunov       2012-05-31  1907  

:::::: The code at line 1896 was first introduced by commit
:::::: 6e399cd144d8500ffb5d40fa6848890e2580a80a prctl: avoid using mmap_sem for exe_file serialization

:::::: TO: Davidlohr Bueso <dave@xxxxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip


[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