All of lore.kernel.org
 help / color / mirror / Atom feed
* [mkl-can-next:testing 8/17] net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.
@ 2020-10-07  9:23 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-10-07  9:23 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: kbuild-all, linux-can, Marc Kleine-Budde

[-- Attachment #1: Type: text/plain, Size: 3105 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
head:   6a89c9390e62e16ede591ae920b38e276207f1a4
commit: 99b153b74559d9e3a6456ea5f0eaae03c8dcad79 [8/17] can: add ISO 15765-2:2016 transport protocol
config: x86_64-randconfig-m001-20201005 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.

vim +/optlen +1159 net/can/isotp.c

  1149	
  1150	static int isotp_setsockopt(struct socket *sock, int level, int optname,
  1151				    sockptr_t optval, unsigned int optlen)
  1152	{
  1153		struct sock *sk = sock->sk;
  1154		struct isotp_sock *so = isotp_sk(sk);
  1155		int ret = 0;
  1156	
  1157		if (level != SOL_CAN_ISOTP)
  1158			return -EINVAL;
> 1159		if (optlen < 0)
  1160			return -EINVAL;
  1161	
  1162		switch (optname) {
  1163		case CAN_ISOTP_OPTS:
  1164			if (optlen != sizeof(struct can_isotp_options))
  1165				return -EINVAL;
  1166	
  1167			if (copy_from_sockptr(&so->opt, optval, optlen))
  1168				return -EFAULT;
  1169	
  1170			/* no separate rx_ext_address is given => use ext_address */
  1171			if (!(so->opt.flags & CAN_ISOTP_RX_EXT_ADDR))
  1172				so->opt.rx_ext_address = so->opt.ext_address;
  1173			break;
  1174	
  1175		case CAN_ISOTP_RECV_FC:
  1176			if (optlen != sizeof(struct can_isotp_fc_options))
  1177				return -EINVAL;
  1178	
  1179			if (copy_from_sockptr(&so->rxfc, optval, optlen))
  1180				return -EFAULT;
  1181			break;
  1182	
  1183		case CAN_ISOTP_TX_STMIN:
  1184			if (optlen != sizeof(__u32))
  1185				return -EINVAL;
  1186	
  1187			if (copy_from_sockptr(&so->force_tx_stmin, optval, optlen))
  1188				return -EFAULT;
  1189			break;
  1190	
  1191		case CAN_ISOTP_RX_STMIN:
  1192			if (optlen != sizeof(__u32))
  1193				return -EINVAL;
  1194	
  1195			if (copy_from_sockptr(&so->force_rx_stmin, optval, optlen))
  1196				return -EFAULT;
  1197			break;
  1198	
  1199		case CAN_ISOTP_LL_OPTS:
  1200			if (optlen == sizeof(struct can_isotp_ll_options)) {
  1201				struct can_isotp_ll_options ll;
  1202	
  1203				if (copy_from_sockptr(&ll, optval, optlen))
  1204					return -EFAULT;
  1205	
  1206				/* check for correct ISO 11898-1 DLC data length */
  1207				if (ll.tx_dl != padlen(ll.tx_dl))
  1208					return -EINVAL;
  1209	
  1210				if (ll.mtu != CAN_MTU && ll.mtu != CANFD_MTU)
  1211					return -EINVAL;
  1212	
  1213				if (ll.mtu == CAN_MTU && ll.tx_dl > CAN_MAX_DLEN)
  1214					return -EINVAL;
  1215	
  1216				memcpy(&so->ll, &ll, sizeof(ll));
  1217	
  1218				/* set ll_dl for tx path to similar place as for rx */
  1219				so->tx.ll_dl = ll.tx_dl;
  1220			} else {
  1221				return -EINVAL;
  1222			}
  1223			break;
  1224	
  1225		default:
  1226			ret = -ENOPROTOOPT;
  1227		}
  1228	
  1229		return ret;
  1230	}
  1231	

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37429 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [mkl-can-next:testing 8/17] net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.
@ 2020-10-07  9:23 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-10-07  9:23 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3208 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
head:   6a89c9390e62e16ede591ae920b38e276207f1a4
commit: 99b153b74559d9e3a6456ea5f0eaae03c8dcad79 [8/17] can: add ISO 15765-2:2016 transport protocol
config: x86_64-randconfig-m001-20201005 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.

vim +/optlen +1159 net/can/isotp.c

  1149	
  1150	static int isotp_setsockopt(struct socket *sock, int level, int optname,
  1151				    sockptr_t optval, unsigned int optlen)
  1152	{
  1153		struct sock *sk = sock->sk;
  1154		struct isotp_sock *so = isotp_sk(sk);
  1155		int ret = 0;
  1156	
  1157		if (level != SOL_CAN_ISOTP)
  1158			return -EINVAL;
> 1159		if (optlen < 0)
  1160			return -EINVAL;
  1161	
  1162		switch (optname) {
  1163		case CAN_ISOTP_OPTS:
  1164			if (optlen != sizeof(struct can_isotp_options))
  1165				return -EINVAL;
  1166	
  1167			if (copy_from_sockptr(&so->opt, optval, optlen))
  1168				return -EFAULT;
  1169	
  1170			/* no separate rx_ext_address is given => use ext_address */
  1171			if (!(so->opt.flags & CAN_ISOTP_RX_EXT_ADDR))
  1172				so->opt.rx_ext_address = so->opt.ext_address;
  1173			break;
  1174	
  1175		case CAN_ISOTP_RECV_FC:
  1176			if (optlen != sizeof(struct can_isotp_fc_options))
  1177				return -EINVAL;
  1178	
  1179			if (copy_from_sockptr(&so->rxfc, optval, optlen))
  1180				return -EFAULT;
  1181			break;
  1182	
  1183		case CAN_ISOTP_TX_STMIN:
  1184			if (optlen != sizeof(__u32))
  1185				return -EINVAL;
  1186	
  1187			if (copy_from_sockptr(&so->force_tx_stmin, optval, optlen))
  1188				return -EFAULT;
  1189			break;
  1190	
  1191		case CAN_ISOTP_RX_STMIN:
  1192			if (optlen != sizeof(__u32))
  1193				return -EINVAL;
  1194	
  1195			if (copy_from_sockptr(&so->force_rx_stmin, optval, optlen))
  1196				return -EFAULT;
  1197			break;
  1198	
  1199		case CAN_ISOTP_LL_OPTS:
  1200			if (optlen == sizeof(struct can_isotp_ll_options)) {
  1201				struct can_isotp_ll_options ll;
  1202	
  1203				if (copy_from_sockptr(&ll, optval, optlen))
  1204					return -EFAULT;
  1205	
  1206				/* check for correct ISO 11898-1 DLC data length */
  1207				if (ll.tx_dl != padlen(ll.tx_dl))
  1208					return -EINVAL;
  1209	
  1210				if (ll.mtu != CAN_MTU && ll.mtu != CANFD_MTU)
  1211					return -EINVAL;
  1212	
  1213				if (ll.mtu == CAN_MTU && ll.tx_dl > CAN_MAX_DLEN)
  1214					return -EINVAL;
  1215	
  1216				memcpy(&so->ll, &ll, sizeof(ll));
  1217	
  1218				/* set ll_dl for tx path to similar place as for rx */
  1219				so->tx.ll_dl = ll.tx_dl;
  1220			} else {
  1221				return -EINVAL;
  1222			}
  1223			break;
  1224	
  1225		default:
  1226			ret = -ENOPROTOOPT;
  1227		}
  1228	
  1229		return ret;
  1230	}
  1231	

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37429 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [mkl-can-next:testing 8/17] net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.
  2020-10-07  9:23 ` kernel test robot
@ 2020-10-07  9:31   ` Marc Kleine-Budde
  -1 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2020-10-07  9:31 UTC (permalink / raw)
  To: kernel test robot, Oliver Hartkopp; +Cc: kbuild-all, linux-can


[-- Attachment #1.1: Type: text/plain, Size: 1400 bytes --]

On 10/7/20 11:23 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
> head:   6a89c9390e62e16ede591ae920b38e276207f1a4
> commit: 99b153b74559d9e3a6456ea5f0eaae03c8dcad79 [8/17] can: add ISO 15765-2:2016 transport protocol
> config: x86_64-randconfig-m001-20201005 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> smatch warnings:
> net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.
> 
> vim +/optlen +1159 net/can/isotp.c
> 
>   1149	
>   1150	static int isotp_setsockopt(struct socket *sock, int level, int optname,
>   1151				    sockptr_t optval, unsigned int optlen)
>   1152	{
>   1153		struct sock *sk = sock->sk;
>   1154		struct isotp_sock *so = isotp_sk(sk);
>   1155		int ret = 0;
>   1156	
>   1157		if (level != SOL_CAN_ISOTP)
>   1158			return -EINVAL;
>> 1159		if (optlen < 0)
>   1160			return -EINVAL;

I'll just delete that line.

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [mkl-can-next:testing 8/17] net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.
@ 2020-10-07  9:31   ` Marc Kleine-Budde
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2020-10-07  9:31 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]

On 10/7/20 11:23 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
> head:   6a89c9390e62e16ede591ae920b38e276207f1a4
> commit: 99b153b74559d9e3a6456ea5f0eaae03c8dcad79 [8/17] can: add ISO 15765-2:2016 transport protocol
> config: x86_64-randconfig-m001-20201005 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> smatch warnings:
> net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero.
> 
> vim +/optlen +1159 net/can/isotp.c
> 
>   1149	
>   1150	static int isotp_setsockopt(struct socket *sock, int level, int optname,
>   1151				    sockptr_t optval, unsigned int optlen)
>   1152	{
>   1153		struct sock *sk = sock->sk;
>   1154		struct isotp_sock *so = isotp_sk(sk);
>   1155		int ret = 0;
>   1156	
>   1157		if (level != SOL_CAN_ISOTP)
>   1158			return -EINVAL;
>> 1159		if (optlen < 0)
>   1160			return -EINVAL;

I'll just delete that line.

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-07  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07  9:23 [mkl-can-next:testing 8/17] net/can/isotp.c:1159 isotp_setsockopt() warn: unsigned 'optlen' is never less than zero kernel test robot
2020-10-07  9:23 ` kernel test robot
2020-10-07  9:31 ` Marc Kleine-Budde
2020-10-07  9:31   ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.