Message ID | 51C2721B.9050603@gmail.com |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Thu, 2013-06-20 at 11:08 +0800, xiaoming gao wrote: > From: newtongao <newtongao@tencent.com> > Date: Wed, 19 Jun 2013 14:58:33 +0800 > Subject: [PATCH] net bridge: add null pointer check,fix panic > > in kernel 3.0, br_port_get_rcu() may return NULL when network interface be deleting from bridge, > but in function br_handle_frame and br_handle_local_finish, the pointer didn't be checked before using, > so all br_port_get_rcu callers must do null check,or there occurs the null pointer panic. > > kernel 3.4 also has this bug,i have verified. > mainline kernel still did not check br_port_get_rcu()'s NULL pointer, but i have not tested it yet. Please check current version before sending a patch. This was most probably fixed in commit 00cfec37484761a44 ("net: add a synchronize_net() in netdev_rx_handler_unregister()") Thanks -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Eric Dumazet said, at 2013-6-20 12:55: > On Thu, 2013-06-20 at 11:08 +0800, xiaoming gao wrote: >> From: newtongao <newtongao@tencent.com> >> Date: Wed, 19 Jun 2013 14:58:33 +0800 >> Subject: [PATCH] net bridge: add null pointer check,fix panic >> >> in kernel 3.0, br_port_get_rcu() may return NULL when network interface be deleting from bridge, >> but in function br_handle_frame and br_handle_local_finish, the pointer didn't be checked before using, >> so all br_port_get_rcu callers must do null check,or there occurs the null pointer panic. >> >> kernel 3.4 also has this bug,i have verified. >> mainline kernel still did not check br_port_get_rcu()'s NULL pointer, but i have not tested it yet. > > Please check current version before sending a patch. > > This was most probably fixed in commit 00cfec37484761a44 > ("net: add a synchronize_net() in netdev_rx_handler_unregister()") > > Thanks > > HI Eric the problem is as follow: br_del_if()-->del_nbp(): list_del_rcu(&p->list); dev->priv_flags &= ~IFF_BRIDGE_PORT; ------>at this point, the nic be deleting still have rx_handler , so , may in br_handle_frame() ------>br_port_exists() will return false,so br_get_port_rcu() will return NULL ------>so in br_handle_frame , there will be a null panic. netdev_rx_handler_unregister(dev); synchronize_net(); i have checked commit 00cfec37484761a44, i think it didn't fix this bug.. thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index f06ee39..c8b365f 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -122,7 +122,8 @@ static int br_handle_local_finish(struct sk_buff *skb) { struct net_bridge_port *p = br_port_get_rcu(skb->dev); - br_fdb_update(p->br, p, eth_hdr(skb)->h_source); + if (p) + br_fdb_update(p->br, p, eth_hdr(skb)->h_source); return 0; /* process further */ } @@ -160,6 +161,8 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb) return RX_HANDLER_CONSUMED; p = br_port_get_rcu(skb->dev); + if (!p) + goto drop; if (unlikely(is_link_local(dest))) { /* Pause frames shouldn't be passed up by driver anyway */