netrom: hold sock when setting skb->destructor
Subsystems (2)
PATCH 1/1 netrom: hold sock when setting skb->destructor
sock_efree() releases the sock refcnt, if we don't hold this refcnt when setting skb->destructor to it, the refcnt would not be balanced. This leads to several bug reports from syzbot.
I have checked other users of sock_efree(), all of them hold the sock refcnt.
Fixes c8c8218ec5af ("netrom: fix a memory leak in nr_rx_frame()")
Reported-and-tested-by <[email protected]>
Reported-and-tested-by <[email protected]>
Reported-and-tested-by <[email protected]>
Reported-and-tested-by <[email protected]>
Cc Ralf Baechle <[email protected]>
Signed-off-by Cong Wang <[email protected]>
--- net/netrom/af_netrom.c | 1 + 1 file changed, 1 insertion(+)
net/netrom/af_netrom.c +1 -0
@@ -967,6 +967,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev) window = skb->data[20 ]; +sock_hold (make); skb->sk = make; skb->destructor = sock_efree; make->sk_state =TCP_ESTABLISHED ;
Signature · 1 line
2.21.0
David Miller
maintainerFrom: Cong Wang <[email protected]>
Date: Mon, 22 Jul 2019 20:41:22 -0700
Quoted 7 lines
sock_efree()releases the sock refcnt, if we don't hold this refcnt when settingskb->destructorto it, the refcnt would not be balanced. This leads to several bug reports from syzbot.I have checked other users of
sock_efree(), all of them hold the sock refcnt.
Quoted 7 lines
Fixes c8c8218ec5af ("netrom: fix a memory leak in nr_rx_frame()")Reported-and-tested-by <[email protected]>Reported-and-tested-by <[email protected]>Reported-and-tested-by <[email protected]>Reported-and-tested-by <[email protected]>Cc Ralf Baechle <[email protected]>Signed-off-by Cong Wang <[email protected]>
Applied and queued up for -stable.