mlx4: fix use-after-free in mlx4_en_fold_software_stats()
authorEric Dumazet <edumazet@google.com>
Thu, 1 Dec 2016 13:02:06 +0000 (05:02 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Dec 2016 18:33:32 +0000 (13:33 -0500)
commit7f7bf1606fa8fa0e3aecdeac0ba8005f2a0fbdef
tree9e260417519b43992f353d24aeb03c3b278dc00c
parentbd3ad7d3a14b07aeeb4f92abc757672719e2a0eb
mlx4: fix use-after-free in mlx4_en_fold_software_stats()

My recent commit to get more precise rx/tx counters in ndo_get_stats64()
can lead to crashes at device dismantle, as Jesper found out.

We must prevent mlx4_en_fold_software_stats() trying to access
tx/rx rings if they are deleted.

Fix this by adding a test against priv->port_up in
mlx4_en_fold_software_stats()

Calling mlx4_en_fold_software_stats() from mlx4_en_stop_port()
allows us to eventually broadcast the latest/current counters to
rtnetlink monitors.

Fixes: 40931b85113d ("mlx4: give precise rx/tx bytes/packets counters")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-and-bisected-by: Jesper Dangaard Brouer <brouer@redhat.com>
Tested-by: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: Tariq Toukan <tariqt@mellanox.com>
Cc: Saeed Mahameed <saeedm@dev.mellanox.co.il>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/en_port.c