public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
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:58:47 +0000	[thread overview]
Message-ID: <20260604195848.546B31F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604194437.1725314-1-simona.vetter@ffwll.ch>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The ioctl returns 0 on `args->handle == args->new_handle` without validating if the handle actually exists in the IDR.
--

commit c59eb6aaceabfd08a4835d7c2c0133017afcb072
Author: Simona Vetter <simona.vetter@ffwll.ch>

drm/gem: Try to fix change_handle ioctl, attempt 4

This commit attempts to fix a race condition in the change_handle ioctl by
reworking the two-stage idr replacement logic and renaming variables for
clarity. It also unifies the object lookup and idr_replace steps and disables
the ioctl pending testing.

> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index ac751a42db281..55caad80a3503 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,
>  	/* idr_alloc() limitation. */
>  	if (args->new_handle > INT_MAX)
>  		return -EINVAL;
> -	handle = args->new_handle;
> -
> -	obj = drm_gem_object_lookup(file_priv, args->handle);
> -	if (!obj)
> -		return -ENOENT;
> +	new_handle = args->new_handle;
>  
> -	if (args->handle == handle) {
> -		ret = 0;
> -		goto out;
> -	}
> +	if (args->handle == new_handle)
> +		return 0;

[Severity: High]
Does this new early return skip handle validation?

Previously, drm_gem_object_lookup() was called before this check, returning
-ENOENT if the given handle was invalid. In the new code, if a user passes
a non-existent handle but sets new_handle to the exact same value, the ioctl
will return 0 (success) instead of -ENOENT. 

Should the handle existence still be verified before returning success here?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260604194437.1725314-1-simona.vetter@ffwll.ch?part=1

  reply	other threads:[~2026-06-04 19:58 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
2026-06-04 19:44 ` Simona Vetter
2026-06-04 19:58   ` sashiko-bot [this message]
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=20260604195848.546B31F00893@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