All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: oushixiong1025@163.com
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address
Date: Fri, 24 Jul 2026 09:52:19 +0000	[thread overview]
Message-ID: <20260724095219.F40281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724093808.776138-2-oushixiong1025@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch replaces direct access to `map->vaddr` with `iosys_map_get_vaddr()`. However, `iosys_map_get_vaddr()` explicitly warns and returns `NULL` if the mapping points to I/O memory (`map->is_iomem == true`). When userspace imports a dma-buf from a discrete GPU (which typically exports VRAM as I/O memory) into the UDL driver and uses it as a framebuffer, the damage handler `udl_handle_damage()` will receive an I/O memory mapping. Calling `iosys_map_get_vaddr()` on this mapping triggers a `WARN_ON` for every damage rectangle processed and fails the update by returning `-EFAULT`. This functionally breaks PRIME imports from discrete GPUs to DisplayLink devices and creates a local Denial of Service (DoS) vector by allowing a local user to spam the kernel log with warnings or trigger a panic if `panic_on_warn` is enabled. The correct fix for the original architectural issue should have been using `iosys_map_rd()` or `iosys_map_memcpy_from()` rather than `iosys_map_get_vaddr()`.
--

--- Patch [2]: [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address ---
commit 935887dfbb84bad699c0f9cf22dbe263fac86a93
Author: Shixiong Ou <oushixiong@kylinos.cn>

drm/udl: Use iosys_map getter for virtual address
    
Replace direct access to map->vaddr with the new iosys_map_get_vaddr()
helper function. This properly uses the iosys_map abstraction layer
instead of directly accessing structure members.

> diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
> index 289711035b67c..06a3a4d149b9d 100644
> --- a/drivers/gpu/drm/udl/udl_modeset.c
> +++ b/drivers/gpu/drm/udl/udl_modeset.c
> @@ -207,12 +207,16 @@ static int udl_handle_damage(struct drm_framebuffer *fb,
>  {
>  	struct drm_device *dev = fb->dev;
>  	struct udl_device *udl = to_udl(dev);
> -	void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */
> +	void *vaddr;
>  	int i, ret;
>  	char *cmd;
>  	struct urb *urb;
>  	int log_bpp;
>  
> +	vaddr = iosys_map_get_vaddr(map);
> +	if (!vaddr)
> +		return -EFAULT;
> +

[Severity: High]
Does this code break PRIME imports from discrete GPUs?

If userspace imports a dma-buf from a discrete GPU (which typically exports
VRAM as I/O memory) into the UDL driver and uses it as a framebuffer, the
map passed to udl_handle_damage() will be mapped as IOMEM.

Looking at iosys_map_get_vaddr() in include/linux/iosys-map.h:

static inline void *iosys_map_get_vaddr(const struct iosys_map *map)
{
	if (WARN_ON(map->is_iomem))
		return NULL;
	return map->vaddr;
}

This will trigger a WARN_ON for every damage rectangle processed and return
-EFAULT, failing the update. Could this create a local DoS if panic_on_warn
is enabled, or spam the kernel log with warnings?

Would it be safer to use iosys_map_rd() or iosys_map_memcpy_from() here
rather than iosys_map_get_vaddr() to properly handle IOMEM mappings?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724093808.776138-1-oushixiong1025@163.com?part=2

  reply	other threads:[~2026-07-24  9:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  9:38 [PATCH 1/2] iosys-map: Add getter functions for virtual addresses oushixiong1025
2026-07-24  9:38 ` [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address oushixiong1025
2026-07-24  9:52   ` sashiko-bot [this message]
2026-07-24 11:29   ` Thomas Zimmermann
2026-07-24  9:52 ` [PATCH 1/2] iosys-map: Add getter functions for virtual addresses sashiko-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=20260724095219.F40281F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=oushixiong1025@163.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.