diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2019-07-22 20:41:22 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-07-28 08:28:34 +0200 |
commit | 1cec7a0cf072a8b0039abaa88c73256f6d82bf4e (patch) | |
tree | 889531ed4fdc955673ed2221e275bc18e4dd44ce | |
parent | 897bcee6a1292b2a5d4e731ec5f12c6b97309465 (diff) | |
download | linux-stable-1cec7a0cf072a8b0039abaa88c73256f6d82bf4e.tar.gz linux-stable-1cec7a0cf072a8b0039abaa88c73256f6d82bf4e.tar.bz2 linux-stable-1cec7a0cf072a8b0039abaa88c73256f6d82bf4e.zip |
netrom: hold sock when setting skb->destructor
[ Upstream commit 4638faac032756f7eab5524be7be56bee77e426b ]
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: <syzbot+622bdabb128acc33427d@syzkaller.appspotmail.com>
Reported-and-tested-by: <syzbot+6eaef7158b19e3fec3a0@syzkaller.appspotmail.com>
Reported-and-tested-by: <syzbot+9399c158fcc09b21d0d2@syzkaller.appspotmail.com>
Reported-and-tested-by: <syzbot+a34e5f3d0300163f0c87@syzkaller.appspotmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/netrom/af_netrom.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index f11b6747e18c..43910e50752c 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -970,6 +970,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; |