netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] bridge: fix NULL pointer deref of br_port_get_rcu
@ 2013-09-14 14:42 Hong Zhiguo
  2013-09-14 14:42 ` [PATCH net-next 1/2] bridge: use br_port_get_rtnl within rtnl lock Hong Zhiguo
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Hong Zhiguo @ 2013-09-14 14:42 UTC (permalink / raw)
  To: netdev; +Cc: davem, eric.dumazet, vyasevic, Hong Zhiguo

From: Hong Zhiguo <zhiguohong@tencent.com>

I got an Oops on my box when br_handle_frame is called between these
2 lines of del_nbp:
	dev->priv_flags &= ~IFF_BRIDGE_PORT;
	/* --> br_handle_frame is called at this time */
	netdev_rx_handler_unregister(dev);

In br_handle_frame the return of br_port_get_rcu(dev) is dereferenced
without check but br_port_get_rcu(dev) returns NULL if:
	!(dev->priv_flags & IFF_BRIDGE_PORT)

Eric Dumazet pointed out the testing of IFF_BRIDGE_PORT is not necessary
here since we're in rcu_read_lock and we have synchronize_net() in
netdev_rx_handler_unregister. So removed the testing of
IFF_BRIDGE_PORT.

I tested the fix on my box with script doing "brctl addif" and "brctl
delif" repeatedly while a lot of broadcast frame present on the LAN.
I added msleep in del_nbp between setting of priv_flags and unregister
so it's easy to reproduce the oops without the fix.

I want to remove the NULL checks following call to br_port_get_rcu in
Br_netfilter and ebtables code. Could someone confirm that's OK?

The Oops(some lines omitted):
BUG: unable to handle kernel NULL pointer dereference at 0000000000000021
IP: [<ffffffff8150901d>] br_handle_frame+0xed/0x230
Oops: 0000 [#1] PREEMPT SMP
RIP: 0010:[<ffffffff8150901d>]  [<ffffffff8150901d>] br_handle_frame+0xed/0x230
RSP: 0018:ffff880030403c10  EFLAGS: 00010286
Stack:
 ffff88002c945700 ffffffff81508f30 0000000000000000 ffff88002d41e000
 ffff880030403c98 ffffffff81477acb ffffffff81477821 ffff880030403c68
 ffffffff81090e10 00ff88002d545c80 ffff88002c945700 ffffffff81aa50c0
Call Trace:
 <IRQ>
 [<ffffffff81508f30>] ? br_handle_frame_finish+0x300/0x300
 [<ffffffff81477acb>] __netif_receive_skb_core+0x39b/0x880

Hong Zhiguo (2):
  bridge: use br_port_get_rtnl within rtnl lock
  bridge: fix NULL pointer deref of br_port_get_rcu

 net/bridge/br_netlink.c | 4 ++--
 net/bridge/br_private.h | 7 ++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-09-16 18:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-14 14:42 [PATCH net-next 0/2] bridge: fix NULL pointer deref of br_port_get_rcu Hong Zhiguo
2013-09-14 14:42 ` [PATCH net-next 1/2] bridge: use br_port_get_rtnl within rtnl lock Hong Zhiguo
2013-09-14 18:46   ` Eric Dumazet
2013-09-14 14:42 ` [PATCH net-next 2/2] bridge: fix NULL pointer deref of br_port_get_rcu Hong Zhiguo
2013-09-14 18:47   ` Eric Dumazet
2013-09-16 17:58   ` Vlad Yasevich
2013-09-16 18:32     ` Stephen Hemminger
2013-09-16 18:37       ` Vlad Yasevich
2013-09-16 18:44         ` Stephen Hemminger
2013-09-16  4:55 ` [PATCH net-next 0/2] " David Miller

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).