From: sashiko-bot@kernel.org
To: "Simona Vetter" <simona.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/gem: Try to fix change_handle ioctl, attempt 4
Date: Thu, 04 Jun 2026 19:29:47 +0000 [thread overview]
Message-ID: <20260604192948.915571F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604191916.1713387-1-simona.vetter@ffwll.ch>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing IS_ERR check on idr_replace() return value causes an invalid pointer dereference.
--
commit f7209a31976a5023734386f397179e3835aa2048
Author: Simona Vetter <simona.vetter@ffwll.ch>
drm/gem: Try to fix change_handle ioctl, attempt 4
This commit modifies the change_handle ioctl to resolve a race condition
by merging the GEM object lookup and two-stage idr_replace. It also
temporarily disables the ioctl in drm_ioctls to prevent further abuse until
the implementation is fully verified.
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index ac751a42db281..66cfd52c7cff9 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
[ ... ]
> @@ -1028,52 +1028,36 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
[ ... ]
> + obj = idr_replace(&file_priv->object_idr, NULL, args->handle);
> + if (!obj) {
[Severity: High]
Will this result in dereferencing an error pointer if args->handle is invalid?
If idr_replace() fails to find the handle, it returns ERR_PTR(-ENOENT) rather
than NULL. The check here only tests for NULL, allowing an error pointer to
fall through.
> + idr_remove(&file_priv->object_idr, new_handle);
> + spin_unlock(&file_priv->table_lock);
> + ret = -ENOENT;
> + goto out_unlock;
> + }
> spin_unlock(&file_priv->table_lock);
>
> if (obj->dma_buf) {
If an error pointer falls through the check above, wouldn't evaluating
obj->dma_buf here cause an invalid pointer dereference? Should the error
handling for idr_replace() be updated to use IS_ERR(obj)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260604191916.1713387-1-simona.vetter@ffwll.ch?part=1
next prev parent reply other threads:[~2026-06-04 19:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 19:19 [PATCH] drm/gem: Try to fix change_handle ioctl, attempt 4 Simona Vetter
2026-06-04 19:29 ` sashiko-bot [this message]
2026-06-04 19:44 ` Simona Vetter
2026-06-04 19:58 ` sashiko-bot
2026-06-04 20:00 ` Claude review: " Claude Code Review Bot
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=20260604192948.915571F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=simona.vetter@ffwll.ch \
/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