* [PATCH] net:tipc: Fix a double free in tipc_sk_mcast_rcv
@ 2021-03-28 7:30 Lv Yunlong
2021-03-29 23:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Lv Yunlong @ 2021-03-28 7:30 UTC (permalink / raw)
To: jmaloy, ying.xue, davem, kuba
Cc: netdev, tipc-discussion, linux-kernel, Lv Yunlong
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>
---
net/tipc/socket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index cebcc104dc70..022999e0202d 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1265,7 +1265,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,
spin_lock_bh(&inputq->lock);
if (skb_peek(arrvq) == skb) {
skb_queue_splice_tail_init(&tmpq, inputq);
- kfree_skb(__skb_dequeue(arrvq));
+ __skb_dequeue(arrvq);
}
spin_unlock_bh(&inputq->lock);
__skb_queue_purge(&tmpq);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net:tipc: Fix a double free in tipc_sk_mcast_rcv
2021-03-28 7:30 [PATCH] net:tipc: Fix a double free in tipc_sk_mcast_rcv Lv Yunlong
@ 2021-03-29 23:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-29 23:30 UTC (permalink / raw)
To: Lv Yunlong
Cc: jmaloy, ying.xue, davem, kuba, netdev, tipc-discussion, linux-kernel
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Sun, 28 Mar 2021 00:30:29 -0700 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- net:tipc: Fix a double free in tipc_sk_mcast_rcv
https://git.kernel.org/netdev/net/c/6bf24dc0cc0c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-29 23:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-28 7:30 [PATCH] net:tipc: Fix a double free in tipc_sk_mcast_rcv Lv Yunlong
2021-03-29 23:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).