* [PATCH] platform/chrome: wilco_ec: Reject out-of-bounds property length
@ 2026-11-18 10:15 Maoyi Xie
0 siblings, 0 replies; only message in thread
From: Maoyi Xie @ 2026-11-18 10:15 UTC (permalink / raw)
To: Tzung-Bi Shih, Benson Leung; +Cc: chrome-platform, linux-kernel, stable
wilco_ec_get_property() copies rs.length bytes from rs.data into
prop_msg->data without checking rs.length, which comes from the EC.
Both buffers hold WILCO_EC_PROPERTY_MAX_SIZE (4) bytes, so a larger
length reads past rs on the stack and writes past the caller's message.
Return -EBADMSG for such a length, as the file does for other bad
responses.
Found with a CodeQL-based static analysis tool that we are developing.
I used an LLM to help write this patch and a userspace harness. The
harness runs the unmodified properties.c against a model of the EC
under AddressSanitizer. It reports the copy for lengths 5 to 255, and
nothing with this patch. Not tested on hardware, only compile-tested
with W=1.
Fixes: 0c0b7ea23aed ("platform/chrome: wilco_ec: Add property helper library")
Cc: stable@vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
drivers/platform/chrome/wilco_ec/properties.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/platform/chrome/wilco_ec/properties.c b/drivers/platform/chrome/wilco_ec/properties.c
index 9951c8db04da065..4ca7e874804c28e 100644
--- a/drivers/platform/chrome/wilco_ec/properties.c
+++ b/drivers/platform/chrome/wilco_ec/properties.c
@@ -70,6 +70,8 @@ int wilco_ec_get_property(struct wilco_ec_device *ec,
ret = send_property_msg(ec, &rq, &rs);
if (ret < 0)
return ret;
+ if (rs.length > WILCO_EC_PROPERTY_MAX_SIZE)
+ return -EBADMSG;
prop_msg->length = rs.length;
memcpy(prop_msg->data, rs.data, rs.length);
base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-18 10:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 10:15 [PATCH] platform/chrome: wilco_ec: Reject out-of-bounds property length Maoyi Xie
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®