Patch "mlxsw: spectrum_router: Fix error path in mlxsw_sp_vr_create" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
mlxsw: spectrum_router: Fix error path in mlxsw_sp_vr_create
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mlxsw-spectrum_router-fix-error-path-in-mlxsw_sp_vr_create.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Tue Mar 6 19:02:12 PST 2018
From: Jiri Pirko <[email protected]>
Date: Tue, 13 Feb 2018 11:22:42 +0100
Subject: mlxsw: spectrum_router: Fix error path in mlxsw_sp_vr_create
From: Jiri Pirko <[email protected]>
[ Upstream commit 0f2d2b2736b08dafa3bde31d048750fbc8df3a31 ]
Since mlxsw_sp_fib_create() and mlxsw_sp_mr_table_create() use ERR_PTR macro to propagate int err through return of a pointer, the return value is not NULL in case of failure. So if one of the calls fails, one of vr->fib4, vr->fib6 or vr->mr4_table is not NULL and mlxsw_sp_vr_is_used wrongly assumes
that vr is in use which leads to crash like following one:
[ 1293.949291] BUG: unable to handle kernel NULL pointer dereference at 00000000000006c9 [ 1293.952729] IP: mlxsw_sp_mr_table_flush+0x15/0x70 [mlxsw_spectrum]
Fix this by using local variables to hold the pointers and set vr->* only in case everything went fine.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 19 ++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +11 -8
@@ -729,26 +729,29 @@ static struct mlxsw_sp_fib *mlxsw_sp_vr_static struct mlxsw_sp_vr *mlxsw_sp_vr_create (struct mlxsw_sp *mlxsw_sp,u32 tb_id) { +struct mlxsw_sp_fib *fib4; +struct mlxsw_sp_fib *fib6;struct mlxsw_sp_vr *vr;int err; vr =mlxsw_sp_vr_find_unused (mlxsw_sp);if (!vr)return ERR_PTR (-EBUSY ); - vr->fib4 =mlxsw_sp_fib_create (vr,MLXSW_SP_L3_PROTO_IPV4 ); -if (IS_ERR (vr->fib4)) -return ERR_CAST (vr->fib4); - vr->fib6 =mlxsw_sp_fib_create (vr,MLXSW_SP_L3_PROTO_IPV6 ); -if (IS_ERR (vr->fib6)) { - err =PTR_ERR (vr->fib6); + fib4 =mlxsw_sp_fib_create (vr,MLXSW_SP_L3_PROTO_IPV4 ); +if (IS_ERR (fib4)) +return ERR_CAST (fib4); + fib6 =mlxsw_sp_fib_create (vr,MLXSW_SP_L3_PROTO_IPV6 ); +if (IS_ERR (fib6)) { + err =PTR_ERR (fib6); goto err_fib6_create; } + vr->fib4 = fib4; + vr->fib6 = fib6; vr->tb_id = tb_id;return vr; err_fib6_create: -mlxsw_sp_fib_destroy (vr->fib4); - vr->fib4 =NULL ; +mlxsw_sp_fib_destroy (fib4);return ERR_PTR (err); }
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/mlxsw-spectrum_router-fix-error-path-in-mlxsw_sp_vr_create.patch queue-4.14/mlxsw-spectrum_router-do-not-unconditionally-clear-route-offload-indication.patch queue-4.14/net-sched-report-if-filter-is-too-large-to-dump.patch queue-4.14/mlxsw-spectrum_switchdev-check-success-of-fdb-add-operation.patch