From: sashiko-bot@kernel.org
To: "YuanZhe Liu" <25031212351@stu.xidian.edu.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 1/2] fbdev: udlfb: fix shadow buffer handling when the framebuffer grows
Date: Fri, 04 Dec 2026 16:28:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-250187@kernel.org> (raw)
In-Reply-To: <20261204160835.16470-1-25031212351@stu.xidian.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] fbdev: udlfb: TOCTOU race on fix.line_length bypasses damage
bounds check
--
commit 6373d803390e810d07fa3293f989ab90570a3e4c
Author: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
fbdev: udlfb: fix shadow buffer handling when the framebuffer grows
This commit allocates the new shadow buffer before publishing the new
framebuffer and geometry under dlfb->render_mutex, frees the old shadow
buffer directly, and adds a bounds check against info->fix.smem_len in
dlfb_handle_damage().
> diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
> index 8b7b4bdac4fbf..66d30cdfbe606 100644
> --- a/drivers/video/fbdev/udlfb.c
> +++ b/drivers/video/fbdev/udlfb.c
> @@ -646,6 +646,18 @@ static int dlfb_handle_damage(struct dlfb_data *dlfb, int x, int y, int width, i
> goto unlock_ret;
> }
>
> + /*
> + * info->var can describe the new mode before dlfb_ops_set_par()
> + * installs the matching framebuffer. Reject damage that does not
> + * fit into the framebuffer that is currently installed.
> + */
> + if (height > 0 &&
> + ((u64)y + height - 1) * dlfb->info->fix.line_length +
> + (u64)(x + width) * BPP > dlfb->info->fix.smem_len) {
> + ret = -EINVAL;
> + goto unlock_ret;
> + }
[Severity: High]
Can a concurrent update to info->fix.line_length bypass this bounds check?
dlfb_ops_set_par() updates info->fix.line_length without holding
dlfb->render_mutex, while dlfb_handle_damage() reloads
dlfb->info->fix.line_length on every scanline iteration across sleepable
dlfb_get_urb() calls:
CPU0 (dlfb_damage_work) CPU1 (FBIOPUT_VSCREENINFO)
dlfb_handle_damage()
mutex_lock(&dlfb->render_mutex)
bounds check (old line_length)
dlfb_get_urb() (sleeps)
dlfb_ops_set_par()
dlfb_realloc_framebuffer()
(new_len <= old_len, skips lock)
info->fix.line_length = new_stride
for (i = y; i < y + height; i++)
line_offset = line_length * i
dlfb_render_hline()
dlfb_compress_hline() <-- out-of-bounds read/write
When switching to a wider, shorter mode that fits in the existing
allocation, dlfb_realloc_framebuffer() skips dlfb->render_mutex, and
dlfb_damage_work() runs without info->lock.
Once info->fix.line_length grows mid-loop, dlfb_compress_hline() reads
past info->fix.smem_start and writes past dlfb->backing_buffer, which can
oops or corrupt adjacent vmalloc allocations.
Updating info->fix.line_length under dlfb->render_mutex in
dlfb_ops_set_par() and snapshotting line_length locally in
dlfb_handle_damage() would close this race.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204093601.9900-1-25031212351@stu.xidian.edu.cn?part=1
prev parent reply other threads:[~2026-12-04 16:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 9:35 [PATCH v2 0/2] fbdev: fix udlfb shadow buffer and framebuffer registration YuanZhe Liu
2026-12-04 16:08 ` [PATCH v2 1/2] fbdev: udlfb: fix shadow buffer handling when the framebuffer grows YuanZhe Liu
2026-12-04 16:08 ` [PATCH v2 2/2] fbdev: fbmem: don't fail registration when fbcon cannot take over YuanZhe Liu
2026-12-04 16:44 ` sashiko-bot
2026-12-04 16:28 ` 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-250187@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=25031212351@stu.xidian.edu.cn \
--cc=dri-devel@lists.freedesktop.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox