Commit b51e4b0a authored by Eli Cohen's avatar Eli Cohen Committed by Greg Kroah-Hartman

IB/mlx5: Fix kernel to user leak prevention logic

commit de8d6e02 upstream.

The logic was broken as it failed to update the response length for
architectures with PAGE_SIZE larger than 4kB. As a result further
extension of the ucontext response struct would fail.

Fixes: d69e3bcf ('IB/mlx5: Mmap the HCA's core clock register to user-space')
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Reviewed-by: default avatarMatan Barak <matanb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dca02651
...@@ -1105,13 +1105,13 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, ...@@ -1105,13 +1105,13 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
* pretend we don't support reading the HCA's core clock. This is also * pretend we don't support reading the HCA's core clock. This is also
* forced by mmap function. * forced by mmap function.
*/ */
if (PAGE_SIZE <= 4096 && if (field_avail(typeof(resp), hca_core_clock_offset, udata->outlen)) {
field_avail(typeof(resp), hca_core_clock_offset, udata->outlen)) { if (PAGE_SIZE <= 4096) {
resp.comp_mask |= resp.comp_mask |=
MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET; MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET;
resp.hca_core_clock_offset = resp.hca_core_clock_offset =
offsetof(struct mlx5_init_seg, internal_timer_h) % offsetof(struct mlx5_init_seg, internal_timer_h) % PAGE_SIZE;
PAGE_SIZE; }
resp.response_length += sizeof(resp.hca_core_clock_offset) + resp.response_length += sizeof(resp.hca_core_clock_offset) +
sizeof(resp.reserved2); sizeof(resp.reserved2);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment