From: "Maíra Canal" <mcanal@igalia.com>
To: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
dri-devel@lists.freedesktop.org
Cc: kernel-dev@igalia.com
Subject: Re: [PATCH 4/7] drm/syncobj: Use put_user in drm_syncobj_query_ioctl
Date: Mon, 24 Mar 2025 19:32:52 -0300 [thread overview]
Message-ID: <ed004911-dc1f-4e15-9df0-a43e0334fcb1@igalia.com> (raw)
In-Reply-To: <20250318155424.78552-5-tvrtko.ursulin@igalia.com>
Hi Tvrtko,
On 18/03/25 12:54, Tvrtko Ursulin wrote:
> Since the query loop is using copy_to_user() to write out a single u64 at
> a time it feels more natural (and is a tiny bit more compact) to replace
> it with put_user().
>
> Access_ok() check is added to the input checking for an early bailout in
> case of a bad buffer passed in.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Best Regards,
- Maíra
> ---
> drivers/gpu/drm/drm_syncobj.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index cdda2df06bec..74d1dc0d1f8b 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -1643,6 +1643,9 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
> if (args->count_handles == 0)
> return -EINVAL;
>
> + if (!access_ok(points, args->count_handles * sizeof(*points)))
> + return -EFAULT;
> +
> ret = drm_syncobj_array_find(file_private,
> u64_to_user_ptr(args->handles),
> args->count_handles,
> @@ -1684,10 +1687,10 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
> point = 0;
> }
> dma_fence_put(fence);
> - ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
> - ret = ret ? -EFAULT : 0;
> - if (ret)
> + if (__put_user(point, points++)) {
> + ret = -EFAULT;
> break;
> + }
> }
> drm_syncobj_array_free(syncobjs, args->count_handles);
>
next prev parent reply other threads:[~2025-03-24 22:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 15:54 [PATCH 0/7] A few drm_syncobj optimisations Tvrtko Ursulin
2025-03-18 15:54 ` [PATCH 1/7] drm/syncobj: Remove unhelpful helper Tvrtko Ursulin
2025-03-24 21:38 ` Maíra Canal
2025-03-25 9:12 ` Tvrtko Ursulin
2025-03-18 15:54 ` [PATCH 2/7] drm/syncobj: Do not allocate an array to store zeros when waiting Tvrtko Ursulin
2025-03-24 21:55 ` Maíra Canal
2025-03-18 15:54 ` [PATCH 3/7] drm/syncobj: Avoid one temporary allocation in drm_syncobj_array_find Tvrtko Ursulin
2025-03-24 22:29 ` Maíra Canal
2025-03-25 9:26 ` Tvrtko Ursulin
2025-03-18 15:54 ` [PATCH 4/7] drm/syncobj: Use put_user in drm_syncobj_query_ioctl Tvrtko Ursulin
2025-03-24 22:32 ` Maíra Canal [this message]
2025-03-18 15:54 ` [PATCH 5/7] drm/syncobj: Avoid temporary allocation in drm_syncobj_timeline_signal_ioctl Tvrtko Ursulin
2025-03-24 22:50 ` Maíra Canal
2025-03-18 15:54 ` [PATCH 6/7] drm/syncobj: Add a fast path to drm_syncobj_array_wait_timeout Tvrtko Ursulin
2025-03-24 23:00 ` Maíra Canal
2025-03-25 9:33 ` Tvrtko Ursulin
2025-03-25 19:56 ` Maíra Canal
2025-03-18 15:54 ` [PATCH 7/7] drm/syncobj: Add a fast path to drm_syncobj_array_find Tvrtko Ursulin
2025-03-24 23:06 ` Maíra Canal
2025-03-25 9:54 ` Tvrtko Ursulin
2025-03-25 20:12 ` Maíra Canal
2025-03-24 23:17 ` [PATCH 0/7] A few drm_syncobj optimisations Maíra Canal
2025-03-25 9:57 ` Tvrtko Ursulin
2025-03-25 21:10 ` Maíra Canal
-- strict thread matches above, loose matches on Subject: below --
2025-01-06 10:55 [PATCH v2 " Tvrtko Ursulin
2025-01-06 10:55 ` [PATCH 4/7] drm/syncobj: Use put_user in drm_syncobj_query_ioctl Tvrtko Ursulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed004911-dc1f-4e15-9df0-a43e0334fcb1@igalia.com \
--to=mcanal@igalia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-dev@igalia.com \
--cc=tvrtko.ursulin@igalia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).