mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-10 18:53:38 +00:00
net/mlx5: FPGA, tls, hold rcu read lock a bit longer
[ Upstream commit31634bf5dc
] To avoid use-after-free, hold the rcu read lock until we are done copying flow data into the command buffer. Fixes:ab412e1dd7
("net/mlx5: Accel, add TLS rx offload routines") Reported-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d1785bea2f
commit
7cfddb81a8
1 changed files with 9 additions and 9 deletions
|
@ -217,22 +217,22 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,
|
||||||
void *cmd;
|
void *cmd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
rcu_read_lock();
|
|
||||||
flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
|
|
||||||
rcu_read_unlock();
|
|
||||||
|
|
||||||
if (!flow) {
|
|
||||||
WARN_ONCE(1, "Received NULL pointer for handle\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = kzalloc(size, GFP_ATOMIC);
|
buf = kzalloc(size, GFP_ATOMIC);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
cmd = (buf + 1);
|
cmd = (buf + 1);
|
||||||
|
|
||||||
|
rcu_read_lock();
|
||||||
|
flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
|
||||||
|
if (unlikely(!flow)) {
|
||||||
|
rcu_read_unlock();
|
||||||
|
WARN_ONCE(1, "Received NULL pointer for handle\n");
|
||||||
|
kfree(buf);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
mlx5_fpga_tls_flow_to_cmd(flow, cmd);
|
mlx5_fpga_tls_flow_to_cmd(flow, cmd);
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
MLX5_SET(tls_cmd, cmd, swid, ntohl(handle));
|
MLX5_SET(tls_cmd, cmd, swid, ntohl(handle));
|
||||||
MLX5_SET64(tls_cmd, cmd, tls_rcd_sn, be64_to_cpu(rcd_sn));
|
MLX5_SET64(tls_cmd, cmd, tls_rcd_sn, be64_to_cpu(rcd_sn));
|
||||||
|
|
Loading…
Reference in a new issue