Skip to content

Commit 716ec05

Browse files
Hong Zhiguodavem330
Hong Zhiguo
authored andcommitted
bridge: fix NULL pointer deref of br_port_get_rcu
The NULL deref happens 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 remove the testing of IFF_BRIDGE_PORT and by the previous patch, make sure br_port_get_rcu is called in bridging code. Signed-off-by: Hong Zhiguo <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1fb1754 commit 716ec05

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

net/bridge/br_private.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ struct net_bridge_port
202202

203203
static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev)
204204
{
205-
struct net_bridge_port *port =
206-
rcu_dereference_rtnl(dev->rx_handler_data);
207-
208-
return br_port_exists(dev) ? port : NULL;
205+
return rcu_dereference(dev->rx_handler_data);
209206
}
210207

211208
static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)

0 commit comments

Comments
 (0)