diff options
author | Jiri Pirko <jiri@resnulli.us> | 2015-02-23 16:02:54 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-23 23:30:28 +0300 |
commit | 57e595631904c827cfa1a0f7bbd7cc9a49da5745 (patch) | |
tree | 6d1164b64d8278ea97b7c87289c664d4935fd40f /drivers/net/team | |
parent | 46b9e4bb76ee26f1e024e048bb95af41b763f48f (diff) | |
download | linux-57e595631904c827cfa1a0f7bbd7cc9a49da5745.tar.xz |
team: fix possible null pointer dereference in team_handle_frame
Currently following race is possible in team:
CPU0 CPU1
team_port_del
team_upper_dev_unlink
priv_flags &= ~IFF_TEAM_PORT
team_handle_frame
team_port_get_rcu
team_port_exists
priv_flags & IFF_TEAM_PORT == 0
return NULL (instead of port got
from rx_handler_data)
netdev_rx_handler_unregister
The thing is that the flag is removed before rx_handler is unregistered.
If team_handle_frame is called in between, team_port_exists returns 0
and team_port_get_rcu will return NULL.
So do not check the flag here. It is guaranteed by netdev_rx_handler_unregister
that team_handle_frame will always see valid rx_handler_data pointer.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/team')
-rw-r--r-- | drivers/net/team/team.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 0e62274e884a..f1ee71e22241 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -43,9 +43,7 @@ static struct team_port *team_port_get_rcu(const struct net_device *dev) { - struct team_port *port = rcu_dereference(dev->rx_handler_data); - - return team_port_exists(dev) ? port : NULL; + return rcu_dereference(dev->rx_handler_data); } static struct team_port *team_port_get_rtnl(const struct net_device *dev) |