* FAILED: patch "[PATCH] platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()" failed to apply to 5.10-stable tree
@ 2026-11-07 11:21 Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 1/4] platform/x86: hp-wmi: rename "thermal policy" to "thermal profile" Sasha Levin
0 siblings, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2026-11-07 11:21 UTC (permalink / raw)
To: meatuni001, ilpo.jarvinen; +Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 6dea092b261f04d632411c2be52d13190f5f67b1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '20261107062147-failed-5.10-6dea092b261f@kernel.org' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 6dea092b261f04d632411c2be52d13190f5f67b1 Mon Sep 17 00:00:00 2001
From: Muhammad Bilal <meatuni001@gmail.com>
Date: Wed, 26 Aug 2026 15:30:12 +0500
Subject: [PATCH] platform/x86: hp-wmi: fix heap OOB read and memory corruption
in hp_wmi_perform_query()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
hp_wmi_perform_query() evaluates an ACPI WMI method and expects a
struct bios_return header in the returned buffer. However, it only
checks that the ACPI object type is ACPI_TYPE_BUFFER without verifying
that obj->buffer.length is at least sizeof(*bios_return) (8 bytes).
If the firmware or ACPI method returns a buffer shorter than 8 bytes:
1. bios_return->return_code at offset 4 reads out of bounds from the
allocated ACPI buffer slab.
2. If return_code evaluates to 0 and outsize is non-zero,
(int)(obj->buffer.length - sizeof(*bios_return)) evaluates to a
negative integer (e.g. -8 for a 0-length buffer). actual_outsize is
set to this negative value and passed to memcpy(buffer, ...,
actual_outsize), where the signed negative value is cast to
size_t (e.g. 0xfffffffffffffff8), attempting to copy ~18 Exabytes
and triggering an immediate kernel crash. Additionally,
memset(buffer + actual_outsize, ...) performs an out-of-bounds
write before buffer.
Fix this by ensuring obj->buffer.length is at least sizeof(*bios_return)
before accessing the return code, and compute actual_outsize safely
using min_t(u32, ...), which is sound specifically because the guard
above already rules out obj->buffer.length being smaller than
sizeof(*bios_return) by the time that subtraction runs.
Fixes: c3021ea1beee ("hp-wmi: allow setting input and output buffer sizes separately")
Cc: stable@vger.kernel.org
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
Link: https://patch.msgid.link/20260826103012.240453-1-meatuni001@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/platform/x86/hp/hp-wmi.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index bc2ada5dfa634..eeb66a7db346a 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -711,8 +711,9 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
goto out_free;
}
- if (obj->type != ACPI_TYPE_BUFFER) {
- pr_warn("query 0x%x returned an invalid object 0x%x\n", query, ret);
+ if (obj->type != ACPI_TYPE_BUFFER ||
+ obj->buffer.length < sizeof(*bios_return)) {
+ pr_warn("query 0x%x returned wrong type or too small buffer\n", query);
ret = -EINVAL;
goto out_free;
}
@@ -731,7 +732,7 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
if (!outsize)
goto out_free;
- actual_outsize = min(outsize, (int)(obj->buffer.length - sizeof(*bios_return)));
+ actual_outsize = min_t(u32, outsize, obj->buffer.length - sizeof(*bios_return));
memcpy(buffer, obj->buffer.pointer + sizeof(*bios_return), actual_outsize);
memset(buffer + actual_outsize, 0, outsize - actual_outsize);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 1/4] platform/x86: hp-wmi: rename "thermal policy" to "thermal profile"
2026-11-07 11:21 FAILED: patch "[PATCH] platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()" failed to apply to 5.10-stable tree Sasha Levin
@ 2026-11-11 3:49 ` Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 2/4] platform/x86: Rename hp-wireless to wireless-hotkey Sasha Levin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sasha Levin @ 2026-11-11 3:49 UTC (permalink / raw)
To: stable; +Cc: Elia Devito, Hans de Goede, Sasha Levin
From: Elia Devito <eliadevito@gmail.com>
[ Upstream commit d7da7534272f7b42629042a5b6fa51debca9201e ]
rename "thermal policy" with the more appropriate term "thermal profile"
Signed-off-by: Elia Devito <eliadevito@gmail.com>
Link: https://lore.kernel.org/r/20210221210256.68198-1-eliadevito@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Stable-dep-of: 6dea092b261f ("platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/platform/x86/hp-wmi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 6642d09b17b55..370f74fa4a9ab 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -87,7 +87,7 @@ enum hp_wmi_commandtype {
HPWMI_FEATURE2_QUERY = 0x0d,
HPWMI_WIRELESS2_QUERY = 0x1b,
HPWMI_POSTCODEERROR_QUERY = 0x2a,
- HPWMI_THERMAL_POLICY_QUERY = 0x4c,
+ HPWMI_THERMAL_PROFILE_QUERY = 0x4c,
};
enum hp_wmi_command {
@@ -875,19 +875,19 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
return err;
}
-static int thermal_policy_setup(struct platform_device *device)
+static int thermal_profile_setup(struct platform_device *device)
{
int err, tp;
- tp = hp_wmi_read_int(HPWMI_THERMAL_POLICY_QUERY);
+ tp = hp_wmi_read_int(HPWMI_THERMAL_PROFILE_QUERY);
if (tp < 0)
return tp;
/*
- * call thermal policy write command to ensure that the firmware correctly
+ * call thermal profile write command to ensure that the firmware correctly
* sets the OEM variables for the DPTF
*/
- err = hp_wmi_perform_query(HPWMI_THERMAL_POLICY_QUERY, HPWMI_WRITE, &tp,
+ err = hp_wmi_perform_query(HPWMI_THERMAL_PROFILE_QUERY, HPWMI_WRITE, &tp,
sizeof(tp), 0);
if (err)
return err;
@@ -914,7 +914,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
hp_wmi_rfkill2_setup(device);
}
- thermal_policy_setup(device);
+ thermal_profile_setup(device);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 2/4] platform/x86: Rename hp-wireless to wireless-hotkey
2026-11-11 3:49 ` [PATCH 5.10.y 1/4] platform/x86: hp-wmi: rename "thermal policy" to "thermal profile" Sasha Levin
@ 2026-11-11 3:49 ` Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 3/4] platform/x86: Move existing HP drivers to a new hp subdir Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 4/4] platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query() Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2026-11-11 3:49 UTC (permalink / raw)
To: stable; +Cc: Mario Limonciello, Hans de Goede, Sasha Levin
From: Mario Limonciello <mario.limonciello@amd.com>
[ Upstream commit a558ea42c0decd088df1950bb232ac2257929281 ]
This driver was originally intended to support some HP laptops, but
later support was added for Xioami and AMD laptops.
Rename it to make it clear that it supports a larger variety of
systems.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20210519174405.30155-1-mario.limonciello@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Stable-dep-of: 6dea092b261f ("platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/platform/x86/Kconfig | 9 ++-
drivers/platform/x86/Makefile | 2 +-
drivers/platform/x86/hp-wireless.c | 102 ------------------------
drivers/platform/x86/wireless-hotkey.c | 103 +++++++++++++++++++++++++
4 files changed, 109 insertions(+), 107 deletions(-)
delete mode 100644 drivers/platform/x86/hp-wireless.c
create mode 100644 drivers/platform/x86/wireless-hotkey.c
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index c14c145b88d80..b7bbe97b727eb 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -530,16 +530,17 @@ config HP_ACCEL
To compile this driver as a module, choose M here: the module will
be called hp_accel.
-config HP_WIRELESS
- tristate "HP wireless button"
+config WIRELESS_HOTKEY
+ tristate "Wireless hotkey button"
depends on ACPI
depends on INPUT
help
- This driver provides supports for new HP wireless button for Windows 8.
+ This driver provides supports for the wireless buttons found on some AMD,
+ HP, & Xioami laptops.
On such systems the driver should load automatically (via ACPI alias).
To compile this driver as a module, choose M here: the module will
- be called hp-wireless.
+ be called wireless-hotkey.
config HP_WMI
tristate "HP WMI extras"
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 5f823f7eff452..5779c9a061384 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -58,7 +58,6 @@ obj-$(CONFIG_GPD_POCKET_FAN) += gpd-pocket-fan.o
# Hewlett Packard
obj-$(CONFIG_HP_ACCEL) += hp_accel.o
-obj-$(CONFIG_HP_WIRELESS) += hp-wireless.o
obj-$(CONFIG_HP_WMI) += hp-wmi.o
obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
@@ -124,6 +123,7 @@ obj-$(CONFIG_TOPSTAR_LAPTOP) += topstar-laptop.o
obj-$(CONFIG_I2C_MULTI_INSTANTIATE) += i2c-multi-instantiate.o
obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o
obj-$(CONFIG_TOUCHSCREEN_DMI) += touchscreen_dmi.o
+obj-$(CONFIG_WIRELESS_HOTKEY) += wireless-hotkey.o
# Intel uncore drivers
obj-$(CONFIG_INTEL_IPS) += intel_ips.o
diff --git a/drivers/platform/x86/hp-wireless.c b/drivers/platform/x86/hp-wireless.c
deleted file mode 100644
index 0753ef18e7211..0000000000000
--- a/drivers/platform/x86/hp-wireless.c
+++ /dev/null
@@ -1,102 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Airplane mode button for HP & Xiaomi laptops
- *
- * Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <linux/platform_device.h>
-#include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Alex Hung");
-MODULE_ALIAS("acpi*:HPQ6001:*");
-MODULE_ALIAS("acpi*:WSTADEF:*");
-MODULE_ALIAS("acpi*:AMDI0051:*");
-
-static struct input_dev *hpwl_input_dev;
-
-static const struct acpi_device_id hpwl_ids[] = {
- {"HPQ6001", 0},
- {"WSTADEF", 0},
- {"AMDI0051", 0},
- {"", 0},
-};
-
-static int hp_wireless_input_setup(void)
-{
- int err;
-
- hpwl_input_dev = input_allocate_device();
- if (!hpwl_input_dev)
- return -ENOMEM;
-
- hpwl_input_dev->name = "HP Wireless hotkeys";
- hpwl_input_dev->phys = "hpq6001/input0";
- hpwl_input_dev->id.bustype = BUS_HOST;
- hpwl_input_dev->evbit[0] = BIT(EV_KEY);
- set_bit(KEY_RFKILL, hpwl_input_dev->keybit);
-
- err = input_register_device(hpwl_input_dev);
- if (err)
- goto err_free_dev;
-
- return 0;
-
-err_free_dev:
- input_free_device(hpwl_input_dev);
- return err;
-}
-
-static void hp_wireless_input_destroy(void)
-{
- input_unregister_device(hpwl_input_dev);
-}
-
-static void hpwl_notify(struct acpi_device *acpi_dev, u32 event)
-{
- if (event != 0x80) {
- pr_info("Received unknown event (0x%x)\n", event);
- return;
- }
-
- input_report_key(hpwl_input_dev, KEY_RFKILL, 1);
- input_sync(hpwl_input_dev);
- input_report_key(hpwl_input_dev, KEY_RFKILL, 0);
- input_sync(hpwl_input_dev);
-}
-
-static int hpwl_add(struct acpi_device *device)
-{
- int err;
-
- err = hp_wireless_input_setup();
- if (err)
- pr_err("Failed to setup hp wireless hotkeys\n");
-
- return err;
-}
-
-static int hpwl_remove(struct acpi_device *device)
-{
- hp_wireless_input_destroy();
- return 0;
-}
-
-static struct acpi_driver hpwl_driver = {
- .name = "hp-wireless",
- .owner = THIS_MODULE,
- .ids = hpwl_ids,
- .ops = {
- .add = hpwl_add,
- .remove = hpwl_remove,
- .notify = hpwl_notify,
- },
-};
-
-module_acpi_driver(hpwl_driver);
diff --git a/drivers/platform/x86/wireless-hotkey.c b/drivers/platform/x86/wireless-hotkey.c
new file mode 100644
index 0000000000000..b010e4ca33831
--- /dev/null
+++ b/drivers/platform/x86/wireless-hotkey.c
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Airplane mode button for AMD, HP & Xiaomi laptops
+ *
+ * Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
+ * Copyright (C) 2021 Advanced Micro Devices
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <acpi/acpi_bus.h>
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Alex Hung");
+MODULE_ALIAS("acpi*:HPQ6001:*");
+MODULE_ALIAS("acpi*:WSTADEF:*");
+MODULE_ALIAS("acpi*:AMDI0051:*");
+
+static struct input_dev *wl_input_dev;
+
+static const struct acpi_device_id wl_ids[] = {
+ {"HPQ6001", 0},
+ {"WSTADEF", 0},
+ {"AMDI0051", 0},
+ {"", 0},
+};
+
+static int wireless_input_setup(void)
+{
+ int err;
+
+ wl_input_dev = input_allocate_device();
+ if (!wl_input_dev)
+ return -ENOMEM;
+
+ wl_input_dev->name = "Wireless hotkeys";
+ wl_input_dev->phys = "hpq6001/input0";
+ wl_input_dev->id.bustype = BUS_HOST;
+ wl_input_dev->evbit[0] = BIT(EV_KEY);
+ set_bit(KEY_RFKILL, wl_input_dev->keybit);
+
+ err = input_register_device(wl_input_dev);
+ if (err)
+ goto err_free_dev;
+
+ return 0;
+
+err_free_dev:
+ input_free_device(wl_input_dev);
+ return err;
+}
+
+static void wireless_input_destroy(void)
+{
+ input_unregister_device(wl_input_dev);
+}
+
+static void wl_notify(struct acpi_device *acpi_dev, u32 event)
+{
+ if (event != 0x80) {
+ pr_info("Received unknown event (0x%x)\n", event);
+ return;
+ }
+
+ input_report_key(wl_input_dev, KEY_RFKILL, 1);
+ input_sync(wl_input_dev);
+ input_report_key(wl_input_dev, KEY_RFKILL, 0);
+ input_sync(wl_input_dev);
+}
+
+static int wl_add(struct acpi_device *device)
+{
+ int err;
+
+ err = wireless_input_setup();
+ if (err)
+ pr_err("Failed to setup hp wireless hotkeys\n");
+
+ return err;
+}
+
+static int wl_remove(struct acpi_device *device)
+{
+ wireless_input_destroy();
+ return 0;
+}
+
+static struct acpi_driver wl_driver = {
+ .name = "wireless-hotkey",
+ .owner = THIS_MODULE,
+ .ids = wl_ids,
+ .ops = {
+ .add = wl_add,
+ .remove = wl_remove,
+ .notify = wl_notify,
+ },
+};
+
+module_acpi_driver(wl_driver);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 3/4] platform/x86: Move existing HP drivers to a new hp subdir
2026-11-11 3:49 ` [PATCH 5.10.y 1/4] platform/x86: hp-wmi: rename "thermal policy" to "thermal profile" Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 2/4] platform/x86: Rename hp-wireless to wireless-hotkey Sasha Levin
@ 2026-11-11 3:49 ` Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 4/4] platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query() Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2026-11-11 3:49 UTC (permalink / raw)
To: stable; +Cc: Jorge Lopez, Hans de Goede, Sasha Levin
From: Jorge Lopez <jorge.lopez2@hp.com>
[ Upstream commit 6e9b8992b122cb12688bd259fc99e67d1be234eb ]
The purpose of this patch is to provide a central location where all
HP related drivers are found. HP drivers will recide under
drivers/platform/x86/hp directory.
Introduce changes to Kconfig file to list all HP driver under "HP X86
Platform Specific Device Drivers" menu option. Additional changes
include update MAINTAINERS file to indicate hp related drivers new
path.
Signed-off-by: Jorge Lopez <jorge.lopez2@hp.com>
Link: https://lore.kernel.org/r/20221020201033.12790-2-jorge.lopez2@hp.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
HP related drivers are found. HP drivers will reside in the new
subdirectory.
Introduce changes to Kconfig file to list all HP driver under "HP X86
Platform Specific Device Drivers" menu option. Additional changes
include update MAINTAINERS file to indicate hp related drivers new
path.
Keep the existing HP WMI configuration requirements: platform profile
and hardware monitoring support are not present in this driver.
Include the missing-object cleanup branch and invalid-object diagnostic
from the later query implementation so the subsequent buffer bounds
check applies without pulling in the unrelated buffer allocation changes.
Stable-dep-of: 6dea092b261f ("platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
MAINTAINERS | 4 +-
drivers/platform/x86/Kconfig | 41 +--------------
drivers/platform/x86/Makefile | 4 +-
drivers/platform/x86/hp/Kconfig | 61 ++++++++++++++++++++++
drivers/platform/x86/hp/Makefile | 10 ++++
drivers/platform/x86/{ => hp}/hp-wmi.c | 7 ++-
drivers/platform/x86/{ => hp}/hp_accel.c | 2 +-
drivers/platform/x86/{ => hp}/tc1100-wmi.c | 0
8 files changed, 81 insertions(+), 48 deletions(-)
create mode 100644 drivers/platform/x86/hp/Kconfig
create mode 100644 drivers/platform/x86/hp/Makefile
rename drivers/platform/x86/{ => hp}/hp-wmi.c (99%)
rename drivers/platform/x86/{ => hp}/hp_accel.c (99%)
rename drivers/platform/x86/{ => hp}/tc1100-wmi.c (100%)
diff --git a/MAINTAINERS b/MAINTAINERS
index beaa5f6294bd2..81bab641d84f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8028,7 +8028,7 @@ F: drivers/net/wireless/intersil/hostap/
HP COMPAQ TC1100 TABLET WMI EXTRAS DRIVER
L: platform-driver-x86@vger.kernel.org
S: Orphan
-F: drivers/platform/x86/tc1100-wmi.c
+F: drivers/platform/x86/hp/tc1100-wmi.c
HPET: High Precision Event Timers driver
M: Clemens Ladisch <clemens@ladisch.de>
@@ -10159,7 +10159,7 @@ M: Eric Piel <eric.piel@tremplin-utc.net>
S: Maintained
F: Documentation/misc-devices/lis3lv02d.rst
F: drivers/misc/lis3lv02d/
-F: drivers/platform/x86/hp_accel.c
+F: drivers/platform/x86/hp/hp_accel.c
LIST KUNIT TEST
M: David Gow <davidgow@google.com>
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index b7bbe97b727eb..7555bb0eb6a0f 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -511,24 +511,7 @@ config GPD_POCKET_FAN
of the CPU temperature. Say Y or M if the kernel may be used on a
GPD pocket.
-config HP_ACCEL
- tristate "HP laptop accelerometer"
- depends on INPUT && ACPI
- depends on SERIO_I8042
- select SENSORS_LIS3LV02D
- select NEW_LEDS
- select LEDS_CLASS
- help
- This driver provides support for the "Mobile Data Protection System 3D"
- or "3D DriveGuard" feature of HP laptops. On such systems the driver
- should load automatically (via ACPI alias).
-
- Support for a led indicating disk protection will be provided as
- hp::hddprotect. For more information on the feature, refer to
- Documentation/misc-devices/lis3lv02d.rst.
-
- To compile this driver as a module, choose M here: the module will
- be called hp_accel.
+source "drivers/platform/x86/hp/Kconfig"
config WIRELESS_HOTKEY
tristate "Wireless hotkey button"
@@ -542,28 +525,6 @@ config WIRELESS_HOTKEY
To compile this driver as a module, choose M here: the module will
be called wireless-hotkey.
-config HP_WMI
- tristate "HP WMI extras"
- depends on ACPI_WMI
- depends on INPUT
- depends on RFKILL || RFKILL = n
- select INPUT_SPARSEKMAP
- help
- Say Y here if you want to support WMI-based hotkeys on HP laptops and
- to read data from WMI such as docking or ambient light sensor state.
-
- To compile this driver as a module, choose M here: the module will
- be called hp-wmi.
-
-config TC1100_WMI
- tristate "HP Compaq TC1100 Tablet WMI Extras"
- depends on !X86_64
- depends on ACPI
- depends on ACPI_WMI
- help
- This is a driver for the WMI extensions (wireless and bluetooth power
- control) of the HP Compaq TC1100 tablet.
-
config IBM_RTL
tristate "Device driver to enable PRTL support"
depends on PCI
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 5779c9a061384..4aa356a431668 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -57,9 +57,7 @@ obj-$(CONFIG_FUJITSU_TABLET) += fujitsu-tablet.o
obj-$(CONFIG_GPD_POCKET_FAN) += gpd-pocket-fan.o
# Hewlett Packard
-obj-$(CONFIG_HP_ACCEL) += hp_accel.o
-obj-$(CONFIG_HP_WMI) += hp-wmi.o
-obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
+obj-$(CONFIG_X86_PLATFORM_DRIVERS_HP) += hp/
# IBM Thinkpad and Lenovo
obj-$(CONFIG_IBM_RTL) += ibm_rtl.o
diff --git a/drivers/platform/x86/hp/Kconfig b/drivers/platform/x86/hp/Kconfig
new file mode 100644
index 0000000000000..5f0f55dbf34bd
--- /dev/null
+++ b/drivers/platform/x86/hp/Kconfig
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# X86 Platform Specific Drivers
+#
+menuconfig X86_PLATFORM_DRIVERS_HP
+ bool "HP X86 Platform Specific Device Drivers"
+ depends on X86_PLATFORM_DEVICES
+ help
+ Say Y here to get to see options for device drivers for various
+ HP x86 platforms, including vendor-specific laptop extension drivers.
+ This option alone does not add any kernel code.
+
+ If you say N, all options in this submenu will be skipped and disabled.
+
+if X86_PLATFORM_DRIVERS_HP
+
+config HP_ACCEL
+ tristate "HP laptop accelerometer"
+ default m
+ depends on INPUT && ACPI
+ depends on SERIO_I8042
+ select SENSORS_LIS3LV02D
+ select NEW_LEDS
+ select LEDS_CLASS
+ help
+ This driver provides support for the "Mobile Data Protection System 3D"
+ or "3D DriveGuard" feature of HP laptops. On such systems the driver
+ should load automatically (via ACPI alias).
+
+ Support for a led indicating disk protection will be provided as
+ hp::hddprotect. For more information on the feature, refer to
+ Documentation/misc-devices/lis3lv02d.rst.
+
+ To compile this driver as a module, choose M here: the module will
+ be called hp_accel.
+
+config HP_WMI
+ tristate "HP WMI extras"
+ default m
+ depends on ACPI_WMI
+ depends on INPUT
+ depends on RFKILL || RFKILL = n
+ select INPUT_SPARSEKMAP
+ help
+ Say Y here if you want to support WMI-based hotkeys on HP laptops and
+ to read data from WMI such as docking or ambient light sensor state.
+
+ To compile this driver as a module, choose M here: the module will
+ be called hp-wmi.
+
+config TC1100_WMI
+ tristate "HP Compaq TC1100 Tablet WMI Extras"
+ default m
+ depends on !X86_64
+ depends on ACPI
+ depends on ACPI_WMI
+ help
+ This is a driver for the WMI extensions (wireless and bluetooth power
+ control) of the HP Compaq TC1100 tablet.
+
+endif # X86_PLATFORM_DRIVERS_HP
diff --git a/drivers/platform/x86/hp/Makefile b/drivers/platform/x86/hp/Makefile
new file mode 100644
index 0000000000000..db1eed4cd7c7d
--- /dev/null
+++ b/drivers/platform/x86/hp/Makefile
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for linux/drivers/platform/x86/hp
+# HP x86 Platform-Specific Drivers
+#
+
+# Hewlett Packard
+obj-$(CONFIG_HP_ACCEL) += hp_accel.o
+obj-$(CONFIG_HP_WMI) += hp-wmi.o
+obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
similarity index 99%
rename from drivers/platform/x86/hp-wmi.c
rename to drivers/platform/x86/hp/hp-wmi.c
index 370f74fa4a9ab..140a5f797980d 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -241,10 +241,13 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
obj = output.pointer;
- if (!obj)
- return -EINVAL;
+ if (!obj) {
+ ret = -EINVAL;
+ goto out_free;
+ }
if (obj->type != ACPI_TYPE_BUFFER) {
+ pr_warn("query 0x%x returned an invalid object 0x%x\n", query, ret);
ret = -EINVAL;
goto out_free;
}
diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp/hp_accel.c
similarity index 99%
rename from drivers/platform/x86/hp_accel.c
rename to drivers/platform/x86/hp/hp_accel.c
index 0dfaa1a43b674..823ea56bf778c 100644
--- a/drivers/platform/x86/hp_accel.c
+++ b/drivers/platform/x86/hp/hp_accel.c
@@ -26,7 +26,7 @@
#include <linux/acpi.h>
#include <linux/i8042.h>
#include <linux/serio.h>
-#include "../../misc/lis3lv02d/lis3lv02d.h"
+#include "../../../misc/lis3lv02d/lis3lv02d.h"
#define DRIVER_NAME "hp_accel"
#define ACPI_MDPS_CLASS "accelerometer"
diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/hp/tc1100-wmi.c
similarity index 100%
rename from drivers/platform/x86/tc1100-wmi.c
rename to drivers/platform/x86/hp/tc1100-wmi.c
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 4/4] platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()
2026-11-11 3:49 ` [PATCH 5.10.y 1/4] platform/x86: hp-wmi: rename "thermal policy" to "thermal profile" Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 2/4] platform/x86: Rename hp-wireless to wireless-hotkey Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 3/4] platform/x86: Move existing HP drivers to a new hp subdir Sasha Levin
@ 2026-11-11 3:49 ` Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2026-11-11 3:49 UTC (permalink / raw)
To: stable; +Cc: Muhammad Bilal, Ilpo Järvinen, Sasha Levin
From: Muhammad Bilal <meatuni001@gmail.com>
[ Upstream commit 6dea092b261f04d632411c2be52d13190f5f67b1 ]
hp_wmi_perform_query() evaluates an ACPI WMI method and expects a
struct bios_return header in the returned buffer. However, it only
checks that the ACPI object type is ACPI_TYPE_BUFFER without verifying
that obj->buffer.length is at least sizeof(*bios_return) (8 bytes).
If the firmware or ACPI method returns a buffer shorter than 8 bytes:
1. bios_return->return_code at offset 4 reads out of bounds from the
allocated ACPI buffer slab.
2. If return_code evaluates to 0 and outsize is non-zero,
(int)(obj->buffer.length - sizeof(*bios_return)) evaluates to a
negative integer (e.g. -8 for a 0-length buffer). actual_outsize is
set to this negative value and passed to memcpy(buffer, ...,
actual_outsize), where the signed negative value is cast to
size_t (e.g. 0xfffffffffffffff8), attempting to copy ~18 Exabytes
and triggering an immediate kernel crash. Additionally,
memset(buffer + actual_outsize, ...) performs an out-of-bounds
write before buffer.
Fix this by ensuring obj->buffer.length is at least sizeof(*bios_return)
before accessing the return code, and compute actual_outsize safely
using min_t(u32, ...), which is sound specifically because the guard
above already rules out obj->buffer.length being smaller than
sizeof(*bios_return) by the time that subtraction runs.
Fixes: c3021ea1beee ("hp-wmi: allow setting input and output buffer sizes separately")
Cc: stable@vger.kernel.org
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
Link: https://patch.msgid.link/20260826103012.240453-1-meatuni001@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/platform/x86/hp/hp-wmi.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 140a5f797980d..c721fcdd2e43c 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -246,8 +246,9 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
goto out_free;
}
- if (obj->type != ACPI_TYPE_BUFFER) {
- pr_warn("query 0x%x returned an invalid object 0x%x\n", query, ret);
+ if (obj->type != ACPI_TYPE_BUFFER ||
+ obj->buffer.length < sizeof(*bios_return)) {
+ pr_warn("query 0x%x returned wrong type or too small buffer\n", query);
ret = -EINVAL;
goto out_free;
}
@@ -266,7 +267,7 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
if (!outsize)
goto out_free;
- actual_outsize = min(outsize, (int)(obj->buffer.length - sizeof(*bios_return)));
+ actual_outsize = min_t(u32, outsize, obj->buffer.length - sizeof(*bios_return));
memcpy(buffer, obj->buffer.pointer + sizeof(*bios_return), actual_outsize);
memset(buffer + actual_outsize, 0, outsize - actual_outsize);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-11 3:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 11:21 FAILED: patch "[PATCH] platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()" failed to apply to 5.10-stable tree Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 1/4] platform/x86: hp-wmi: rename "thermal policy" to "thermal profile" Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 2/4] platform/x86: Rename hp-wireless to wireless-hotkey Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 3/4] platform/x86: Move existing HP drivers to a new hp subdir Sasha Levin
2026-11-11 3:49 ` [PATCH 5.10.y 4/4] platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query() Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox