]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
netrom: fix a memory leak in nr_rx_frame()
authorCong Wang <xiyou.wangcong@gmail.com>
Thu, 27 Jun 2019 21:30:58 +0000 (14:30 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1839036
[ Upstream commit c8c8218ec5af5d2598381883acbefbf604e56b5e ]

When the skb is associated with a new sock, just assigning
it to skb->sk is not sufficient, we have to set its destructor
to free the sock properly too.

Reported-by: syzbot+d6636a36d3c34bd88938@syzkaller.appspotmail.com
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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/netrom/af_netrom.c

index 85bb2296b545e943a19f2353efeb14c634ba5b64..79536a6e01b909f56c716034a8f1ee21a58120d2 100644 (file)
@@ -871,7 +871,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
        unsigned short frametype, flags, window, timeout;
        int ret;
 
-       skb->sk = NULL;         /* Initially we don't know who it's for */
+       skb_orphan(skb);
 
        /*
         *      skb->data points to the netrom frame start
@@ -970,6 +970,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
        window = skb->data[20];
 
        skb->sk             = make;
+       skb->destructor     = sock_efree;
        make->sk_state      = TCP_ESTABLISHED;
 
        /* Fill in his circuit details */