Commit ee5e8dd1 authored by Ido Schimmel's avatar Ido Schimmel Committed by Kelsey Skunberg

mlxsw: core: Increase scope of RCU read-side critical section

BugLink: https://bugs.launchpad.net/bugs/1892822

[ Upstream commit 7d8e8f34 ]

The lifetime of the Rx listener item ('rxl_item') is managed using RCU,
but is dereferenced outside of RCU read-side critical section, which can
lead to a use-after-free.

Fix this by increasing the scope of the RCU read-side critical section.

Fixes: 93c1edb2 ("mlxsw: Introduce Mellanox switch driver core")
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent 5614728c
...@@ -1208,9 +1208,10 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb, ...@@ -1208,9 +1208,10 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
break; break;
} }
} }
rcu_read_unlock(); if (!found) {
if (!found) rcu_read_unlock();
goto drop; goto drop;
}
pcpu_stats = this_cpu_ptr(mlxsw_core->pcpu_stats); pcpu_stats = this_cpu_ptr(mlxsw_core->pcpu_stats);
u64_stats_update_begin(&pcpu_stats->syncp); u64_stats_update_begin(&pcpu_stats->syncp);
...@@ -1221,6 +1222,7 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb, ...@@ -1221,6 +1222,7 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
u64_stats_update_end(&pcpu_stats->syncp); u64_stats_update_end(&pcpu_stats->syncp);
rxl->func(skb, local_port, rxl_item->priv); rxl->func(skb, local_port, rxl_item->priv);
rcu_read_unlock();
return; return;
drop: drop:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment