From: sashiko-bot@kernel.org
To: "YuanZhe Liu" <25031212351@stu.xidian.edu.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] fbdev: udlfb: drop stale shadow buffer when the framebuffer grows
Date: Fri, 04 Dec 2026 09:22:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-249497@kernel.org> (raw)
In-Reply-To: <20261204090457.7130-2-25031212351@stu.xidian.edu.cn>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] fbdev: udlfb: unsynchronized backing_buffer clear races with
render_hline()
- [Medium] fbdev: udlfb: dlfb_deferred_vfree() on OOM path leaks or pins
shadow buffer
--
commit 8f1d574fcc8d77dc56b4c4144bf3b2dcaee63c24
Author: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
fbdev: udlfb: drop stale shadow buffer when the framebuffer grows
This commit drops dlfb->backing_buffer via dlfb_deferred_vfree() and clears
it to NULL in dlfb_realloc_framebuffer() when a new shadow buffer is not
allocated.
> diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
> index 8b7b4bdac4fbf..917bcef4bb695 100644
> --- a/drivers/video/fbdev/udlfb.c
> +++ b/drivers/video/fbdev/udlfb.c
> @@ -1248,10 +1248,18 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dlfb, struct fb_info *info
> */
> if (shadow)
> new_back = vzalloc(new_len);
> - if (!new_back)
> + if (!new_back) {
> dev_info(info->dev,
> "No shadow/backing buffer allocated\n");
> - else {
> + /*
> + * The old shadow buffer is smaller than the new
> + * framebuffer and can no longer be used for comparing.
> + */
> + if (dlfb->backing_buffer) {
> + dlfb_deferred_vfree(dlfb, dlfb->backing_buffer);
> + dlfb->backing_buffer = NULL;
> + }
[Severity: High]
Can clearing dlfb->backing_buffer without holding dlfb->render_mutex race
with dlfb_render_hline() and cause a NULL pointer dereference?
dlfb_realloc_framebuffer() runs without dlfb->render_mutex, while
dlfb_damage_work() -> dlfb_handle_damage() -> dlfb_render_hline() runs
under dlfb->render_mutex without info->lock. dlfb_render_hline() reads
dlfb->backing_buffer twice without caching it:
CPU0 CPU1
fb_set_var()
dlfb_ops_set_par()
dlfb_realloc_framebuffer()
dlfb_damage_work()
dlfb_handle_damage()
mutex_lock(&dlfb->render_mutex)
dlfb_render_hline()
if (dlfb->backing_buffer)
dlfb->backing_buffer = NULL
back_start = dlfb->backing_buffer
+ byte_offset
dlfb_trim_hline(back_start, ...)
<-- NULL+offset dereference
There is also an out-of-bounds window before dlfb->backing_buffer is
updated: fb_set_var() publishes the larger info->var and
dlfb_realloc_framebuffer() updates info->fix.smem_len before sleeping in
vzalloc(), so concurrent rendering can still index past the smaller buffer.
Updating the buffer pointers under dlfb->render_mutex (nested inside
info->lock, matching dlfb_ops_set_par()) would close both races.
[Severity: Medium]
Can calling dlfb_deferred_vfree() here leak the old dlfb->backing_buffer
under memory pressure?
dlfb_deferred_vfree() allocates a tracking struct with kmalloc_obj() and
returns silently on failure. When !new_back is reached because vzalloc()
failed under memory pressure, kmalloc_obj() can fail too, permanently
leaking the old shadow buffer once dlfb->backing_buffer is cleared.
Even when kmalloc_obj() succeeds, deferring vfree() keeps the unused
shadow buffer pinned until device teardown. Unlike info->screen_buffer,
dlfb->backing_buffer is driver-internal, so synchronizing the swap with
dlfb->render_mutex allows freeing it directly with vfree() after unlocking.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204090457.7130-1-25031212351@stu.xidian.edu.cn?part=1
next prev parent reply other threads:[~2026-12-04 9:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 9:04 [PATCH 0/2] fbdev: fix udlfb shadow buffer and framebuffer registration YuanZhe Liu
2026-12-04 9:04 ` [PATCH 1/2] fbdev: udlfb: drop stale shadow buffer when the framebuffer grows YuanZhe Liu
2026-12-04 9:22 ` sashiko-bot [this message]
2026-12-04 9:04 ` [PATCH 2/2] fbdev: fbmem: don't fail registration when fbcon cannot take over YuanZhe Liu
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-249497@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 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.