diff options
| author | Maoyi Xie <maoyixie.tju@gmail.com> | 2026-06-25 21:00:56 +0800 |
|---|---|---|
| committer | Tzung-Bi Shih <tzungbi@kernel.org> | 2026-06-29 03:09:51 +0000 |
| commit | a0a8cd9fc9c48b95095bcec4b146f7a99486f58e (patch) | |
| tree | 1629d25e273ca41cb340f626123f575d0e466e3d /lib/stackdepot.c | |
| parent | 10a1e8c3539039c4c9de4783a683e8e01a3dee8d (diff) | |
| download | linux-next-a0a8cd9fc9c48b95095bcec4b146f7a99486f58e.tar.gz linux-next-a0a8cd9fc9c48b95095bcec4b146f7a99486f58e.zip | |
platform/chrome: cros_ec_typec: Reject out-of-bounds PD cap count
cros_typec_register_partner_pdos() copies the partner PDOs from the EC
TYPEC_STATUS response into the fixed caps_desc.pdo[PDO_MAX_OBJECTS] array.
memcpy(caps_desc.pdo, resp->source_cap_pdos,
sizeof(u32) * resp->source_cap_count);
...
memcpy(caps_desc.pdo, resp->sink_cap_pdos,
sizeof(u32) * resp->sink_cap_count);
PDO_MAX_OBJECTS is 7. source_cap_count and sink_cap_count are u8 fields
from the EC. The only check is that they are not both zero. If either is
larger than 7, the memcpy writes past the end of the array on the stack.
A count of 255 overflows it by about 1 KB. The EC source arrays are only
seven entries wide. A larger count reads past them too.
The ChromeOS EC firmware caps these counts today, so a compliant setup
does not hit this. The kernel should still validate these values rather
than trust them.
Validate the counts in cros_typec_register_partner_pdos() next to the
memcpy. Skip the PDO registration if either count is above PDO_MAX_OBJECTS.
The rest of cros_typec_handle_status() still runs so events are handled
and cleared.
Fixes: 348a2e8c93d3 ("platform/chrome: cros_ec_typec: Register partner PDOs")
Suggested-by: Andrei Kuchynski <akuchynski@chromium.org>
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Andrei Kuchynski <akuchynski@chromium.org>
Link: https://lore.kernel.org/r/20260625130056.3378097-1-maoyixie.tju@gmail.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Diffstat (limited to 'lib/stackdepot.c')
0 files changed, 0 insertions, 0 deletions
