From: sashiko-bot@kernel.org
To: "Ramesh Ramalingam" <r-ramalingam@ti.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 12/17] wifi: cc33xx: Add init.c, init.h
Date: Thu, 03 Dec 2026 07:43:19 +0000 [thread overview]
Message-ID: <sashiko-outbox-247315@kernel.org> (raw)
In-Reply-To: <20261203070906.1294171-13-r-ramalingam@ti.com>
Thank you for your contribution! Sashiko AI review found 13 potential
issues to consider:
- [High] wifi: cc33xx: out-of-bounds read past cmd_buf during INI
download
- [High] wifi: cc33xx: target_mem_map leak and IRQ UAF on cc33xx_init()
failure
- [Medium] wifi: cc33xx: leaked partial_rx.skb on recovery reset in
cc33xx_hw_init()
- [Medium] wifi: cc33xx: unchecked cc33xx_init_phy_vif_config() return
value
- [Medium] wifi: cc33xx: missing rollback on cc33xx_init_vif_specific()
failure
- [Medium] wifi: cc33xx: unlocked max_cmd_size race during recovery INI
download
- [Medium] wifi: cc33xx: unlocked RX/TX state reset after IRQ enable in
cc33xx_hw_init()
- [Medium] wifi: cc33xx: slab OOB write in __cc33xx_cmd_send() via
cc33xx_hw_init()
- [Medium] wifi: cc33xx: big-endian double-swap of TX AC params in vif
init
- [Medium] wifi: cc33xx: leak role and rate policies if
cc33xx_init_vif_specific() fails
- [Low] wifi: cc33xx: out-of-bounds pointer arithmetic past scalar
ac_conf0 member
- [Low] wifi: cc33xx: split __free(kfree) declaration and init in INI
download
- [Low] wifi: cc33xx: write-only event_mask update in
cc33xx_init_vif_specific()
--
commit ed1928d83427e6ccca38c2d954901e5f1f86141e
Author: Michael Nemanov <michael.nemanov@ti.com>
wifi: cc33xx: Add init.c, init.h
This commit adds high-level initialization helpers for the cc33xx wireless
driver, covering per-vif firmware configuration, hardware memory map setup,
and INI parameter download.
> diff --git a/drivers/net/wireless/ti/cc33xx/init.c b/drivers/net/wireless/ti/cc33xx/init.c
> new file mode 100644
> index 0000000000000..b0d3f927ebe80
> --- /dev/null
> +++ b/drivers/net/wireless/ti/cc33xx/init.c
[ ... ]
> +int cc33xx_init_vif_specific(struct cc33xx *cc, struct ieee80211_vif *vif)
[Severity: Medium]
When cc33xx_init_vif_specific() returns an error, does the caller leak the
firmware role and rate policies allocated for this vif?
In cc33xx_op_add_interface(), cc33xx_init_vif_data() allocates bits in
cc->rate_policies_map and cc33xx_cmd_role_enable() enables the firmware role
and sets a bit in cc->roles_map before calling cc33xx_init_vif_specific().
On failure, cc33xx_op_add_interface() returns directly without disabling the
role or freeing the rate policies, and mac80211 will not call
remove_interface(). Because cc33xx_cmd_role_enable() enforces a limit of two
active non-device roles, two failed interface additions permanently exhaust
all hardware role slots until recovery or driver reload.
> +{
> + struct cc33xx_vif *wlvif = cc33xx_vif_to_data(vif);
> + struct conf_tx_settings *tx_settings = &cc->conf.host_conf.tx;
> + struct conf_tx_ac_category *conf_ac = &tx_settings->ac_conf0;
> + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
> + u8 ps_scheme = cc->conf.mac.ps_scheme;
> + int ret, i;
> +
> + /* consider all existing roles before configuring psm. */
> +
> + if (cc->ap_count == 0 && is_ap) { /* first AP */
> + ret = cc33xx_acx_sleep_auth(cc, CC33XX_PSM_ELP);
> + if (ret < 0)
> + return ret;
> +
> + /* unmask ap events */
> + cc->event_mask |= cc->ap_event_mask;
[Severity: Medium]
If a later step in cc33xx_init_vif_specific() fails while adding the first AP
vif alongside an active STA vif, does firmware sleep_auth remain stuck at
CC33XX_PSM_ELP?
cc33xx_acx_sleep_auth() overrides the active STA sleep authorization and sets
cc->event_mask |= cc->ap_event_mask before fallible calls such as
cc33xx_init_ap_role() and cc33xx_tx_param_cfg(). Those error paths return
directly without restoring the STA sleep authorization or reverting
cc->event_mask, and because cc33xx_op_add_interface() returns without
registering the vif or incrementing cc->ap_count,
__cc33xx_op_remove_interface() never runs to undo them.
[Severity: Low]
Does updating cc->event_mask here actually unmask any AP events in firmware?
Across drivers/net/wireless/ti/cc33xx/, cc->event_mask is only written (in
cc33xx_setup(), cc33xx_init_vif_specific(), and
__cc33xx_op_remove_interface()) and is never read or sent to firmware.
process_deferred_events() dispatches events such as MAX_TX_FAILURE_EVENT_ID
directly from the firmware event vector, so cc->event_mask,
cc->ap_event_mask, and struct acx_event_mask appear to be unused leftover
code that should either be wired up to a firmware command or removed.
[ ... ]
> + cc33xx_init_phy_vif_config(cc, wlvif);
[Severity: Medium]
Should the return value of cc33xx_init_phy_vif_config() be checked here?
cc33xx_init_phy_vif_config() propagates negative errors from
cc33xx_acx_slot() (such as -ENOMEM or a firmware command failure), so
ignoring the return value leaves the vif slot time unconfigured and continues
sending subsequent ACX commands instead of failing interface setup.
> +
> + /* Default TID/AC configuration */
> + if (WARN_ON(tx_settings->ac_conf_count != tx_settings->tid_conf_count) ||
> + WARN_ON(tx_settings->ac_conf_count != CONF_TX_MAX_AC_COUNT))
> + return -EINVAL;
> +
> + for (i = 0; i < tx_settings->tid_conf_count; i++) {
> + /* If no ps poll is used, send legacy ps scheme in cmd */
> + if (ps_scheme == PS_SCHEME_NOPSPOLL)
> + ps_scheme = PS_SCHEME_LEGACY;
> +
> + ret = cc33xx_tx_param_cfg(cc, wlvif, conf_ac->ac,
> + conf_ac->cw_min, conf_ac->cw_max,
> + conf_ac->aifsn, conf_ac->tx_op_limit,
> + false, ps_scheme, conf_ac->is_mu_edca,
> + conf_ac->mu_edca_aifs,
> + conf_ac->mu_edca_ecw_min_max,
> + conf_ac->mu_edca_timer);
[Severity: Medium]
Does passing conf_ac->cw_max and conf_ac->tx_op_limit directly to
cc33xx_tx_param_cfg() double-swap them on big-endian hosts?
cc->conf stores the raw little-endian binary INI payload (copied verbatim
into cmd->payload in cc33xx_download_ini_params_and_wait()), while
cc33xx_tx_param_cfg() expects host-endian u16 arguments and encodes them with
cpu_to_le16(). On big-endian architectures, this sends byte-swapped cw_max
and tx_op_limit values in TX_PARAMS_CFG.
> +
> + if (ret < 0)
> + return ret;
> +
> + conf_ac++;
[Severity: Low]
Does incrementing conf_ac past tx_settings->ac_conf0 rely on out-of-bounds
pointer arithmetic?
In struct conf_tx_settings, ac_conf0..ac_conf3 are four separate scalar
members rather than an array, so advancing a pointer derived from
&tx_settings->ac_conf0 across CONF_TX_MAX_AC_COUNT iterations is undefined
behavior in C and can trigger -Warray-bounds or CONFIG_UBSAN_BOUNDS.
Declaring ac_conf[CONF_TX_MAX_AC_COUNT] as an array and indexing
tx_settings->ac_conf[i] avoids this.
[ ... ]
> +int cc33xx_hw_init(struct cc33xx *cc)
> +{
> + int ret;
> +
> + cc->last_fw_rls_idx = 0;
> + cc->partial_rx.status = CURR_RX_START;
[Severity: Medium]
Can resetting cc->last_fw_rls_idx and cc->partial_rx.status here race with
cc33xx_irq() and cc33xx_irq_work() because interrupts are already enabled?
cc33xx_init_fw() calls cc33xx_enable_interrupts() (which also invokes
cc33xx_irq() immediately) before calling cc33xx_hw_init(), and
cc33xx_hw_init() writes both fields without holding cc->mutex or
core_status_lock:
CPU0 CPU1 (kworker)
cc33xx_init_fw()
cc33xx_enable_interrupts()
cc33xx_irq()
queue_work(&irq_deferred_work)
cc33xx_hw_init() cc33xx_irq_work()
cc->last_fw_rls_idx = 0; mutex_lock(&cc->mutex)
cc->partial_rx.status = ... cc33xx_rx() / tx_immediate_complete()
reads partial_rx / last_fw_rls_idx
<-- data race
During hardware recovery, cc33xx_turn_off() also leaves cc->last_fw_rls_idx
non-zero, so process_core_status() immediately sees tx_result_queue_index
(0) != cc->last_fw_rls_idx after chip reset and queues irq_deferred_work.
If cc33xx_init_fw() then fails before cc33xx_hw_init(), irq_deferred_work
later runs cc33xx_tx_immediate_complete() on the powered-off chip, hits a
missing tx_frames[] entry, and re-queues recovery_work in a spurious recovery
loop. Resetting both fields before enabling interrupts avoids both issues.
[Severity: Medium]
Does unconditionally resetting cc->partial_rx.status here leak
cc->partial_rx.skb during hardware recovery?
When a multi-transfer RX frame is in progress,
cc33xx_rx_get_packet_descriptor() stores the allocated sk_buff in
cc->partial_rx.skb with status CURR_RX_DATA. If recovery triggers before the
rest of the frame arrives, neither cc33xx_turn_off() nor cc33xx_hw_init()
frees it, so the next received frame overwrites the pointer and leaks the
sk_buff. Because cc33xx_rx_get_packet_data() does not clear
cc->partial_rx.skb to NULL after queuing a completed frame, freeing it must
be guarded by status == CURR_RX_DATA (or rx.c must clear the pointer on
completion) to avoid a double free.
> +
> + ret = cc33xx_acx_init_mem_config(cc);
[Severity: High]
When probe fails after cc33xx_init_fw() succeeds, does cc33xx_init() leak
cc->target_mem_map and leave interrupts enabled against freed memory?
cc33xx_acx_init_mem_config() allocates cc->target_mem_map, which is only
freed in cc33xx_turn_off(). In cc33xx_init(), if read_version_info(),
cc33xx_init_ieee80211(), or cc33xx_register_hw() fails after
cc33xx_init_fw(), control jumps to out_irq without calling cc33xx_turn_off(),
and cc33xx_probe() then calls cc33xx_free_hw(). This leaks
cc->target_mem_map and frees cc->core_status, cc->aggr_buf, and struct cc33xx
while interrupts remain enabled and queued work (such as recovery_work queued
on read_version_info() failure) can still access them, causing a
use-after-free.
[Severity: Medium]
Can the CMD_INTERROGATE response path invoked by cc33xx_acx_init_mem_config()
write up to 8 bytes past the end of cc->target_mem_map?
cc33xx_acx_init_mem_config() passes sizeof(struct cc33xx_acx_mem_map) as
res_len to __cc33xx_cmd_send(), whose bounds check omits the leading
struct nab_header offset used by memcpy():
drivers/net/wireless/ti/cc33xx/cmd.c:__cc33xx_cmd_send() {
...
if (WARN_ON(cc->result_length > res_len)) {
...
memcpy(buf + sizeof(struct nab_header), cc->command_result,
cc->result_length);
...
}
If firmware returns a ctrl_info_length between
res_len - sizeof(struct nab_header) + 1 and res_len, the check passes and
memcpy() overflows the slab buffer by up to 8 bytes.
> +
> + return ret;
> +}
> +
> +int cc33xx_download_ini_params_and_wait(struct cc33xx *cc)
> +{
> + struct cc33xx_cmd_ini_params_download *cmd __free(kfree) = NULL;
[Severity: Low]
This isn't a bug, but kernel Cleanup API convention prefers defining and
initializing __free() variables in a single statement at the allocation site
rather than declaring them as NULL at the top of the function and assigning
them later.
[ ... ]
> + cc33xx_set_max_buffer_size(cc, INI_MAX_BUFFER_SIZE);
[Severity: Medium]
Can modifying cc->max_cmd_size outside cc->cmd_lock race with concurrent
firmware commands during hardware recovery?
During recovery, cc33xx_recovery_work() releases wiphy_lock and calls
cc33xx_turn_off(), which clears cc->flags (including
CC33XX_FLAG_RECOVERY_IN_PROGRESS) before cc33xx_init_fw() invokes
cc33xx_download_ini_params_and_wait(). Because cc33xx_op_add_interface()
does not check cc->state, a concurrent interface addition can submit commands
while cc33xx_set_max_buffer_size() updates cc->max_cmd_size in three unlocked
stores:
CPU0 (recovery_work) CPU1 (nl80211)
cc33xx_turn_off()
cc->flags = 0;
cc33xx_init_fw()
cc33xx_download_ini_params_and_wait()
cc33xx_set_max_buffer_size() cc33xx_op_add_interface()
cc->max_cmd_size = ... ...
cc->max_cmd_size += ... __cc33xx_cmd_send()
reads cc->max_cmd_size
<-- data race
Concurrent command submissions can observe a torn intermediate value or the
elevated INI_MAX_BUFFER_SIZE transfer length and disrupt the firmware command
protocol.
> +
> + cmd->length = cpu_to_le32(sizeof(cc->conf));
> +
> + /* copy INI file params payload */
> + memcpy((cmd->payload), &cc->conf, sizeof(cc->conf));
> +
> + ret = cc33xx_cmd_send(cc, CMD_DOWNLOAD_INI_PARAMS,
> + cmd, command_size, 0);
[Severity: High]
Does sending CMD_DOWNLOAD_INI_PARAMS with INI_MAX_BUFFER_SIZE read out of
bounds past cc->cmd_buf and the end of struct cc33xx?
In cc33xx.h, CC33XX_INI_CMD_MAX_SIZE already includes the 16-byte command
header and 4-byte int, and cc->cmd_buf is sized to CC33XX_CMD_BUFFER_SIZE
(which equals CC33XX_INI_CMD_MAX_SIZE because sizeof(cc->conf) exceeds 896
bytes). However, cc33xx_set_max_buffer_size() adds those 20 bytes a second
time, and send_buffer() aligns cc->max_cmd_size up to a 256-byte boundary
before passing cc->cmd_buf to cc33xx_raw_write():
drivers/net/wireless/ti/cc33xx/cmd.c:cc33xx_set_max_buffer_size() {
...
case INI_MAX_BUFFER_SIZE:
cc->max_cmd_size = CC33XX_INI_CMD_MAX_SIZE;
cc->max_cmd_size += sizeof(struct cc33xx_cmd_ini_params_download);
cc->max_cmd_size += sizeof(u32);
break;
...
}
drivers/net/wireless/ti/cc33xx/cmd.c:send_buffer() {
...
max_cmd_size_align = __ALIGN_MASK(cc->max_cmd_size,
CC33XX_BUS_BLOCK_SIZE * 2 - 1);
return cc33xx_raw_write(cc, cmd_box_addr, cc->cmd_buf,
max_cmd_size_align, true);
}
This reads 20 to 275 bytes past cc->cmd_buf and past the trailing fields of
struct cc33xx on every firmware initialization and recovery, triggering KASAN
slab-out-of-bounds faults and transmitting adjacent kernel heap memory over
SDIO. Additionally, cc->cmd_buf is embedded in struct cc33xx without DMA
cache-line alignment while passed to sdio_writesb(), sharing cache lines with
adjacent fields such as dynamic_fw_traces and extra_spare_key_count.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203070906.1294171-1-r-ramalingam@ti.com?part=12
next prev parent reply other threads:[~2026-12-03 7:43 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 7:08 [PATCH v6 00/17] wifi: cc33xx: Add driver for new TI CC33xx wireless device family Ramesh Ramalingam
2026-12-03 7:08 ` [PATCH v6 01/17] dt-bindings: net: wireless: cc33xx: Add ti,cc33xx.yaml Ramesh Ramalingam
2026-12-03 7:20 ` sashiko-bot
2026-12-03 18:27 ` Rob Herring
2026-12-03 7:08 ` [PATCH v6 02/17] wifi: cc33xx: Add cc33xx.h, cc33xx_i.h Ramesh Ramalingam
2026-12-03 7:31 ` sashiko-bot
2026-12-03 7:08 ` [PATCH v6 03/17] wifi: cc33xx: Add debug.h Ramesh Ramalingam
2026-12-03 7:26 ` sashiko-bot
2026-12-03 7:08 ` [PATCH v6 04/17] wifi: cc33xx: Add sdio.c, io.c, io.h Ramesh Ramalingam
2026-12-03 7:33 ` sashiko-bot
2026-12-03 7:08 ` [PATCH v6 05/17] wifi: cc33xx: Add cmd.c, cmd.h Ramesh Ramalingam
2026-12-03 7:42 ` sashiko-bot
2026-12-03 7:08 ` [PATCH v6 06/17] wifi: cc33xx: Add acx.c, acx.h Ramesh Ramalingam
2026-12-03 7:32 ` sashiko-bot
2026-12-03 7:08 ` [PATCH v6 07/17] wifi: cc33xx: Add event.c, event.h Ramesh Ramalingam
2026-12-03 7:31 ` sashiko-bot
2026-12-03 7:08 ` [PATCH v6 08/17] wifi: cc33xx: Add boot.c, boot.h Ramesh Ramalingam
2026-12-03 7:38 ` sashiko-bot
2026-12-03 7:08 ` [PATCH v6 09/17] wifi: cc33xx: Add main.c Ramesh Ramalingam
2026-12-03 9:12 ` Uwe Kleine-König
2026-12-03 7:08 ` [PATCH v6 10/17] wifi: cc33xx: Add rx.c, rx.h Ramesh Ramalingam
2026-12-03 7:33 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 11/17] wifi: cc33xx: Add tx.c, tx.h Ramesh Ramalingam
2026-12-03 7:47 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 12/17] wifi: cc33xx: Add init.c, init.h Ramesh Ramalingam
2026-12-03 7:43 ` sashiko-bot [this message]
2026-12-03 7:09 ` [PATCH v6 13/17] wifi: cc33xx: Add scan.c, scan.h Ramesh Ramalingam
2026-12-03 7:52 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 14/17] wifi: cc33xx: Add conf.h Ramesh Ramalingam
2026-12-03 7:50 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 15/17] wifi: cc33xx: Add ps.c, ps.h Ramesh Ramalingam
2026-12-03 7:43 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 16/17] wifi: cc33xx: Add testmode.c, testmode.h Ramesh Ramalingam
2026-12-03 7:48 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 17/17] wifi: cc33xx: Add Kconfig, Makefile Ramesh Ramalingam
2026-12-03 7:46 ` sashiko-bot
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=sashiko-outbox-247315@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=r-ramalingam@ti.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.