* [PATCH v2] platform/x86: asus-wmi: validate custom fan curves on enable
@ 2026-08-31 18:45 Ahmed Yaseen
2026-09-17 10:42 ` Ahmed Yaseen
0 siblings, 1 reply; 4+ messages in thread
From: Ahmed Yaseen @ 2026-08-31 18:45 UTC (permalink / raw)
Cc: platform-driver-x86, linux-kernel, Nir Yehoshua, Ahmed Yaseen
Custom fan curves reach firmware unchecked, so a curve whose temperature
or PWM decreases from one point to the next is accepted. The firmware
does not respect such a curve: a first point of 100% followed by 50%
leaves every point running at 100%. The kernel keeps reporting the
points that were written, so sysfs stops describing what the fans are
actually doing.
Check the curve when enabling and reject it if it is invalid. Validation
is done on enable rather than on write because fan curves are written
one point at a time and are inconsistent mid-write.
Fixes: 0f0ac158d28f ("platform/x86: asus-wmi: Add support for custom fan curves")
Reported-by: Nir Yehoshua <nir@ciphersecuritylabs.com>
Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
---
Changes in v2:
- Rephrased second paragraph of commit message (Ilpo)
- Link to v1: https://patch.msgid.link/20260828160743.31957-1-yaseen@ghoul.dev
---
drivers/platform/x86/asus-wmi.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index a65090429ca7..3b743fec5c64 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3714,6 +3714,33 @@ static int fan_curve_write(struct asus_wmi *asus,
arg1, arg2, arg3, arg4, &ret);
}
+/*
+ * A fan curve is a set of points the firmware interpolates between, so it
+ * only makes sense if neither temperature nor PWM ever decreases along it.
+ */
+static int fan_curve_validate(struct device *dev, struct fan_curve_data *data)
+{
+ u8 *percents = data->percents;
+ u8 *temps = data->temps;
+ int i;
+
+ for (i = 1; i < FAN_CURVE_POINTS; i++) {
+ if (temps[i] < temps[i - 1]) {
+ dev_warn(dev, "fan curve: temperature decreases at point %d (%u < %u)\n",
+ i, temps[i], temps[i - 1]);
+ return -EINVAL;
+ }
+
+ if (percents[i] < percents[i - 1]) {
+ dev_warn(dev, "fan curve: pwm decreases at point %d (%u < %u)\n",
+ i, percents[i], percents[i - 1]);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
static ssize_t fan_curve_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
@@ -3798,6 +3825,11 @@ static ssize_t fan_curve_enable_store(struct device *dev,
}
if (data->enabled) {
+ err = fan_curve_validate(dev, data);
+ if (err) {
+ data->enabled = false;
+ return err;
+ }
err = fan_curve_write(asus, data);
if (err)
return err;
---
base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
change-id: 20260831-fan-curve-validation-991770300ff3
Best regards,
--
Ahmed Yaseen <yaseen@ghoul.dev>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] platform/x86: asus-wmi: validate custom fan curves on enable
2026-08-31 18:45 [PATCH v2] platform/x86: asus-wmi: validate custom fan curves on enable Ahmed Yaseen
@ 2026-09-17 10:42 ` Ahmed Yaseen
0 siblings, 0 replies; 4+ messages in thread
From: Ahmed Yaseen @ 2026-09-17 10:42 UTC (permalink / raw)
Cc: platform-driver-x86, linux-kernel, Nir Yehoshua
Hi, I have come to realize that this was delivered to all of you. This
has no business being here. Apologies.
Cause: b4 reflect misfire
On 8/31/26 23:45, Ahmed Yaseen wrote:
> Custom fan curves reach firmware unchecked, so a curve whose temperature
> or PWM decreases from one point to the next is accepted. The firmware
> does not respect such a curve: a first point of 100% followed by 50%
> leaves every point running at 100%. The kernel keeps reporting the
> points that were written, so sysfs stops describing what the fans are
> actually doing.
>
> Check the curve when enabling and reject it if it is invalid. Validation
> is done on enable rather than on write because fan curves are written
> one point at a time and are inconsistent mid-write.
>
> Fixes: 0f0ac158d28f ("platform/x86: asus-wmi: Add support for custom fan curves")
> Reported-by: Nir Yehoshua <nir@ciphersecuritylabs.com>
> Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
> ---
> Changes in v2:
> - Rephrased second paragraph of commit message (Ilpo)
> - Link to v1: https://patch.msgid.link/20260828160743.31957-1-yaseen@ghoul.dev
> ---
> drivers/platform/x86/asus-wmi.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index a65090429ca7..3b743fec5c64 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -3714,6 +3714,33 @@ static int fan_curve_write(struct asus_wmi *asus,
> arg1, arg2, arg3, arg4, &ret);
> }
>
> +/*
> + * A fan curve is a set of points the firmware interpolates between, so it
> + * only makes sense if neither temperature nor PWM ever decreases along it.
> + */
> +static int fan_curve_validate(struct device *dev, struct fan_curve_data *data)
> +{
> + u8 *percents = data->percents;
> + u8 *temps = data->temps;
> + int i;
> +
> + for (i = 1; i < FAN_CURVE_POINTS; i++) {
> + if (temps[i] < temps[i - 1]) {
> + dev_warn(dev, "fan curve: temperature decreases at point %d (%u < %u)\n",
> + i, temps[i], temps[i - 1]);
> + return -EINVAL;
> + }
> +
> + if (percents[i] < percents[i - 1]) {
> + dev_warn(dev, "fan curve: pwm decreases at point %d (%u < %u)\n",
> + i, percents[i], percents[i - 1]);
> + return -EINVAL;
> + }
> + }
> +
> + return 0;
> +}
> +
> static ssize_t fan_curve_store(struct device *dev,
> struct device_attribute *attr, const char *buf,
> size_t count)
> @@ -3798,6 +3825,11 @@ static ssize_t fan_curve_enable_store(struct device *dev,
> }
>
> if (data->enabled) {
> + err = fan_curve_validate(dev, data);
> + if (err) {
> + data->enabled = false;
> + return err;
> + }
> err = fan_curve_write(asus, data);
> if (err)
> return err;
>
> ---
> base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
> change-id: 20260831-fan-curve-validation-991770300ff3
>
> Best regards,
> --
> Ahmed Yaseen <yaseen@ghoul.dev>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] platform/x86: asus-wmi: validate custom fan curves on enable
@ 2026-08-31 18:48 Ahmed Yaseen
2026-10-05 15:37 ` Ilpo Järvinen
0 siblings, 1 reply; 4+ messages in thread
From: Ahmed Yaseen @ 2026-08-31 18:48 UTC (permalink / raw)
To: Corentin Chary, Luke D. Jones, Denis Benato, Hans de Goede,
Ilpo Järvinen
Cc: platform-driver-x86, linux-kernel, Nir Yehoshua, Ahmed Yaseen
Custom fan curves reach firmware unchecked, so a curve whose temperature
or PWM decreases from one point to the next is accepted. The firmware
does not respect such a curve: a first point of 100% followed by 50%
leaves every point running at 100%. The kernel keeps reporting the
points that were written, so sysfs stops describing what the fans are
actually doing.
Check the curve when enabling and reject it if it is invalid. Validation
is done on enable rather than on write because fan curves are written
one point at a time and are inconsistent mid-write.
Fixes: 0f0ac158d28f ("platform/x86: asus-wmi: Add support for custom fan curves")
Reported-by: Nir Yehoshua <nir@ciphersecuritylabs.com>
Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
---
Changes in v2:
- Rephrased second paragraph of commit message (Ilpo)
- Link to v1: https://patch.msgid.link/20260828160743.31957-1-yaseen@ghoul.dev
---
drivers/platform/x86/asus-wmi.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index a65090429ca7..3b743fec5c64 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3714,6 +3714,33 @@ static int fan_curve_write(struct asus_wmi *asus,
arg1, arg2, arg3, arg4, &ret);
}
+/*
+ * A fan curve is a set of points the firmware interpolates between, so it
+ * only makes sense if neither temperature nor PWM ever decreases along it.
+ */
+static int fan_curve_validate(struct device *dev, struct fan_curve_data *data)
+{
+ u8 *percents = data->percents;
+ u8 *temps = data->temps;
+ int i;
+
+ for (i = 1; i < FAN_CURVE_POINTS; i++) {
+ if (temps[i] < temps[i - 1]) {
+ dev_warn(dev, "fan curve: temperature decreases at point %d (%u < %u)\n",
+ i, temps[i], temps[i - 1]);
+ return -EINVAL;
+ }
+
+ if (percents[i] < percents[i - 1]) {
+ dev_warn(dev, "fan curve: pwm decreases at point %d (%u < %u)\n",
+ i, percents[i], percents[i - 1]);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
static ssize_t fan_curve_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
@@ -3798,6 +3825,11 @@ static ssize_t fan_curve_enable_store(struct device *dev,
}
if (data->enabled) {
+ err = fan_curve_validate(dev, data);
+ if (err) {
+ data->enabled = false;
+ return err;
+ }
err = fan_curve_write(asus, data);
if (err)
return err;
---
base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
change-id: 20260831-fan-curve-validation-991770300ff3
Best regards,
--
Ahmed Yaseen <yaseen@ghoul.dev>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] platform/x86: asus-wmi: validate custom fan curves on enable
2026-08-31 18:48 Ahmed Yaseen
@ 2026-10-05 15:37 ` Ilpo Järvinen
0 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-10-05 15:37 UTC (permalink / raw)
To: Corentin Chary, Luke D. Jones, Denis Benato, Hans de Goede, Ahmed Yaseen
Cc: platform-driver-x86, linux-kernel, Nir Yehoshua
On Mon, 31 Aug 2026 18:48:08 +0000, Ahmed Yaseen wrote:
> Custom fan curves reach firmware unchecked, so a curve whose temperature
> or PWM decreases from one point to the next is accepted. The firmware
> does not respect such a curve: a first point of 100% followed by 50%
> leaves every point running at 100%. The kernel keeps reporting the
> points that were written, so sysfs stops describing what the fans are
> actually doing.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also
fixes are mostly routed through for-next unless the fix is for a
commit introduced in the most recent cycle or is clearly a regression
fix.
The list of commits applied:
[1/1] platform/x86: asus-wmi: validate custom fan curves on enable
commit: ff7edee7842cba8c28845f5a63d2cc7f0e05586d
--
i.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-05 15:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-31 18:45 [PATCH v2] platform/x86: asus-wmi: validate custom fan curves on enable Ahmed Yaseen
2026-09-17 10:42 ` Ahmed Yaseen
2026-08-31 18:48 Ahmed Yaseen
2026-10-05 15:37 ` Ilpo Järvinen
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®