linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Joe Ghalam <Joe.Ghalam@dell.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.9 31/54] macvlan: Fix device ref leak when purging bc_queue
Date: Mon,  1 May 2017 14:31:38 -0700	[thread overview]
Message-ID: <20170501212632.997105182@linuxfoundation.org> (raw)
In-Reply-To: <20170501212631.798128131@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Herbert Xu <herbert@gondor.apana.org.au>


[ 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 <Joe.Ghalam@dell.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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);
 }

  parent reply	other threads:[~2017-05-01 21:53 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-01 21:31 [PATCH 4.9 00/54] 4.9.26-stable review Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 01/54] [PATCH] Revert "mmc: sdhci-msm: Enable few quirks" Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 02/54] ping: implement proper locking Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 03/54] sparc64: kern_addr_valid regression Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 04/54] sparc64: Fix kernel panic due to erroneous #ifdef surrounding pmd_write() Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 05/54] net: neigh: guard against NULL solicit() method Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 06/54] net: phy: handle state correctly in phy_stop_machine Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 07/54] kcm: return immediately after copy_from_user() failure Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 08/54] bpf: improve verifier packet range checks Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 09/54] net/mlx5: Avoid dereferencing uninitialized pointer Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 10/54] l2tp: hold tunnel socket when handling control frames in l2tp_ip and l2tp_ip6 Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 11/54] l2tp: purge socket queues in the .destruct() callback Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 12/54] net/packet: fix overflow in check for tp_frame_nr Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 13/54] net/packet: fix overflow in check for tp_reserve Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 14/54] l2tp: take reference on sessions being dumped Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 15/54] l2tp: fix PPP pseudo-wire auto-loading Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 16/54] net: ipv4: fix multipath RTM_GETROUTE behavior when iif is given Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 17/54] sctp: listen on the sock only when its state is listening or closed Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 18/54] tcp: clear saved_syn in tcp_disconnect() Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 19/54] ipv6: Fix idev->addr_list corruption Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 20/54] net-timestamp: avoid use-after-free in ip_recv_error Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 21/54] net: vrf: Fix setting NLM_F_EXCL flag when adding l3mdev rule Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 22/54] sh_eth: unmap DMA buffers when freeing rings Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 24/54] gso: Validate assumption of frag_list segementation Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 25/54] net: ipv6: RTF_PCPU should not be settable from userspace Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 26/54] netpoll: Check for skb->queue_mapping Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 27/54] ip6mr: fix notification device destruction Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 28/54] net/mlx5: Fix driver load bad flow when having fw initializing timeout Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 29/54] net/mlx5e: Fix small packet threshold Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 30/54] net/mlx5e: Fix ETHTOOL_GRXCLSRLALL handling Greg Kroah-Hartman
2017-05-01 21:31 ` Greg Kroah-Hartman [this message]
2017-05-01 21:31 ` [PATCH 4.9 32/54] net: ipv6: regenerate host route if moved to gc list Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 33/54] net: phy: fix auto-negotiation stall due to unavailable interrupt Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 34/54] ipv6: check skb->protocol before lookup for nexthop Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 35/54] tcp: memset ca_priv data to 0 properly Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 36/54] ipv6: check raw payload size correctly in ioctl Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 37/54] ALSA: oxfw: fix regression to handle Stanton SCS.1m/1d Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 38/54] ALSA: firewire-lib: fix inappropriate assignment between signed/unsigned type Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 39/54] ALSA: seq: Dont break snd_use_lock_sync() loop by timeout Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 40/54] ARC: [plat-eznps] Fix build error Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 41/54] MIPS: KGDB: Use kernel context for sleeping threads Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 42/54] MIPS: cevt-r4k: Fix out-of-bounds array access Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 43/54] MIPS: Avoid BUG warning in arch_check_elf Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 44/54] p9_client_readdir() fix Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 45/54] ASoC: intel: Fix PM and non-atomic crash in bytcr drivers Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 48/54] nfsd4: minor NFSv2/v3 write decoding cleanup Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 50/54] ceph: fix recursion between ceph_set_acl() and __ceph_setattr() Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 51/54] macsec: avoid heap overflow in skb_to_sgvec Greg Kroah-Hartman
2017-05-01 21:31 ` [PATCH 4.9 52/54] net: can: usb: gs_usb: Fix buffer on stack Greg Kroah-Hartman
2017-05-01 21:32 ` [PATCH 4.9 53/54] ARCv2: save r30 on kernel entry as gcc uses it for code-gen Greg Kroah-Hartman
2017-05-01 21:32 ` [PATCH 4.9 54/54] ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram Greg Kroah-Hartman
     [not found] ` <590808bb.a121ed0a.b040f.045c@mx.google.com>
2017-05-02 13:53   ` [PATCH 4.9 00/54] 4.9.26-stable review Shuah Khan
2017-05-02 17:36 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170501212632.997105182@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Joe.Ghalam@dell.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).