]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net/mlx5e: Fix incorrect access of RCU-protected xdp_prog
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Thu, 22 Oct 2020 09:49:51 +0000 (12:49 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2020 18:22:17 +0000 (19:22 +0100)
[ Upstream commit 1a50cf9a67ff2241c2949d30bc11c8dd4280eef8 ]

rq->xdp_prog is RCU-protected and should be accessed only with
rcu_access_pointer for the NULL check in mlx5e_poll_rx_cq.

rq->xdp_prog may change on the fly only from one non-NULL value to
another non-NULL value, so the checks in mlx5e_xdp_handle and
mlx5e_poll_rx_cq will have the same result during one NAPI cycle,
meaning that no additional synchronization is needed.

Fixes: fe45386a2082 ("net/mlx5e: Use RCU to protect rq->xdp_prog")
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

index 64c8ac5eabf6a81325fdabd1daee031e8b74987e..a0a4398408b850c7281fa0b6e75f4c44161fc576 100644 (file)
@@ -1566,7 +1566,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
        } while ((++work_done < budget) && (cqe = mlx5_cqwq_get_cqe(cqwq)));
 
 out:
-       if (rq->xdp_prog)
+       if (rcu_access_pointer(rq->xdp_prog))
                mlx5e_xdp_rx_poll_complete(rq);
 
        mlx5_cqwq_update_db_record(cqwq);