From: Tim Michals <tcmichals@gmail.com>
To: yanli.yang@bedmex.com
Cc: zhirun.liu@aicsemi.com, dijia.xu@aicsemi.com,
chunqiu.liu@aicsemi.com, johannes@sipsolutions.net,
kvalo@kernel.org, linux-wireless@vger.kernel.org,
Tim Michals <tcmichals@gmail.com>
Subject: [PATCH RFC v2 1/2] wifi: aic: fix stack buffer overflow in aicbt_patch_info_unpack
Date: Sat, 8 Aug 2026 12:23:04 -0500 [thread overview]
Message-ID: <20260808172305.138690-1-tcmichals@gmail.com> (raw)
During hardware validation of the AIC8800D80 SDIO chipset on real
silicon (Radxa Cubie A5E with Allwinner T527 SoC running Linux 7.1),
unpacking the BT patch table (fw_patch_table_8800d80_u02.bin) caused a
kernel stack protector panic:
Kernel panic - not syncing: stack-protector: Kernel stack is corrupted
in: aicbt_patch_trap_data_load+0xe4/0x110 [aic8800_bsp]
`aicbt_patch_info_unpack()` calculated copy length as:
patch_info->info_len * sizeof(uint32_t) * 2
When reading `fw_patch_table_8800d80_u02.bin`, `info_len` resulted in a
memcpy size exceeding the remaining bounds of the stack-allocated struct
`struct aicbt_patch_info_t patch_info`, overflowing by 4+ bytes.
Fix this by adding explicit bounds checking to `memcpy` in
`aicbt_patch_info_unpack()`, capping `copy_len` to `sizeof(struct
aicbt_patch_info_t) - sizeof(patch_info->info_len)`.
Signed-off-by: Tim Michals <tcmichals@gmail.com>
Tested-by: Tim Michals <tcmichals@gmail.com>
---
drivers/net/wireless/aic/aic8800_bsp/aic_bsp_driver.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/aic/aic8800_bsp/aic_bsp_driver.c b/drivers/net/wireless/aic/aic8800_bsp/aic_bsp_driver.c
index a1b2c3d..e4f5a6b 100644
--- a/drivers/net/wireless/aic/aic8800_bsp/aic_bsp_driver.c
+++ b/drivers/net/wireless/aic/aic8800_bsp/aic_bsp_driver.c
@@ -1148,9 +1148,13 @@ int aicbt_patch_info_unpack(struct aicbt_patch_info_t *patch_info,
if (patch_info->info_len == 0)
return 0;
+ size_t copy_len = patch_info->info_len * sizeof(uint32_t) * 2;
+ size_t max_len = sizeof(struct aicbt_patch_info_t) - sizeof(patch_info->info_len);
+ if (copy_len > max_len)
+ copy_len = max_len;
memcpy(patch_info_array + sizeof(patch_info->info_len),
head_t->data,
- patch_info->info_len * sizeof(uint32_t) * 2);
+ copy_len);
AICWFDBG(LOGDEBUG, "%s adid_addrinf:%x addr_adid:%x \r\n", __func__,
((struct aicbt_patch_info_t *)patch_info_array)->adid_addrinf,
((struct aicbt_patch_info_t *)patch_info_array)->addr_adid);
--
2.43.0
next reply other threads:[~2026-08-08 17:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 17:23 Tim Michals [this message]
2026-08-08 17:23 ` [PATCH RFC v2 2/2] wifi: aic: update cfg80211 API compatibility for modern kernels Tim Michals
2026-08-08 19:01 ` [PATCH RFC v2 1/2] wifi: aic: fix stack buffer overflow in aicbt_patch_info_unpack Johannes Berg
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=20260808172305.138690-1-tcmichals@gmail.com \
--to=tcmichals@gmail.com \
--cc=chunqiu.liu@aicsemi.com \
--cc=dijia.xu@aicsemi.com \
--cc=johannes@sipsolutions.net \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=yanli.yang@bedmex.com \
--cc=zhirun.liu@aicsemi.com \
/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