Re: net/can/isotp.c:1240:13: sparse: sparse: incorrect type in initializer (different address spaces)
From: Marc Kleine-Budde
Date: Mon Jan 04 2021 - 04:12:53 EST
On 12/26/20 8:29 PM, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: f838f8d2b694cf9d524dc4423e9dd2db13892f3f
> commit: e057dd3fc20ffb3d7f150af46542a51b59b90127 can: add ISO 15765-2:2016 transport protocol
> date: 3 months ago
> config: sh-randconfig-s032-20201225 (attached as .config)
> compiler: sh4-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.3-184-g1b896707-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e057dd3fc20ffb3d7f150af46542a51b59b90127
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout e057dd3fc20ffb3d7f150af46542a51b59b90127
> # 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=sh
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
>
> "sparse warnings: (new ones prefixed by >>)"
>>> net/can/isotp.c:1240:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *optlen @@
> net/can/isotp.c:1240:13: sparse: expected int const *__gu_addr
> net/can/isotp.c:1240:13: sparse: got int [noderef] __user *optlen
>>> net/can/isotp.c:1240:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
> net/can/isotp.c:1240:13: sparse: expected void const volatile [noderef] __user *ptr
> net/can/isotp.c:1240:13: sparse: got int const *__gu_addr
From my point of view, it looks like the get_user() on the sh platform is
somehow different to the other platform, which all accept a __user pointer. IMHO
this should be fixed in sh.
> vim +1240 net/can/isotp.c
>
> 1229
> 1230 static int isotp_getsockopt(struct socket *sock, int level, int optname,
> 1231 char __user *optval, int __user *optlen)
> 1232 {
> 1233 struct sock *sk = sock->sk;
> 1234 struct isotp_sock *so = isotp_sk(sk);
> 1235 int len;
> 1236 void *val;
> 1237
> 1238 if (level != SOL_CAN_ISOTP)
> 1239 return -EINVAL;
>> 1240 if (get_user(len, optlen))
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Attachment:
signature.asc
Description: OpenPGP digital signature