From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 751A9244693; Tue, 11 Nov 2025 00:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762822138; cv=none; b=eoMgPagqG1AU7rgPNe2fZA5X/O3i6ZSZdfeYEQQXX6lOp5+tLuP96nth/2YbnMJZ7249NGsTft0klVkxWFPmopnb72y4tCmVYE/slJ6K8MTikMJ1Vc1UMRAsW3V3a/5MNVOGqu9rJZlCRi3ECIoF8Ou8ib1Wu1++Hgtkr8ujGAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762822138; c=relaxed/simple; bh=CQI1mBdQW7QVjMRKou0ZvnROBbcIpjcuHEXqF/rdqRE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qwxxy9uCoYSHlNCIeRFMf7/haJb/4CzAnTfSVvmQY0EkhnU6pN4nSutZrxIhBlYf5CArRt756xx949i47kFWjhsnt4JrV9V5hyVp8Vxo3JV4Y85d8lGliXT11TWxktuwZCcPDx2644boQ9V2Wn5ScCsM1S0Lcrt7/OTRnnWDy4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XGAWmiwM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XGAWmiwM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EBE8C19425; Tue, 11 Nov 2025 00:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1762822138; bh=CQI1mBdQW7QVjMRKou0ZvnROBbcIpjcuHEXqF/rdqRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XGAWmiwMW3/Hn7Bv5un3KsMuK7v1lhK+i9ar9l0b3S3t2LJDGHk1nMXi91KbZ9w7O SQvsOth8kvK7O4bCitbsZm0qbCQIUs7zkVtO+l/mwld8X6b78xmPVc+0gfEpyhBXZO yxMEzzLWt8Lg97flQM6DeQ1fbVBbyZGkc3CW+iu4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Hans de Goede , "Rafael J. Wysocki" Subject: [PATCH 6.17 009/849] ACPI: video: Fix use-after-free in acpi_video_switch_brightness() Date: Tue, 11 Nov 2025 09:32:59 +0900 Message-ID: <20251111004536.689255773@linuxfoundation.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251111004536.460310036@linuxfoundation.org> References: <20251111004536.460310036@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yuhao Jiang commit 8f067aa59430266386b83c18b983ca583faa6a11 upstream. The switch_brightness_work delayed work accesses device->brightness and device->backlight, freed by acpi_video_dev_unregister_backlight() during device removal. If the work executes after acpi_video_bus_unregister_backlight() frees these resources, it causes a use-after-free when acpi_video_switch_brightness() dereferences device->brightness or device->backlight. Fix this by calling cancel_delayed_work_sync() for each device's switch_brightness_work in acpi_video_bus_remove_notify_handler() after removing the notify handler that queues the work. This ensures the work completes before the memory is freed. Fixes: 8ab58e8e7e097 ("ACPI / video: Fix backlight taking 2 steps on a brightness up/down keypress") Cc: All applicable Signed-off-by: Yuhao Jiang Reviewed-by: Hans de Goede [ rjw: Changelog edit ] Link: https://patch.msgid.link/20251022200704.2655507-1-danisjiang@gmail.com Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/acpi_video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1959,8 +1959,10 @@ static void acpi_video_bus_remove_notify struct acpi_video_device *dev; mutex_lock(&video->device_list_lock); - list_for_each_entry(dev, &video->video_device_list, entry) + list_for_each_entry(dev, &video->video_device_list, entry) { acpi_video_dev_remove_notify_handler(dev); + cancel_delayed_work_sync(&dev->switch_brightness_work); + } mutex_unlock(&video->device_list_lock); acpi_video_bus_stop_devices(video);