From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283800; b=R0L9GOdiKaU9Z1Fr/X7mJKCtjDaNhnYk6lAKh1LfdJ57Z6aVZFgempasOAmArlP9e3qx nv0vp/rVLq3mmflYOIAHT1Mu+8arqxFwSsqNuQ9cxXshg4D5Wm0gSNjMcbdHaPnLMXlb5 +sALYGeA752vv9e7wxl1Zkq1hINzWspm9kBW1KcRGQebLWcbs4h/s1dMVU0Of6Kc5UQXh 4O8MmA3wmJ7DTfVAsID7JZrvneDmX3VBKyKs3Job0hwPbHORcboaB/0OSKGBZWS01PR/B zp/V3jH+QoKE2DLjBZEXuyTEtBtXzJ2e83HLoUUUwfSHvHPM9nVufFNz5xyo84n4Xfg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283800; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=HLrRS+Lq5FBgjaPyRriPdsqnbxk3BGU5QK/ItWvuf34=; b=TyWXC1f397Auw97exo+RpcaeWdd2spPmH7GC3Yaa6FPnjqitoBsbE1BFFIdIxulbbquj mF4b+42/KVDDZAxIuYvreiguif8khRrgjlj7cFAEqC5Ec3Coo6Wb9+EtgvTO9E9lc2nhp /nttbU6BMRmmYpEEBtDo/v8tSs6S1jsuRbDjvksFBQuq6ysy53Cj2cRMrw9u6TzPSAvNq aQyUvKDN4KqtaCuLUw9mS8JWgmQ3yMDYkWA1XBw4ITv6LdFwjqspNAFQ9Qkr06FkmnB54 9C4QDI7pKnLMk32ZlmFJ2Ca1vCRDUsTu2eT1IHYZ7jYpKaXcm/d6XQ4NkyfRrXWubwg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HoBGsCvJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA270606A322 for ; Thu, 3 Dec 2026 07:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HoBGsCvJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 268771F000C1; Thu, 3 Dec 2026 07:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796283800; bh=HLrRS+Lq5FBgjaPyRriPdsqnbxk3BGU5QK/ItWvuf34=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=HoBGsCvJcuClm7P3nWDNeLX2VBf008GisPh+HVaerVE2eQtmX5B16ReXC/JHKhJT3 2x2AlDRipEde3Ig3cC92dTvzoA1D5cz+kAYL13aP1kdxUZG+xCANvhMm/jiCSicmaX 9b7aIhaliV4iCoCygrMJqZV3Kywp1wk2rjP4OJFQFBmZ75uMTadw1PR4ZGyyBMuGqC 1WGDwLrW/0ScDU9qnjoX9L5j32vib8BNwE7GhD3M2v3edjc6xKY70mqtyHTK8MJmUV MpiqlRgSrCN8ST4RUAWXoVqz+p1OOCS8tStwhvsgWWc7GUHeqX8DPci9EejEpENbZP IrpN2pqLflwTg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 12/17] wifi: cc33xx: Add init.c, init.h Reply-To: sashiko-reviews@lists.linux.dev To: "Ramesh Ramalingam" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203070906.1294171-13-r-ramalingam@ti.com> References: <20261203070906.1294171-1-r-ramalingam@ti.com> <20261203070906.1294171-13-r-ramalingam@ti.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:43:19 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 *vi= f) [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 t= wo active non-device roles, two failed interface additions permanently exhaust all hardware role slots until recovery or driver reload. > +{ > + struct cc33xx_vif *wlvif =3D cc33xx_vif_to_data(vif); > + struct conf_tx_settings *tx_settings =3D &cc->conf.host_conf.tx; > + struct conf_tx_ac_category *conf_ac =3D &tx_settings->ac_conf0; > + bool is_ap =3D (wlvif->bss_type =3D=3D BSS_TYPE_AP_BSS); > + u8 ps_scheme =3D cc->conf.mac.ps_scheme; > + int ret, i; > + > + /* consider all existing roles before configuring psm. */ > + > + if (cc->ap_count =3D=3D 0 && is_ap) { /* first AP */ > + ret =3D cc33xx_acx_sleep_auth(cc, CC33XX_PSM_ELP); > + if (ret < 0) > + return ret; > + > + /* unmask ap events */ > + cc->event_mask |=3D 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 se= ts cc->event_mask |=3D 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 continu= es sending subsequent ACX commands instead of failing interface setup. > + > + /* Default TID/AC configuration */ > + if (WARN_ON(tx_settings->ac_conf_count !=3D tx_settings->tid_conf_count= ) || > + WARN_ON(tx_settings->ac_conf_count !=3D CONF_TX_MAX_AC_COUNT)) > + return -EINVAL; > + > + for (i =3D 0; i < tx_settings->tid_conf_count; i++) { > + /* If no ps poll is used, send legacy ps scheme in cmd */ > + if (ps_scheme =3D=3D PS_SCHEME_NOPSPOLL) > + ps_scheme =3D PS_SCHEME_LEGACY; > + > + ret =3D 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 wi= th 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 =3D 0; > + cc->partial_rx.status =3D 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 =3D 0; mutex_lock(&cc->mutex) cc->partial_rx.status =3D ... 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) !=3D 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 recove= ry 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 t= he 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 =3D=3D CURR_RX_DATA (or rx.c must clear the pointer on completion) to avoid a double free. > + > + ret =3D 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 cc33= xx while interrupts remain enabled and queued work (such as recovery_work queu= ed 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) =3D 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 comman= ds while cc33xx_set_max_buffer_size() updates cc->max_cmd_size in three unlock= ed stores: CPU0 (recovery_work) CPU1 (nl80211) cc33xx_turn_off() cc->flags =3D 0; cc33xx_init_fw() cc33xx_download_ini_params_and_wait() cc33xx_set_max_buffer_size() cc33xx_op_add_interface() cc->max_cmd_size =3D ... ... cc->max_cmd_size +=3D ... __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 comma= nd protocol. > + > + cmd->length =3D cpu_to_le32(sizeof(cc->conf)); > + > + /* copy INI file params payload */ > + memcpy((cmd->payload), &cc->conf, sizeof(cc->conf)); > + > + ret =3D 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 =3D CC33XX_INI_CMD_MAX_SIZE; cc->max_cmd_size +=3D sizeof(struct cc33xx_cmd_ini_params_download); cc->max_cmd_size +=3D sizeof(u32); break; ... } drivers/net/wireless/ti/cc33xx/cmd.c:send_buffer() { ... max_cmd_size_align =3D __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 KAS= AN 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 wi= th adjacent fields such as dynamic_fw_traces and extra_spare_key_count. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203070906.1294= 171-1-r-ramalingam@ti.com?part=3D12