[PATCH v4 7/9] platform/x86: hp-bioscfg: validate SPM state returned by firmware

From: Muhammad Bilal

Date: Fri Oct 02 2026 - 15:18:01 EST


status_show() and update_spm_state() use the state byte from firmware
to index 3-entry string arrays without a range check. A value above 2
indexes past the arrays, and the result is printed with %s by the
world-readable status and key_mechanism files.

For example, a state of 3 makes status treat whatever follows
spm_state_types[] as a string pointer.

Return -EIO for an out of range state.

Compile tested only.

Fixes: b2715aa2e135 ("platform/x86: hp-bioscfg: spmobj-attributes")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Muhammad Bilal <meatuni001@xxxxxxxxx>
---
Changes in v4:
- New patch

drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
index 4d94e48c1..f0eb5c445 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
@@ -118,6 +118,9 @@ static ssize_t update_spm_state(void)
if (ret < 0)
return ret;

+ if (data.state >= ARRAY_SIZE(spm_mechanism_types))
+ return -EIO;
+
bioscfg_drv.spm_data.mechanism = data.state;
if (bioscfg_drv.spm_data.mechanism)
bioscfg_drv.spm_data.is_enabled = 1;
@@ -153,6 +156,9 @@ static ssize_t status_show(struct kobject *kobj, struct kobj_attribute
if (ret < 0)
return ret;

+ if (data.state >= ARRAY_SIZE(spm_state_types))
+ return -EIO;
+
/*
* 'status' is a read-only file that returns ASCII text in
* JSON format reporting the status information.
--
2.43.0