* [PATCH] thermal: testing: reject missing command arguments
@ 2026-06-05 18:52 Samuel Moelius
2026-06-08 13:46 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Samuel Moelius @ 2026-06-05 18:52 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Samuel Moelius, Daniel Lezcano, Zhang Rui, Lukasz Luba, Al Viro,
Greg Kroah-Hartman, open list:THERMAL, open list
The thermal testing debugfs command parser splits commands at ':' and
passes the right-hand side to the command implementation. Commands such
as deltz, tzaddtrip, tzreg, and tzunreg require a zone id, but writing
one of those command names without ':' leaves the argument pointer NULL.
The command implementations parse the id with sscanf(arg, "%d", ...), so
the missing-argument form dereferences a NULL pointer from the debugfs
write path.
Reject missing arguments in tt_command_exec() before calling handlers
that require an id.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
drivers/thermal/testing/command.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/thermal/testing/command.c b/drivers/thermal/testing/command.c
index 1159ecea57e7..fbf7ab9729b5 100644
--- a/drivers/thermal/testing/command.c
+++ b/drivers/thermal/testing/command.c
@@ -116,18 +116,30 @@ static int tt_command_exec(int index, const char *arg)
break;
case TT_CMD_DELTZ:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_del_tz(arg);
break;
case TT_CMD_TZADDTRIP:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_zone_add_trip(arg);
break;
case TT_CMD_TZREG:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_zone_reg(arg);
break;
case TT_CMD_TZUNREG:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_zone_unreg(arg);
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thermal: testing: reject missing command arguments
2026-06-05 18:52 [PATCH] thermal: testing: reject missing command arguments Samuel Moelius
@ 2026-06-08 13:46 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2026-06-08 13:46 UTC (permalink / raw)
To: Samuel Moelius
Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Al Viro, Greg Kroah-Hartman, open list:THERMAL, open list
On Fri, Jun 5, 2026 at 8:52 PM Samuel Moelius
<sam.moelius@trailofbits.com> wrote:
>
> The thermal testing debugfs command parser splits commands at ':' and
> passes the right-hand side to the command implementation. Commands such
> as deltz, tzaddtrip, tzreg, and tzunreg require a zone id, but writing
> one of those command names without ':' leaves the argument pointer NULL.
>
> The command implementations parse the id with sscanf(arg, "%d", ...), so
> the missing-argument form dereferences a NULL pointer from the debugfs
> write path.
>
> Reject missing arguments in tt_command_exec() before calling handlers
> that require an id.
>
> Assisted-by: Codex:gpt-5.5-cyber-preview
> Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
> ---
> drivers/thermal/testing/command.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/thermal/testing/command.c b/drivers/thermal/testing/command.c
> index 1159ecea57e7..fbf7ab9729b5 100644
> --- a/drivers/thermal/testing/command.c
> +++ b/drivers/thermal/testing/command.c
> @@ -116,18 +116,30 @@ static int tt_command_exec(int index, const char *arg)
> break;
>
> case TT_CMD_DELTZ:
> + if (!arg || !*arg)
> + return -EINVAL;
> +
> ret = tt_del_tz(arg);
> break;
>
> case TT_CMD_TZADDTRIP:
> + if (!arg || !*arg)
> + return -EINVAL;
> +
> ret = tt_zone_add_trip(arg);
> break;
>
> case TT_CMD_TZREG:
> + if (!arg || !*arg)
> + return -EINVAL;
> +
> ret = tt_zone_reg(arg);
> break;
>
> case TT_CMD_TZUNREG:
> + if (!arg || !*arg)
> + return -EINVAL;
> +
> ret = tt_zone_unreg(arg);
> break;
>
> --
Applied as 7.2 material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-08 13:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-05 18:52 [PATCH] thermal: testing: reject missing command arguments Samuel Moelius
2026-06-08 13:46 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox