Patch "packet: missing dev_put() in packet_do_bind()" has been added to the 3.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
packet: missing dev_put() in packet_do_bind()
to the 3.14-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:
packet-missing-dev_put-in-packet_do_bind.patch
and it can be found in the queue-3.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Sat Sep 26 11:19:08 PDT 2015
From: Lars Westerhoff <[email protected]>
Date: Tue, 28 Jul 2015 01:32:21 +0300
Subject: packet: missing dev_put() in packet_do_bind()
From: Lars Westerhoff <[email protected]>
[ Upstream commit 158cd4af8dedbda0d612d448c724c715d0dda649 ]
When binding a PF_PACKET socket, the use count of the bound interface is always increased with dev_hold in dev_get_by_{index,name}. However, when rebound with the same protocol and device as in the previous bind the use count of the interface was not decreased. Ultimately, this caused the deletion of the interface to fail with the following message:
unregister_netdevice: waiting for dummy0 to become free. Usage count = 1
This patch moves the dev_put out of the conditional part that was only executed when either the protocol or device changed on a bind.
--- net/packet/af_packet.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/packet/af_packet.c +3 -5
@@ -2645,7 +2645,7 @@ static int packet_release(struct socketstatic int packet_do_bind (struct sock *sk,struct net_device *dev,__be16 proto) {struct packet_sock *po =pkt_sk (sk); -const struct net_device *dev_curr; +struct net_device *dev_curr;__be16 proto_curr;bool need_rehook;
@@ -2669,15 +2669,13 @@ static int packet_do_bind(struct sock *s po->num = proto; po->prot_hook.type = proto; - -if (po->prot_hook.dev) -dev_put (po->prot_hook.dev); - po->prot_hook.dev = dev; po->ifindex = dev ? dev->ifindex :0 ;packet_cached_dev_assign (po, dev); } +if (dev_curr) +dev_put (dev_curr);if (proto ==0 || !need_rehook) goto out_unlock;
Patches currently in stable-queue which might be from [email protected] are
queue-3.14/packet-missing-dev_put-in-packet_do_bind.patch