From: Oleg Nesterov <oleg@tv-sign.ru>
To: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jarek Poplawski <jarkao2@o2.pl>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: PATCH? net/bridge/br_if.c: fix use after free in port_carrier_check()
Date: Tue, 20 Feb 2007 01:11:25 +0300 [thread overview]
Message-ID: <20070219221125.GA5070@tv-sign.ru> (raw)
In-Reply-To: <20070219115955.GB91@tv-sign.ru>
On 02/19, Oleg Nesterov wrote:
>
> I think the fix should be so that port_carrier_check() does get/put on
> "struct net_bridge_port" (container), but not on "struct net_device", and
>
> del_nbp(struct net_bridge_port *p)
>
> if (cancel_delayed_work(&p->carrier_check))
> - dev_put(p->dev);
> + kobject_put(&p->kobj);
Perhaps something like the patch below? (on top of this patch).
We should do something, the stable tree has the same bug.
Oleg.
--- WQ/net/bridge/br_if.c~5_bridge_uaf 2007-02-18 23:06:15.000000000 +0300
+++ WQ/net/bridge/br_if.c 2007-02-20 00:59:54.000000000 +0300
@@ -83,14 +83,14 @@ static void port_carrier_check(struct wo
struct net_device *dev;
struct net_bridge *br;
- dev = container_of(work, struct net_bridge_port,
- carrier_check.work)->dev;
+ p = container_of(work, struct net_bridge_port, carrier_check.work);
rtnl_lock();
- p = dev->br_port;
- if (!p)
- goto done;
br = p->br;
+ dev = p->dev;
+
+ if (!dev->br_port)
+ goto done;
if (netif_carrier_ok(dev))
p->path_cost = port_cost(dev);
@@ -107,14 +107,16 @@ static void port_carrier_check(struct wo
spin_unlock_bh(&br->lock);
}
done:
- dev_put(dev);
rtnl_unlock();
+ kobject_put(&p->kobj);
}
static void release_nbp(struct kobject *kobj)
{
struct net_bridge_port *p
= container_of(kobj, struct net_bridge_port, kobj);
+
+ dev_put(p->dev);
kfree(p);
}
@@ -127,12 +129,6 @@ static struct kobj_type brport_ktype = {
static void destroy_nbp(struct net_bridge_port *p)
{
- struct net_device *dev = p->dev;
-
- p->br = NULL;
- p->dev = NULL;
- dev_put(dev);
-
kobject_put(&p->kobj);
}
@@ -162,7 +158,7 @@ static void del_nbp(struct net_bridge_po
dev_set_promiscuity(dev, -1);
if (cancel_delayed_work(&p->carrier_check))
- dev_put(dev);
+ kobject_put(&p->kobj);
spin_lock_bh(&br->lock);
br_stp_disable_port(p);
@@ -446,7 +442,7 @@ int br_add_if(struct net_bridge *br, str
br_stp_recalculate_bridge_id(br);
br_features_recompute(br);
if (schedule_delayed_work(&p->carrier_check, BR_PORT_DEBOUNCE))
- dev_hold(dev);
+ kobject_get(&p->kobj);
spin_unlock_bh(&br->lock);
next prev parent reply other threads:[~2007-02-19 22:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-18 21:43 [PATCH 1/3] net/bridge/br_if.c: don't use _WORK_NAR Oleg Nesterov
2007-02-19 11:00 ` Jarek Poplawski
2007-02-19 12:03 ` Oleg Nesterov
2007-02-19 13:27 ` Jarek Poplawski
2007-02-19 15:04 ` Oleg Nesterov
2007-02-20 13:25 ` Jarek Poplawski
2007-02-20 14:25 ` Oleg Nesterov
2007-02-19 11:27 ` David Howells
2007-02-19 11:59 ` Oleg Nesterov
2007-02-19 22:11 ` Oleg Nesterov [this message]
2007-02-20 10:44 ` PATCH? net/bridge/br_if.c: fix use after free in port_carrier_check() David Howells
2007-02-20 14:34 ` Oleg Nesterov
2007-02-19 13:15 ` [PATCH 1/3] net/bridge/br_if.c: don't use _WORK_NAR David Howells
2007-02-19 14:56 ` Oleg Nesterov
2007-02-19 15:15 ` David Howells
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=20070219221125.GA5070@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=jarkao2@o2.pl \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®