[PATCH 2/2] drm/amdgpu: validate user queue parameters
Liang, Prike
Prike.Liang at amd.com
Thu Feb 27 10:15:28 UTC 2025
[Public]
It seems that invalid input parameters happen rarely. Using the `unlikely()` function in the validation condition can optimize the code execution path.
Anyway, the patch series is Reviewed-by: Prike Liang <Prike.Liang at amd.com>
Regards,
Prike
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Thursday, February 27, 2025 12:03 PM
> To: amd-gfx at lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher at amd.com>
> Subject: [PATCH 2/2] drm/amdgpu: validate user queue parameters
>
> Make sure these are set properly to ensure compatibility if we ever update the
> IOCTL interface.
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> index 0664e04828c07..39279920a757c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> @@ -380,12 +380,26 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void
> *data,
>
> switch (args->in.op) {
> case AMDGPU_USERQ_OP_CREATE:
> + if (args->in._pad)
> + return -EINVAL;
> r = amdgpu_userqueue_create(filp, args);
> if (r)
> DRM_ERROR("Failed to create usermode queue\n");
> break;
>
> case AMDGPU_USERQ_OP_FREE:
> + if (args->in.ip_type ||
> + args->in.doorbell_handle ||
> + args->in.doorbell_offset ||
> + args->in._pad ||
> + args->in.queue_va ||
> + args->in.queue_size ||
> + args->in.rptr_va ||
> + args->in.wptr_va ||
> + args->in.wptr_va ||
> + args->in.mqd ||
> + args->in.mqd_size)
> + return -EINVAL;
> r = amdgpu_userqueue_destroy(filp, args->in.queue_id);
> if (r)
> DRM_ERROR("Failed to destroy usermode queue\n");
> --
> 2.48.1
More information about the amd-gfx
mailing list