Skip to content

Commit 156ee62

Browse files
committed
Merge branch 'mlxsw-Various-fixes'
Ido Schimmel says: ==================== mlxsw: Various fixes Patch #1 from Jiri fixes a use-after-free discovered while fuzzing mlxsw / devlink with syzkaller. Patch #2 from Amit works around a limitation in new versions of arping, which is used in several selftests. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a96ac8a + 46ca111 commit 156ee62

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3986,6 +3986,7 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp)
39863986
mlxsw_sp_port_remove(mlxsw_sp, i);
39873987
mlxsw_sp_cpu_port_remove(mlxsw_sp);
39883988
kfree(mlxsw_sp->ports);
3989+
mlxsw_sp->ports = NULL;
39893990
}
39903991

39913992
static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
@@ -4022,6 +4023,7 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
40224023
mlxsw_sp_cpu_port_remove(mlxsw_sp);
40234024
err_cpu_port_create:
40244025
kfree(mlxsw_sp->ports);
4026+
mlxsw_sp->ports = NULL;
40254027
return err;
40264028
}
40274029

@@ -4143,6 +4145,14 @@ static int mlxsw_sp_local_ports_offset(struct mlxsw_core *mlxsw_core,
41434145
return mlxsw_core_res_get(mlxsw_core, local_ports_in_x_res_id);
41444146
}
41454147

4148+
static struct mlxsw_sp_port *
4149+
mlxsw_sp_port_get_by_local_port(struct mlxsw_sp *mlxsw_sp, u8 local_port)
4150+
{
4151+
if (mlxsw_sp->ports && mlxsw_sp->ports[local_port])
4152+
return mlxsw_sp->ports[local_port];
4153+
return NULL;
4154+
}
4155+
41464156
static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port,
41474157
unsigned int count,
41484158
struct netlink_ext_ack *extack)
@@ -4156,7 +4166,7 @@ static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port,
41564166
int i;
41574167
int err;
41584168

4159-
mlxsw_sp_port = mlxsw_sp->ports[local_port];
4169+
mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port);
41604170
if (!mlxsw_sp_port) {
41614171
dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n",
41624172
local_port);
@@ -4251,7 +4261,7 @@ static int mlxsw_sp_port_unsplit(struct mlxsw_core *mlxsw_core, u8 local_port,
42514261
int offset;
42524262
int i;
42534263

4254-
mlxsw_sp_port = mlxsw_sp->ports[local_port];
4264+
mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port);
42554265
if (!mlxsw_sp_port) {
42564266
dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n",
42574267
local_port);

drivers/net/ethernet/mellanox/mlxsw/switchx2.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@ static void mlxsw_sx_ports_remove(struct mlxsw_sx *mlxsw_sx)
12591259
if (mlxsw_sx_port_created(mlxsw_sx, i))
12601260
mlxsw_sx_port_remove(mlxsw_sx, i);
12611261
kfree(mlxsw_sx->ports);
1262+
mlxsw_sx->ports = NULL;
12621263
}
12631264

12641265
static int mlxsw_sx_ports_create(struct mlxsw_sx *mlxsw_sx)
@@ -1293,6 +1294,7 @@ static int mlxsw_sx_ports_create(struct mlxsw_sx *mlxsw_sx)
12931294
if (mlxsw_sx_port_created(mlxsw_sx, i))
12941295
mlxsw_sx_port_remove(mlxsw_sx, i);
12951296
kfree(mlxsw_sx->ports);
1297+
mlxsw_sx->ports = NULL;
12961298
return err;
12971299
}
12981300

@@ -1376,6 +1378,12 @@ static int mlxsw_sx_port_type_set(struct mlxsw_core *mlxsw_core, u8 local_port,
13761378
u8 module, width;
13771379
int err;
13781380

1381+
if (!mlxsw_sx->ports || !mlxsw_sx->ports[local_port]) {
1382+
dev_err(mlxsw_sx->bus_info->dev, "Port number \"%d\" does not exist\n",
1383+
local_port);
1384+
return -EINVAL;
1385+
}
1386+
13791387
if (new_type == DEVLINK_PORT_TYPE_AUTO)
13801388
return -EOPNOTSUPP;
13811389

tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ test_uc_aware()
300300
local i
301301

302302
for ((i = 0; i < attempts; ++i)); do
303-
if $ARPING -c 1 -I $h1 -b 192.0.2.66 -q -w 0.1; then
303+
if $ARPING -c 1 -I $h1 -b 192.0.2.66 -q -w 1; then
304304
((passes++))
305305
fi
306306

0 commit comments

Comments
 (0)