Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/panic: data corruption in drm_panic_get_qr_code_url()
  [1]
--

commit 6107444dfad860987491c5c76fe37fcd55bcb9ae
Author: Thomas Zimmermann <[email protected]>

drm/panic: Do not use un-escaped URL as format string

This commit passes CONFIG_DRM_PANIC_SCREEN_QR_CODE_URL via a %s format
specifier in drm_panic_get_qr_code_url() instead of concatenating it
directly into the snprintf() format string.

Link: https://patch.msgid.link/[email protected]

> diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
> index 0aa87eafdacd5..7dedf18f9ed0c 100644
> --- a/drivers/gpu/drm/drm_panic.c
> +++ b/drivers/gpu/drm/drm_panic.c
> @@ -502,7 +502,8 @@ static int drm_panic_get_qr_code_url(u8 **qr_image)
>       char *kmsg;
>       int max_qr_data_size, url_len;
>  
> -     url_len = snprintf(url, sizeof(url), 
> CONFIG_DRM_PANIC_SCREEN_QR_CODE_URL "?a=%s&v=%s&zl=",
> +     url_len = snprintf(url, sizeof(url), "%s?a=%s&v=%s&zl=",
> +                        CONFIG_DRM_PANIC_SCREEN_QR_CODE_URL,
>                          utsname()->machine, utsname()->release);
>  
>       max_qr_data_size = drm_panic_qr_max_data_size(panic_qr_version, 
> url_len);

[Severity: Critical]
This problem wasn't introduced by this patch, but can concurrent debugfs
writes across different DRM devices corrupt the global zlib stream and
buffers in drm_panic_get_qr_code_url() [1]?

draw_panic_plane() only serializes callers per device via
drm_panic_trylock(plane->dev), while drm_panic_get_qr_code_url() and
drm_panic_get_qr_code_raw() operate on shared file-scope globals:

drivers/gpu/drm/drm_panic.c:
static char *qrbuf1;
static char *qrbuf2;
static struct z_stream_s stream;

CPU0                                    CPU1
debugfs_panic_write() (dev A)           debugfs_panic_write() (dev B)
  draw_panic_plane()                      draw_panic_plane()
    drm_panic_trylock(dev A)                drm_panic_trylock(dev B)
    ...                                     ...
      drm_panic_get_qr_code_url()             drm_panic_get_qr_code_url()
        zlib_deflateInit2(&stream, ...)
                                                zlib_deflateInit2(&stream, ...)
        stream.next_in = kmsg;                  stream.next_in = kmsg;
                                                  <-- corrupts shared stream

Concurrent writes to per-plane panic debugfs files on two DRM devices
simultaneously mutate qrbuf1, qrbuf2, and stream, corrupting zlib state
and kernel memory.

[1] https://sashiko.dev/#/bug/linux-093f9782-c6d2-4cc0-b04c-5ef4dea5d6f9

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to