From: Eric Dumazet <eric.dumazet@gmail.com>
To: Maxim Levitsky <maximlevitsky@gmail.com>,
David Miller <davem@davemloft.net>
Cc: linux1394-devel <linux1394-devel@lists.sourceforge.net>,
Stefan Richter <stefanr@s5r6.in-berlin.de>,
netdev@vger.kernel.org, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
James Morris <jmorris@namei.org>,
Patrick McHardy <kaber@trash.net>,
Octavian Purdila <opurdila@ixiacom.com>,
stable@kernel.org
Subject: [PATCH net-2.6] llc: fix a device refcount imbalance
Date: Sun, 05 Dec 2010 13:03:26 +0100 [thread overview]
Message-ID: <1291550606.2806.237.camel@edumazet-laptop> (raw)
In-Reply-To: <1291548233.2806.212.camel@edumazet-laptop>
Le dimanche 05 décembre 2010 à 12:23 +0100, Eric Dumazet a écrit :
> Le dimanche 05 décembre 2010 à 09:19 +0100, Eric Dumazet a écrit :
>
> > Hmm..
> >
> > If somebody can explain why RTNL is held in arp_ioctl() (and therefore
> > in arp_req_delete()), we might first remove RTNL use in arp_ioctl() so
> > that your patch can be applied.
> >
> > Right now it is not good, because RTNL wont be necessarly held when you
> > are going to call arp_invalidate() ?
>
> While doing this analysis, I found a refcount bug in llc, I'll send a
> patch for net-2.6
Oh well, of course I must first fix the bug in net-2.6, and wait David
pull the fix in net-next-2.6 before sending this rcu conversion.
Note: this patch should be sent to stable teams (2.6.34 and up)
[PATCH net-2.6] llc: fix a device refcount imbalance
commit abf9d537fea225 (llc: add support for SO_BINDTODEVICE) added one
refcount imbalance in llc_ui_bind(), because dev_getbyhwaddr() doesnt
take a reference on device, while dev_get_by_index() does.
Fix this using RCU locking. And since an RCU conversion will be done for
2.6.38 for dev_getbyhwaddr(), put the rcu_read_lock/unlock exactly at
their final place.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: stable@kernel.org
Cc: Octavian Purdila <opurdila@ixiacom.com>
---
net/llc/af_llc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 5826129..e35dbe5 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -317,8 +317,9 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
goto out;
rc = -ENODEV;
rtnl_lock();
+ rcu_read_lock();
if (sk->sk_bound_dev_if) {
- llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
+ llc->dev = dev_get_by_index_rcu(&init_net, sk->sk_bound_dev_if);
if (llc->dev) {
if (!addr->sllc_arphrd)
addr->sllc_arphrd = llc->dev->type;
@@ -329,13 +330,13 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
!llc_mac_match(addr->sllc_mac,
llc->dev->dev_addr)) {
rc = -EINVAL;
- dev_put(llc->dev);
llc->dev = NULL;
}
}
} else
llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd,
addr->sllc_mac);
+ rcu_read_unlock();
rtnl_unlock();
if (!llc->dev)
goto out;
next prev parent reply other threads:[~2010-12-05 12:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-29 2:09 [PATCH 0/5 V2] Firewire networking assorted fixes Maxim Levitsky
2010-11-29 2:09 ` [PATCH 1/5] firewire: ohci: restore GUID on resume Maxim Levitsky
2010-11-29 2:09 ` [PATCH 2/5] firewire: ohci: restart ISO DMA contexts on resume from low power mode Maxim Levitsky
2010-11-29 2:09 ` [PATCH 3/5] NET: IPV4: ARP: allow to invalidate specific ARP entries Maxim Levitsky
2010-12-04 23:15 ` Maxim Levitsky
2010-12-05 8:19 ` Eric Dumazet
2010-12-05 11:23 ` [PATCH] net: RCU conversion of dev_getbyhwaddr() and arp_ioctl() Eric Dumazet
2010-12-05 12:03 ` Eric Dumazet [this message]
2010-12-08 17:59 ` [PATCH net-2.6] llc: fix a device refcount imbalance David Miller
2010-12-09 3:46 ` Maxim Levitsky
2010-12-16 21:49 ` Maxim Levitsky
2010-12-08 18:05 ` [PATCH] net: RCU conversion of dev_getbyhwaddr() and arp_ioctl() David Miller
2010-12-08 18:07 ` Eric Dumazet
2010-12-08 18:10 ` David Miller
2010-12-08 18:11 ` Eric Dumazet
2011-01-07 12:47 ` [PATCH 3/5] NET: IPV4: ARP: allow to invalidate specific ARP entries Maxim Levitsky
2011-01-07 12:57 ` Eric Dumazet
2011-01-07 13:15 ` Maxim Levitsky
2011-01-08 23:57 ` Maxim Levitsky
2011-01-11 0:11 ` David Miller
2010-11-29 2:09 ` [PATCH 4/5] firewire: net: invalidate ARP entries of removed nodes Maxim Levitsky
2010-11-29 2:09 ` [PATCH 5/5] firewire: net: ratelimit error messages Maxim Levitsky
2010-11-29 15:02 ` [PATCH 0/5 V2] Firewire networking assorted fixes Stefan Richter
2010-12-04 23:14 ` Maxim Levitsky
2010-12-08 3:32 ` Maxim Levitsky
2010-12-09 1:42 ` Maxim Levitsky
[not found] ` <20101208040559.20639.qmail@stuge.se>
[not found] ` <1291809485.5421.0.camel@maxim-laptop>
2010-12-12 17:09 ` [PATCH update] firewire: net: add carrier detection Stefan Richter
2010-12-12 23:05 ` Ben Hutchings
2010-12-13 0:46 ` [PATCH update 2] " Stefan Richter
2010-12-13 23:01 ` [PATCH update 3] " Stefan Richter
2010-12-14 23:46 ` Maxim Levitsky
2010-12-16 1:17 ` Dan Williams
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=1291550606.2806.237.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=maximlevitsky@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=opurdila@ixiacom.com \
--cc=stable@kernel.org \
--cc=stefanr@s5r6.in-berlin.de \
/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