From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Tzung-Bi Shih <tzungbi@kernel.org>, Benson Leung <bleung@chromium.org>
Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH] platform/chrome: wilco_ec: Reject out-of-bounds property length
Date: Wed, 18 Nov 2026 18:15:55 +0800 [thread overview]
Message-ID: <20261118101555.3467162-1-maoyixie.tju@gmail.com> (raw)
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
reply other threads:[~2026-11-18 10:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118101555.3467162-1-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®