From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v7 01/12] Revert "backlight: Remove notifier"
Date: Mon, 31 Aug 2026 22:02:03 +0000 [thread overview]
Message-ID: <20260831220204.828DC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831210531.2334221-2-mario.limonciello@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] `backlight_device_get_by_type()` does not take a reference on the returned device pointer, leading to Use-After-Free vulnerabilities in callers.
--
commit 910d8ccf8b36f6154658d6c354c95ebb55830e1d
Author: Mario Limonciello <mario.limonciello@amd.com>
Revert "backlight: Remove notifier"
This reverts commit 5461f3fd74a89757f95f351eb0bc26aafc2a2e91. The
backlight notifier support is needed in order to add backlight control
support into DRM connectors.
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index f29a9ef1052e7..015183d129f96 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
[ ... ]
> @@ -388,6 +408,8 @@ void devm_backlight_device_unregister(struct device *dev,
> struct backlight_device *bd);
> void backlight_force_update(struct backlight_device *bd,
> enum backlight_update_reason reason);
> +int backlight_register_notifier(struct notifier_block *nb);
> +int backlight_unregister_notifier(struct notifier_block *nb);
> struct backlight_device *backlight_device_get_by_name(const char *name);
> struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
[Severity: High]
This is a pre-existing issue, but does backlight_device_get_by_type() need to
increment the reference count of the returned device pointer?
Currently, backlight_device_get_by_type() in
drivers/video/backlight/backlight.c returns a pointer to the backlight
device without taking a reference:
drivers/video/backlight/backlight.c:backlight_device_get_by_type() {
...
mutex_unlock(&backlight_dev_list_mutex);
return found ? bd : NULL;
}
Callers like int3406_thermal_probe() in
drivers/thermal/intel/int340x_thermal/int3406_thermal.c call this and
permanently cache the returned pointer:
bd = backlight_device_get_by_type(BACKLIGHT_RAW);
if (!bd)
return -ENODEV;
d->raw_bd = bd;
Because the reference count is not incremented (for example, via
get_device(&bd->dev)), a concurrent unbind of the raw backlight driver
will unregister and free the backlight device.
The thermal driver remains unaware, and subsequent reads or writes to the
thermal sysfs attributes (such as
/sys/class/thermal/cooling_deviceX/cur_state) will call
int3406_thermal_get_cur_state(), which dereferences the freed pointer
(d->raw_bd->props.brightness).
Could we add get_device() to backlight_device_get_by_type() and update
callers to drop the reference when done?
> int backlight_device_set_brightness(struct backlight_device *bd,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831210531.2334221-1-mario.limonciello@amd.com?part=1
next prev parent reply other threads:[~2026-08-31 22:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 21:05 [PATCH v7 00/12] Add support for a DRM backlight capability Mario Limonciello
2026-08-31 21:05 ` [PATCH v7 01/12] Revert "backlight: Remove notifier" Mario Limonciello
2026-08-31 22:02 ` sashiko-bot [this message]
2026-08-31 21:05 ` [PATCH v7 02/12] backlight: add kernel-internal backlight API Mario Limonciello
2026-08-31 22:11 ` sashiko-bot
2026-08-31 21:05 ` [PATCH v7 03/12] drm/property: add a per-connector luminance flag Mario Limonciello
2026-08-31 21:05 ` [PATCH v7 04/12] drm: add connector backlight (LUMINANCE) infrastructure Mario Limonciello
2026-08-31 22:28 ` sashiko-bot
2026-08-31 21:05 ` [PATCH v7 05/12] drm: add DRM_CLIENT_CAP_LUMINANCE Mario Limonciello
2026-08-31 22:37 ` sashiko-bot
2026-08-31 21:05 ` [PATCH v7 06/12] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-08-31 22:49 ` sashiko-bot
2026-08-31 21:05 ` [PATCH v7 07/12] drm/amd: Indicate driver supports luminance Mario Limonciello
2026-08-31 21:05 ` [PATCH v7 08/12] drm/amd/display: use drm backlight Mario Limonciello
2026-08-31 23:12 ` sashiko-bot
2026-08-31 21:05 ` [PATCH v7 09/12] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello
2026-08-31 23:24 ` sashiko-bot
2026-08-31 21:05 ` [PATCH v7 10/12] drm/xe: Indicate support for luminance on the connector Mario Limonciello
2026-08-31 23:30 ` sashiko-bot
2026-08-31 21:05 ` [PATCH v7 11/12] drm/i915: " Mario Limonciello
2026-08-31 21:05 ` [PATCH v7 12/12] drm/i915/display: use drm backlight Mario Limonciello
2026-08-31 23:55 ` sashiko-bot
2026-09-01 0:19 ` [PATCH v7 00/12] Add support for a DRM backlight capability Mario Limonciello
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=20260831220204.828DC1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=mario.limonciello@amd.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