]> git.itanic.dy.fi Git - linux-stable/commit
net:tipc: Fix a double free in tipc_sk_mcast_rcv
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Sun, 28 Mar 2021 07:30:29 +0000 (00:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Apr 2021 09:59:08 +0000 (11:59 +0200)
commitd0d49f2c1b904a1d3134f55fcc73abe1ce573be0
treefc43b0bd7737012cc137779036aeba6b4563e8a4
parent6157a79cdc089e9b4a0d819cd3070bef9b5cf1e2
net:tipc: Fix a double free in tipc_sk_mcast_rcv

[ Upstream commit 6bf24dc0cc0cc43b29ba344b66d78590e687e046 ]

In the if(skb_peek(arrvq) == skb) branch, it calls __skb_dequeue(arrvq) to get
the skb by skb = skb_peek(arrvq). Then __skb_dequeue() unlinks the skb from arrvq
and returns the skb which equals to skb_peek(arrvq). After __skb_dequeue(arrvq)
finished, the skb is freed by kfree_skb(__skb_dequeue(arrvq)) in the first time.

Unfortunately, the same skb is freed in the second time by kfree_skb(skb) after
the branch completed.

My patch removes kfree_skb() in the if(skb_peek(arrvq) == skb) branch, because
this skb will be freed by kfree_skb(skb) finally.

Fixes: cb1b728096f54 ("tipc: eliminate race condition at multicast reception")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/tipc/socket.c