From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:40148 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030566AbdD2G0P (ORCPT ); Sat, 29 Apr 2017 02:26:15 -0400 Subject: Patch "macvlan: Fix device ref leak when purging bc_queue" has been added to the 4.9-stable tree To: herbert@gondor.apana.org.au, Joe.Ghalam@dell.com, davem@davemloft.net, gregkh@linuxfoundation.org Cc: , From: Date: Sat, 29 Apr 2017 08:24:03 +0200 Message-ID: <1493447043171115@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled macvlan: Fix device ref leak when purging bc_queue to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: macvlan-fix-device-ref-leak-when-purging-bc_queue.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From foo@baz Sat Apr 29 08:22:13 CEST 2017 From: Herbert Xu Date: Thu, 20 Apr 2017 20:55:12 +0800 Subject: macvlan: Fix device ref leak when purging bc_queue From: Herbert Xu [ Upstream commit f6478218e6edc2a587b8f132f66373baa7b2497c ] When a parent macvlan device is destroyed we end up purging its broadcast queue without dropping the device reference count on the packet source device. This causes the source device to linger. This patch drops that reference count. Fixes: 260916dfb48c ("macvlan: Fix potential use-after free for...") Reported-by: Joe Ghalam Signed-off-by: Herbert Xu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/macvlan.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1140,6 +1140,7 @@ static int macvlan_port_create(struct ne static void macvlan_port_destroy(struct net_device *dev) { struct macvlan_port *port = macvlan_port_get_rtnl(dev); + struct sk_buff *skb; dev->priv_flags &= ~IFF_MACVLAN_PORT; netdev_rx_handler_unregister(dev); @@ -1148,7 +1149,15 @@ static void macvlan_port_destroy(struct * but we need to cancel it and purge left skbs if any. */ cancel_work_sync(&port->bc_work); - __skb_queue_purge(&port->bc_queue); + + while ((skb = __skb_dequeue(&port->bc_queue))) { + const struct macvlan_dev *src = MACVLAN_SKB_CB(skb)->src; + + if (src) + dev_put(src->dev); + + kfree_skb(skb); + } kfree_rcu(port, rcu); } Patches currently in stable-queue which might be from herbert@gondor.apana.org.au are queue-4.9/macvlan-fix-device-ref-leak-when-purging-bc_queue.patch