Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d40ff07a authored by Zheng Yongjun's avatar Zheng Yongjun Committed by Sasha Levin
Browse files

ping: Check return value of function 'ping_queue_rcv_skb'



[ Upstream commit 9d44fa3e50cc91691896934d106c86e4027e61ca ]

Function 'ping_queue_rcv_skb' not always return success, which will
also return fail. If not check the wrong return value of it, lead to function
`ping_rcv` return success.

Signed-off-by: default avatarZheng Yongjun <zhengyongjun3@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9df4f031
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -963,6 +963,7 @@ bool ping_rcv(struct sk_buff *skb)
	struct sock *sk;
	struct net *net = dev_net(skb->dev);
	struct icmphdr *icmph = icmp_hdr(skb);
	bool rc = false;

	/* We assume the packet has already been checked by icmp_rcv */

@@ -977,14 +978,15 @@ bool ping_rcv(struct sk_buff *skb)
		struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);

		pr_debug("rcv on socket %p\n", sk);
		if (skb2)
			ping_queue_rcv_skb(sk, skb2);
		if (skb2 && !ping_queue_rcv_skb(sk, skb2))
			rc = true;
		sock_put(sk);
		return true;
	}

	if (!rc)
		pr_debug("no socket, dropping\n");

	return false;
	return rc;
}
EXPORT_SYMBOL_GPL(ping_rcv);