All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Devin Wittmayer" <lucid_duck@justthetip.ca>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/panic: Fix kmsg screen hang on a long log line
Date: Fri, 16 Oct 2026 05:39:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-173828@kernel.org> (raw)
In-Reply-To: <20261016052722.60051-1-lucid_duck@justthetip.ca>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/panic: pointer underflow and off-by-one line skipping
--

commit 0e87da3652905d3ac59b3e4a4293f550785dff6f
Author: Devin Wittmayer <lucid_duck@justthetip.ca>

drm/panic: Fix kmsg screen hang on a long log line

This commit increases the size of kmsg_buf and makes it static to avoid 
stack issues. It also adds a check to stop reading if kmsg_len is 0,
preventing an infinite loop when a log record doesn't fit in the buffer.

> diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
> index e576c4791861d..29b1487de7ae0 100644
> --- a/drivers/gpu/drm/drm_panic.c
> +++ b/drivers/gpu/drm/drm_panic.c
[ ... ]
> @@ -574,6 +575,10 @@ static void draw_panic_screen_kmsg(struct drm_scanout_buffer *sb)
>  		char *start;
>  		char *end;
>  
> +		/* a record that does not fit comes back empty, every time */
> +		if (!kmsg_len)
> +			break;
> +
>  		/* ignore terminating NUL and newline */
>  		start = kmsg_buf + kmsg_len - 2;
>  		end = kmsg_buf + kmsg_len - 1;

[Severity: High]
Does this code underflow the pointer arithmetic if kmsg_len is 1? For
example, an empty printk that just outputs a newline would have a length
of 1, resulting in start pointing to kmsg_buf - 1, which causes undefined
behavior.

Also, looking at the code immediately following this in
draw_panic_screen_kmsg():

    while (start > kmsg_buf && yoffset >= 0) {
        ...

Does the strict inequality prematurely terminate parsing? It appears it
would silently drop 1-char lines. It also seems to skip the first log line of
every kmsg dump chunk, because the loop stops before processing when start
reaches kmsg_buf.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016052722.60051-1-lucid_duck@justthetip.ca?part=1

      parent reply	other threads:[~2026-10-16  5:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  5:27 [PATCH 1/2] drm/panic: Fix kmsg screen hang on a long log line Devin Wittmayer
2026-10-16  5:27 ` [PATCH 2/2] drm/panic: Accept a trailing newline in panic_screen Devin Wittmayer
2026-10-16  7:47   ` Tvrtko Ursulin
2026-10-16  5:39 ` sashiko-bot [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=sashiko-outbox-173828@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lucid_duck@justthetip.ca \
    --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.