From: sashiko-bot@kernel.org
To: "Melbin K Mathew" <mlbnkm1@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/2] fbdev: serialize mode sysfs access with lock_fb_info()
Date: Wed, 01 Jul 2026 23:29:55 +0000 [thread overview]
Message-ID: <20260701232956.0B9211F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701231706.234715-3-mlbnkm1@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] fb_info->mode can become a dangling pointer if the active mode is deleted via ioctl(FBIOPUT_VSCREENINFO) with FB_ACTIVATE_INV_MODE, leading to a Use-After-Free in show_mode().
--
commit 243c82e865602245e21ae16b7cdd7738ccfa6a53
Author: Melbin K Mathew <mlbnkm1@gmail.com>
fbdev: serialize mode sysfs access with lock_fb_info()
Take lock_fb_info() in show_mode(), show_modes(), and store_mode() to
serialize with store_modes(). In show_mode(), copy the mode to the
stack and format after dropping the lock. In store_mode(), split
activate() into a _locked variant to avoid double-locking.
> diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
> index af21dc5052df3..d3d60c555bb86 100644
> --- a/drivers/video/fbdev/core/fbsysfs.c
> +++ b/drivers/video/fbdev/core/fbsysfs.c
[ ... ]
> @@ -85,11 +103,20 @@ static ssize_t show_mode(struct device *device, struct device_attribute *attr,
> char *buf)
> {
> struct fb_info *fb_info = dev_get_drvdata(device);
> + struct fb_videomode mode;
> + bool have_mode = false;
>
> - if (!fb_info->mode)
> + lock_fb_info(fb_info);
> + if (fb_info->mode) {
> + mode = *fb_info->mode;
[Severity: High]
This is a pre-existing issue, but can fb_info->mode become a dangling pointer
and lead to a use-after-free here?
If the active mode is deleted via ioctl(FBIOPUT_VSCREENINFO) with
FB_ACTIVATE_INV_MODE, it appears fb_delete_videomode() unlinks and frees
the mode node:
drivers/video/fbdev/core/modedb.c:fb_delete_videomode() {
...
list_del(pos);
kfree(pos);
...
}
However, it does not seem to clear the fb_info->mode reference. If a user
subsequently reads /sys/class/graphics/fb0/mode, would this dereference the
freed memory even while holding the lock?
> + have_mode = true;
> + }
> + unlock_fb_info(fb_info);
> +
> + if (!have_mode)
> return 0;
>
> - return mode_string(buf, PAGE_SIZE, 0, fb_info->mode);
> + return mode_string(buf, PAGE_SIZE, 0, &mode);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701221757.231490-1-mlbnkm1@gmail.com?part=2
prev parent reply other threads:[~2026-07-01 23:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 22:17 [PATCH] fbdev: protect mode sysfs reads with lock_fb_info() Melbin K Mathew
2026-07-01 22:30 ` sashiko-bot
2026-07-01 23:17 ` [PATCH v2 0/2] fbdev: fix mode sysfs lifetime and bounds issues Melbin K Mathew
2026-07-01 23:42 ` [PATCH v3 0/3] " Melbin K Mathew
2026-07-01 23:42 ` [PATCH v3 1/3] fbdev: bound mode sysfs output to the sysfs buffer Melbin K Mathew
2026-07-01 23:54 ` sashiko-bot
2026-07-18 20:04 ` Helge Deller
2026-07-01 23:42 ` [PATCH v3 2/3] fbdev: clear fb_info->mode before deleting a videomode Melbin K Mathew
2026-07-01 23:42 ` [PATCH v3 3/3] fbdev: serialize mode sysfs access with lock_fb_info() Melbin K Mathew
2026-07-01 23:56 ` sashiko-bot
2026-07-02 0:05 ` Melbin K Mathew
2026-07-01 23:17 ` [PATCH v2 1/2] fbdev: bound mode sysfs output to the sysfs buffer Melbin K Mathew
2026-07-01 23:26 ` sashiko-bot
2026-07-01 23:17 ` [PATCH v2 2/2] fbdev: serialize mode sysfs access with lock_fb_info() Melbin K Mathew
2026-07-01 23:29 ` 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=20260701232956.0B9211F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mlbnkm1@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox