From: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
To: Kang Chen <k.chen@smail.nju.edu.cn>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Aaron Lu <aaron.lu@intel.com>,
Danny Baumann <dannybaumann@web.de>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ACPI: video: reject out-of-range _BQC indexes
Date: Tue, 10 Nov 2026 18:26:39 +0100 [thread overview]
Message-ID: <CAJZ5v0iCfDR341Barrui1TSiY6o7ePYd2f7aZYXvo3aper2pvA@mail.gmail.com> (raw)
In-Reply-To: <20261103114118.74782-1-k.chen@smail.nju.edu.cn>
On Tue, Nov 3, 2026 at 12:41 PM Kang Chen <k.chen@smail.nju.edu.cn> wrote:
>
> acpi_video_bqc_value_to_level() indexes brightness->levels[] with the
> value returned by _BQC once the index quirk has been armed, but does
> not verify that the value is inside the array. A firmware that behaves
> consistently during the quirk detection and then returns a large value
> can make the driver read out of bounds; the reversed branch also
> underflows before indexing.
>
> Return an invalid level when the index is out of range, so that the
> existing callers disable _BQC. Also guard against a brightness table
> with no usable levels, and tighten the range check in the quirk
> detection before its reversed subtraction.
>
> Fixes: 994fa63c5b12 ("ACPI / video: Fix applying indexed initial brightness value.")
> Signed-off-by: Kang Chen <k.chen@smail.nju.edu.cn>
> ---
> drivers/acpi/acpi_video.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> index 2a2822516665..44af7ffb9a81 100644
> --- a/drivers/acpi/acpi_video.c
> +++ b/drivers/acpi/acpi_video.c
> @@ -533,6 +533,13 @@ acpi_video_bqc_value_to_level(struct acpi_video_device *device,
> * items with special meaning (see enum acpi_video_level_idx),
> * so we need to compensate for that by offsetting ourselves
> */
> + if (device->brightness->count <= ACPI_VIDEO_FIRST_LEVEL)
> + return U64_MAX;
> +
> + if (bqc_value >= device->brightness->count -
> + ACPI_VIDEO_FIRST_LEVEL)
> + return U64_MAX;
> +
> if (device->brightness->flags._BCL_reversed)
> bqc_value = device->brightness->count -
> ACPI_VIDEO_FIRST_LEVEL - 1 - bqc_value;
> @@ -781,7 +788,7 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,
>
> if (level != test_level) {
> /* buggy _BQC found, need to find out if it uses index */
> - if (level < br->count) {
> + if (level < br->count - ACPI_VIDEO_FIRST_LEVEL) {
> if (br->flags._BCL_reversed)
> level = br->count - ACPI_VIDEO_FIRST_LEVEL - 1 - level;
> if (br->levels[level + ACPI_VIDEO_FIRST_LEVEL] == test_level)
> --
Applied as 7.5 material, thanks!
prev parent reply other threads:[~2026-11-10 17:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 11:41 Kang Chen
2026-11-10 17:26 ` Rafael J. Wysocki (Intel) [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=CAJZ5v0iCfDR341Barrui1TSiY6o7ePYd2f7aZYXvo3aper2pvA@mail.gmail.com \
--to=rafael@kernel.org \
--cc=aaron.lu@intel.com \
--cc=dannybaumann@web.de \
--cc=k.chen@smail.nju.edu.cn \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®