mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: zzjas98@gmail.com,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/gem-dma: Read vaddr before dropping the object reference
Date: Thu, 3 Dec 2026 15:03:52 +0100	[thread overview]
Message-ID: <4f801f0d-de52-49f8-886d-1b9bcb3ddf4b@suse.de> (raw)
In-Reply-To: <20261202-kbug-l955-v1-1-54b0fdfb7a63@gmail.com>

Hi

Am 03.12.26 um 04:09 schrieb Zijie Zhao via B4 Relay:
> From: Zijie Zhao <zzjas98@gmail.com>
>
> drm_gem_dma_get_unmapped_area() reads dma_obj->vaddr after
> drm_gem_object_put(), which may have dropped the last reference and
> freed the object. Read it before the put.

After putting the object, the vaddr is potentially dangling. How does 
mmap deal with this?

Best regards
Thomas

>
> Found by a static analysis tool.
>
> Fixes: 62a0d98a188c ("drm: allow to use mmuless SoC")
> Signed-off-by: Zijie Zhao <zzjas98@gmail.com>
> ---
> The fix and the changelog were drafted with AI assistance (Claude Code,
> with a second review by OpenAI Codex), then reviewed by the submitter.
>
> Testing:
> - Compile-tested on x86_64 (allmodconfig, W=1):
>    drivers/gpu/drm/drm_gem_dma_helper.o; no new warnings.
> - checkpatch.pl --strict: no errors or warnings.
> ---
>   drivers/gpu/drm/drm_gem_dma_helper.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c
> index 7d9612075d31..8c305f7ad969 100644
> --- a/drivers/gpu/drm/drm_gem_dma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_dma_helper.c
> @@ -355,6 +355,7 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
>   	struct drm_file *priv = filp->private_data;
>   	struct drm_device *dev = priv->minor->dev;
>   	struct drm_vma_offset_node *node;
> +	unsigned long ret;
>   
>   	if (drm_dev_is_unplugged(dev))
>   		return -ENODEV;
> @@ -390,10 +391,11 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
>   	}
>   
>   	dma_obj = to_drm_gem_dma_obj(obj);
> +	ret = dma_obj->vaddr ? (unsigned long)dma_obj->vaddr : -EINVAL;
>   
>   	drm_gem_object_put(obj);
>   
> -	return dma_obj->vaddr ? (unsigned long)dma_obj->vaddr : -EINVAL;
> +	return ret;
>   }
>   EXPORT_SYMBOL_GPL(drm_gem_dma_get_unmapped_area);
>   #endif
>
> ---
> base-commit: 4d6d0a4639a335df10598e6a4373299bc3f167c0
> change-id: 20261202-kbug-l955-5e3659d1c551
>
> Best regards,
> --
> Zijie Zhao <zzjas98@gmail.com>
>
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



      parent reply	other threads:[~2026-12-03 14:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  3:09 Zijie Zhao via B4 Relay
2026-12-03 13:54 ` Chen-Yu Tsai
2026-12-03 14:03 ` Thomas Zimmermann [this message]

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=4f801f0d-de52-49f8-886d-1b9bcb3ddf4b@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=zzjas98@gmail.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

all inboxes | Powered by JetHome®