[m68knommu:for-next 1/1] arch/m68k/kernel/signal.c:923:16: 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/gerg/m68knommu.git for-next
head:   ef03e4545eac3137f37604daef09019dd638b17e
commit: ef03e4545eac3137f37604daef09019dd638b17e [1/1] m68knommu: switch to using asm-generic/uaccess.h
config: m68k-randconfig-s032-20200913 (attached as .config)
compiler: m68k-linux-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.2-191-g10164920-dirty
        git checkout ef03e4545eac3137f37604daef09019dd638b17e
        # 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=m68k 

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


sparse warnings: (new ones prefixed by >>)

arch/m68k/kernel/signal.c:923:16: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected char [noderef] __user *__x @@     got void * @@
arch/m68k/kernel/signal.c:923:16: sparse:     expected char [noderef] __user *__x
   arch/m68k/kernel/signal.c:923:16: sparse:     got void *
   arch/m68k/kernel/signal.c:1007:16: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected char [noderef] __user *__x @@     got void * @@
   arch/m68k/kernel/signal.c:1007:16: sparse:     expected char [noderef] __user *__x
   arch/m68k/kernel/signal.c:1007:16: sparse:     got void *

# https://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu.git/commit/?id=ef03e4545eac3137f37604daef09019dd638b17e
git remote add m68knommu https://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu.git
git fetch --no-tags m68knommu for-next
git checkout ef03e4545eac3137f37604daef09019dd638b17e
vim +923 arch/m68k/kernel/signal.c

0c22fafd312cd86 Greg Ungerer       2012-03-14  783  
a95517992a37488 Greg Ungerer       2016-02-15 @784  asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
0c22fafd312cd86 Greg Ungerer       2012-03-14  785  {
0c22fafd312cd86 Greg Ungerer       2012-03-14  786  	unsigned long usp = rdusp();
0c22fafd312cd86 Greg Ungerer       2012-03-14  787  	struct sigframe __user *frame = (struct sigframe __user *)(usp - 4);
0c22fafd312cd86 Greg Ungerer       2012-03-14  788  	sigset_t set;
0c22fafd312cd86 Greg Ungerer       2012-03-14  789  
96d4f267e40f950 Linus Torvalds     2019-01-03  790  	if (!access_ok(frame, sizeof(*frame)))
0c22fafd312cd86 Greg Ungerer       2012-03-14  791  		goto badframe;
0c22fafd312cd86 Greg Ungerer       2012-03-14  792  	if (__get_user(set.sig[0], &frame->sc.sc_mask) ||
0c22fafd312cd86 Greg Ungerer       2012-03-14  793  	    (_NSIG_WORDS > 1 &&
0c22fafd312cd86 Greg Ungerer       2012-03-14  794  	     __copy_from_user(&set.sig[1], &frame->extramask,
0c22fafd312cd86 Greg Ungerer       2012-03-14  795  			      sizeof(frame->extramask))))
0c22fafd312cd86 Greg Ungerer       2012-03-14  796  		goto badframe;
0c22fafd312cd86 Greg Ungerer       2012-03-14  797  
43a35995562495b Matt Fleming       2012-05-11  798  	set_current_blocked(&set);
0c22fafd312cd86 Greg Ungerer       2012-03-14  799  
0c22fafd312cd86 Greg Ungerer       2012-03-14  800  	if (restore_sigcontext(regs, &frame->sc, frame + 1))
0c22fafd312cd86 Greg Ungerer       2012-03-14  801  		goto badframe;
0c22fafd312cd86 Greg Ungerer       2012-03-14  802  	return regs->d0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  803  
0c22fafd312cd86 Greg Ungerer       2012-03-14  804  badframe:
3cf5d076fb4d489 Eric W. Biederman  2019-05-23  805  	force_sig(SIGSEGV);
0c22fafd312cd86 Greg Ungerer       2012-03-14  806  	return 0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  807  }
0c22fafd312cd86 Greg Ungerer       2012-03-14  808  
a95517992a37488 Greg Ungerer       2016-02-15  809  asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
0c22fafd312cd86 Greg Ungerer       2012-03-14  810  {
0c22fafd312cd86 Greg Ungerer       2012-03-14  811  	unsigned long usp = rdusp();
0c22fafd312cd86 Greg Ungerer       2012-03-14  812  	struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4);
0c22fafd312cd86 Greg Ungerer       2012-03-14  813  	sigset_t set;
0c22fafd312cd86 Greg Ungerer       2012-03-14  814  
96d4f267e40f950 Linus Torvalds     2019-01-03  815  	if (!access_ok(frame, sizeof(*frame)))
0c22fafd312cd86 Greg Ungerer       2012-03-14  816  		goto badframe;
0c22fafd312cd86 Greg Ungerer       2012-03-14  817  	if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
0c22fafd312cd86 Greg Ungerer       2012-03-14  818  		goto badframe;
0c22fafd312cd86 Greg Ungerer       2012-03-14  819  
43a35995562495b Matt Fleming       2012-05-11  820  	set_current_blocked(&set);
0c22fafd312cd86 Greg Ungerer       2012-03-14  821  
0c22fafd312cd86 Greg Ungerer       2012-03-14  822  	if (rt_restore_ucontext(regs, sw, &frame->uc))
0c22fafd312cd86 Greg Ungerer       2012-03-14  823  		goto badframe;
0c22fafd312cd86 Greg Ungerer       2012-03-14  824  	return regs->d0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  825  
0c22fafd312cd86 Greg Ungerer       2012-03-14  826  badframe:
3cf5d076fb4d489 Eric W. Biederman  2019-05-23  827  	force_sig(SIGSEGV);
0c22fafd312cd86 Greg Ungerer       2012-03-14  828  	return 0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  829  }
0c22fafd312cd86 Greg Ungerer       2012-03-14  830  
0c22fafd312cd86 Greg Ungerer       2012-03-14  831  static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
0c22fafd312cd86 Greg Ungerer       2012-03-14  832  			     unsigned long mask)
0c22fafd312cd86 Greg Ungerer       2012-03-14  833  {
0c22fafd312cd86 Greg Ungerer       2012-03-14  834  	sc->sc_mask = mask;
0c22fafd312cd86 Greg Ungerer       2012-03-14  835  	sc->sc_usp = rdusp();
0c22fafd312cd86 Greg Ungerer       2012-03-14  836  	sc->sc_d0 = regs->d0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  837  	sc->sc_d1 = regs->d1;
0c22fafd312cd86 Greg Ungerer       2012-03-14  838  	sc->sc_a0 = regs->a0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  839  	sc->sc_a1 = regs->a1;
0c22fafd312cd86 Greg Ungerer       2012-03-14  840  	sc->sc_sr = regs->sr;
0c22fafd312cd86 Greg Ungerer       2012-03-14  841  	sc->sc_pc = regs->pc;
0c22fafd312cd86 Greg Ungerer       2012-03-14  842  	sc->sc_formatvec = regs->format << 12 | regs->vector;
0c22fafd312cd86 Greg Ungerer       2012-03-14  843  	save_a5_state(sc, regs);
0c22fafd312cd86 Greg Ungerer       2012-03-14  844  	save_fpu_state(sc, regs);
0c22fafd312cd86 Greg Ungerer       2012-03-14  845  }
0c22fafd312cd86 Greg Ungerer       2012-03-14  846  
0c22fafd312cd86 Greg Ungerer       2012-03-14  847  static inline int rt_setup_ucontext(struct ucontext __user *uc, struct pt_regs *regs)
0c22fafd312cd86 Greg Ungerer       2012-03-14  848  {
0c22fafd312cd86 Greg Ungerer       2012-03-14  849  	struct switch_stack *sw = (struct switch_stack *)regs - 1;
0c22fafd312cd86 Greg Ungerer       2012-03-14  850  	greg_t __user *gregs = uc->uc_mcontext.gregs;
0c22fafd312cd86 Greg Ungerer       2012-03-14  851  	int err = 0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  852  
0c22fafd312cd86 Greg Ungerer       2012-03-14  853  	err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);
0c22fafd312cd86 Greg Ungerer       2012-03-14  854  	err |= __put_user(regs->d0, &gregs[0]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  855  	err |= __put_user(regs->d1, &gregs[1]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  856  	err |= __put_user(regs->d2, &gregs[2]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  857  	err |= __put_user(regs->d3, &gregs[3]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  858  	err |= __put_user(regs->d4, &gregs[4]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  859  	err |= __put_user(regs->d5, &gregs[5]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  860  	err |= __put_user(sw->d6, &gregs[6]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  861  	err |= __put_user(sw->d7, &gregs[7]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  862  	err |= __put_user(regs->a0, &gregs[8]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  863  	err |= __put_user(regs->a1, &gregs[9]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  864  	err |= __put_user(regs->a2, &gregs[10]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  865  	err |= __put_user(sw->a3, &gregs[11]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  866  	err |= __put_user(sw->a4, &gregs[12]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  867  	err |= __put_user(sw->a5, &gregs[13]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  868  	err |= __put_user(sw->a6, &gregs[14]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  869  	err |= __put_user(rdusp(), &gregs[15]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  870  	err |= __put_user(regs->pc, &gregs[16]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  871  	err |= __put_user(regs->sr, &gregs[17]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  872  	err |= __put_user((regs->format << 12) | regs->vector, &uc->uc_formatvec);
0c22fafd312cd86 Greg Ungerer       2012-03-14  873  	err |= rt_save_fpu_state(uc, regs);
0c22fafd312cd86 Greg Ungerer       2012-03-14  874  	return err;
0c22fafd312cd86 Greg Ungerer       2012-03-14  875  }
0c22fafd312cd86 Greg Ungerer       2012-03-14  876  
0c22fafd312cd86 Greg Ungerer       2012-03-14  877  static inline void __user *
36992f2893d224a Richard Weinberger 2014-03-05  878  get_sigframe(struct ksignal *ksig, size_t frame_size)
0c22fafd312cd86 Greg Ungerer       2012-03-14  879  {
36992f2893d224a Richard Weinberger 2014-03-05  880  	unsigned long usp = sigsp(rdusp(), ksig);
0c22fafd312cd86 Greg Ungerer       2012-03-14  881  
0c22fafd312cd86 Greg Ungerer       2012-03-14  882  	return (void __user *)((usp - frame_size) & -8UL);
0c22fafd312cd86 Greg Ungerer       2012-03-14  883  }
0c22fafd312cd86 Greg Ungerer       2012-03-14  884  
0d97500d3930126 Richard Weinberger 2013-10-07  885  static int setup_frame(struct ksignal *ksig, sigset_t *set,
0d97500d3930126 Richard Weinberger 2013-10-07  886  			struct pt_regs *regs)
0c22fafd312cd86 Greg Ungerer       2012-03-14  887  {
0c22fafd312cd86 Greg Ungerer       2012-03-14  888  	struct sigframe __user *frame;
0c22fafd312cd86 Greg Ungerer       2012-03-14  889  	int fsize = frame_extra_sizes(regs->format);
0c22fafd312cd86 Greg Ungerer       2012-03-14  890  	struct sigcontext context;
0d97500d3930126 Richard Weinberger 2013-10-07  891  	int err = 0, sig = ksig->sig;
0c22fafd312cd86 Greg Ungerer       2012-03-14  892  
0c22fafd312cd86 Greg Ungerer       2012-03-14  893  	if (fsize < 0) {
7c79e1eef8c9a72 Geert Uytterhoeven 2016-12-06  894  		pr_debug("setup_frame: Unknown frame format %#x\n",
0c22fafd312cd86 Greg Ungerer       2012-03-14  895  			 regs->format);
0d97500d3930126 Richard Weinberger 2013-10-07  896  		return -EFAULT;
0c22fafd312cd86 Greg Ungerer       2012-03-14  897  	}
0c22fafd312cd86 Greg Ungerer       2012-03-14  898  
36992f2893d224a Richard Weinberger 2014-03-05  899  	frame = get_sigframe(ksig, sizeof(*frame) + fsize);
0c22fafd312cd86 Greg Ungerer       2012-03-14  900  
0c22fafd312cd86 Greg Ungerer       2012-03-14  901  	if (fsize)
0c22fafd312cd86 Greg Ungerer       2012-03-14  902  		err |= copy_to_user (frame + 1, regs + 1, fsize);
0c22fafd312cd86 Greg Ungerer       2012-03-14  903  
a0075cd1cb79971 Richard Weinberger 2014-07-13  904  	err |= __put_user(sig, &frame->sig);
0c22fafd312cd86 Greg Ungerer       2012-03-14  905  
0c22fafd312cd86 Greg Ungerer       2012-03-14  906  	err |= __put_user(regs->vector, &frame->code);
0c22fafd312cd86 Greg Ungerer       2012-03-14  907  	err |= __put_user(&frame->sc, &frame->psc);
0c22fafd312cd86 Greg Ungerer       2012-03-14  908  
0c22fafd312cd86 Greg Ungerer       2012-03-14  909  	if (_NSIG_WORDS > 1)
0c22fafd312cd86 Greg Ungerer       2012-03-14  910  		err |= copy_to_user(frame->extramask, &set->sig[1],
0c22fafd312cd86 Greg Ungerer       2012-03-14  911  				    sizeof(frame->extramask));
0c22fafd312cd86 Greg Ungerer       2012-03-14  912  
0c22fafd312cd86 Greg Ungerer       2012-03-14  913  	setup_sigcontext(&context, regs, set->sig[0]);
0c22fafd312cd86 Greg Ungerer       2012-03-14  914  	err |= copy_to_user (&frame->sc, &context, sizeof(context));
0c22fafd312cd86 Greg Ungerer       2012-03-14  915  
0c22fafd312cd86 Greg Ungerer       2012-03-14  916  	/* Set up to return from userspace.  */
0c22fafd312cd86 Greg Ungerer       2012-03-14  917  #ifdef CONFIG_MMU
0c22fafd312cd86 Greg Ungerer       2012-03-14  918  	err |= __put_user(frame->retcode, &frame->pretcode);
0c22fafd312cd86 Greg Ungerer       2012-03-14  919  	/* moveq #,d0; trap #0 */
0c22fafd312cd86 Greg Ungerer       2012-03-14  920  	err |= __put_user(0x70004e40 + (__NR_sigreturn << 16),
0c22fafd312cd86 Greg Ungerer       2012-03-14  921  			  (long __user *)(frame->retcode));
0c22fafd312cd86 Greg Ungerer       2012-03-14  922  #else
0c22fafd312cd86 Greg Ungerer       2012-03-14 @923  	err |= __put_user((void *) ret_from_user_signal, &frame->pretcode);
0c22fafd312cd86 Greg Ungerer       2012-03-14  924  #endif
0c22fafd312cd86 Greg Ungerer       2012-03-14  925  
0c22fafd312cd86 Greg Ungerer       2012-03-14  926  	if (err)
0d97500d3930126 Richard Weinberger 2013-10-07  927  		return -EFAULT;
0c22fafd312cd86 Greg Ungerer       2012-03-14  928  
0c22fafd312cd86 Greg Ungerer       2012-03-14  929  	push_cache ((unsigned long) &frame->retcode);
0c22fafd312cd86 Greg Ungerer       2012-03-14  930  
0c22fafd312cd86 Greg Ungerer       2012-03-14  931  	/*
0c22fafd312cd86 Greg Ungerer       2012-03-14  932  	 * Set up registers for signal handler.  All the state we are about
0c22fafd312cd86 Greg Ungerer       2012-03-14  933  	 * to destroy is successfully copied to sigframe.
0c22fafd312cd86 Greg Ungerer       2012-03-14  934  	 */
0c22fafd312cd86 Greg Ungerer       2012-03-14  935  	wrusp ((unsigned long) frame);
0d97500d3930126 Richard Weinberger 2013-10-07  936  	regs->pc = (unsigned long) ksig->ka.sa.sa_handler;
0c22fafd312cd86 Greg Ungerer       2012-03-14  937  	adjustformat(regs);
0c22fafd312cd86 Greg Ungerer       2012-03-14  938  
0c22fafd312cd86 Greg Ungerer       2012-03-14  939  	/*
0c22fafd312cd86 Greg Ungerer       2012-03-14  940  	 * This is subtle; if we build more than one sigframe, all but the
0c22fafd312cd86 Greg Ungerer       2012-03-14  941  	 * first one will see frame format 0 and have fsize == 0, so we won't
0c22fafd312cd86 Greg Ungerer       2012-03-14  942  	 * screw stkadj.
0c22fafd312cd86 Greg Ungerer       2012-03-14  943  	 */
0c22fafd312cd86 Greg Ungerer       2012-03-14  944  	if (fsize)
0c22fafd312cd86 Greg Ungerer       2012-03-14  945  		regs->stkadj = fsize;
0c22fafd312cd86 Greg Ungerer       2012-03-14  946  
0c22fafd312cd86 Greg Ungerer       2012-03-14  947  	/* Prepare to skip over the extra stuff in the exception frame.  */
0c22fafd312cd86 Greg Ungerer       2012-03-14  948  	if (regs->stkadj) {
0c22fafd312cd86 Greg Ungerer       2012-03-14  949  		struct pt_regs *tregs =
0c22fafd312cd86 Greg Ungerer       2012-03-14  950  			(struct pt_regs *)((ulong)regs + regs->stkadj);
7c79e1eef8c9a72 Geert Uytterhoeven 2016-12-06  951  		pr_debug("Performing stackadjust=%04lx\n", regs->stkadj);
0c22fafd312cd86 Greg Ungerer       2012-03-14  952  		/* This must be copied with decreasing addresses to
0c22fafd312cd86 Greg Ungerer       2012-03-14  953                     handle overlaps.  */
0c22fafd312cd86 Greg Ungerer       2012-03-14  954  		tregs->vector = 0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  955  		tregs->format = 0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  956  		tregs->pc = regs->pc;
0c22fafd312cd86 Greg Ungerer       2012-03-14  957  		tregs->sr = regs->sr;
0c22fafd312cd86 Greg Ungerer       2012-03-14  958  	}
0c22fafd312cd86 Greg Ungerer       2012-03-14  959  	return 0;
0c22fafd312cd86 Greg Ungerer       2012-03-14  960  }
0c22fafd312cd86 Greg Ungerer       2012-03-14  961  

:::::: The code at line 923 was first introduced by commit
:::::: 0c22fafd312cd8658ca23f6067a20aec0781c02a m68k: merge the MMU and non-MMU signal.c code

:::::: TO: Greg Ungerer <gerg@xxxxxxxxxxx>
:::::: CC: Greg Ungerer <gerg@xxxxxxxxxxx>

---
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]     [Video for Linux]     [Yosemite News]     [Linux S/390]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux