Unverified Commit 3b44b815 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!8258 v5 can: dev: can_put_echo_skb(): don't crash kernel if...

!8258 v5  can: dev: can_put_echo_skb(): don't crash kernel if can_priv::echo_skb is accessed out of bounds

Merge Pull Request from: @ci-robot 
 
PR sync from: Yipeng Zou <zouyipeng@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/4WYIGSSFZWL7UNROLK6TB7OH7KSBA363/ 
 
https://gitee.com/src-openeuler/kernel/issues/I9REA2 
 
Link:https://gitee.com/openeuler/kernel/pulls/8258

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 5e64f2c7 c684e2ca
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -462,7 +462,11 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
{
	struct can_priv *priv = netdev_priv(dev);

	BUG_ON(idx >= priv->echo_skb_max);
	if (idx >= priv->echo_skb_max) {
		netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n",
			   __func__, idx, priv->echo_skb_max);
		return -EINVAL;
	}

	/* check flag whether this packet has to be looped back */
	if (!(dev->flags & IFF_ECHO) || skb->pkt_type != PACKET_LOOPBACK ||