Skip to content

Commit 2108330

Browse files
Raed SalemSaeed Mahameed
authored andcommitted
net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev
mlx5e_rep_is_lag_netdev is used as first check as part of netdev events handler for bond device of non-uplink representors, this handler can get any netdevice under the same network namespace of mlx5e netdevice. Current code treats the netdev as mlx5e netdev and only later on verifies this, hence causes the following Kasan trace: [15402.744990] ================================================================== [15402.746942] BUG: KASAN: slab-out-of-bounds in mlx5e_rep_is_lag_netdev+0xcb/0xf0 [mlx5_core] [15402.749009] Read of size 8 at addr ffff880391f3f6b0 by task ovs-vswitchd/5347 [15402.752065] CPU: 7 PID: 5347 Comm: ovs-vswitchd Kdump: loaded Tainted: G B O --------- -t - 4.18.0-g3dcc204d291d-dirty #1 [15402.755349] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [15402.757600] Call Trace: [15402.758968] dump_stack+0x71/0xab [15402.760427] print_address_description+0x6a/0x270 [15402.761969] kasan_report+0x179/0x2d0 [15402.763445] ? mlx5e_rep_is_lag_netdev+0xcb/0xf0 [mlx5_core] [15402.765121] mlx5e_rep_is_lag_netdev+0xcb/0xf0 [mlx5_core] [15402.766782] mlx5e_rep_esw_bond_netevent+0x129/0x620 [mlx5_core] Fix by deferring the violating access to be post the netdev verify check. Fixes: 7e51891 ("net/mlx5e: Use netdev events to set/del egress acl forward-to-vport rule") Signed-off-by: Raed Salem <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Reviewed-by: Vu Pham <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 071995c commit 2108330

File tree

1 file changed

+5
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en/rep

1 file changed

+5
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ void mlx5e_rep_bond_unslave(struct mlx5_eswitch *esw,
183183

184184
static bool mlx5e_rep_is_lag_netdev(struct net_device *netdev)
185185
{
186-
struct mlx5e_priv *priv = netdev_priv(netdev);
187-
struct mlx5e_rep_priv *rpriv = priv->ppriv;
186+
struct mlx5e_rep_priv *rpriv;
187+
struct mlx5e_priv *priv;
188188

189189
/* A given netdev is not a representor or not a slave of LAG configuration */
190190
if (!mlx5e_eswitch_rep(netdev) || !bond_slave_get_rtnl(netdev))
191191
return false;
192192

193+
priv = netdev_priv(netdev);
194+
rpriv = priv->ppriv;
195+
193196
/* Egress acl forward to vport is supported only non-uplink representor */
194197
return rpriv->rep->vport != MLX5_VPORT_UPLINK;
195198
}

0 commit comments

Comments
 (0)