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=1796283133; b=JM5YVNBkyg6aDh0a65duZce7QP+9SgfjX+OUO+lA6czgyRyUf72R4JyExDIIMsAY6IfA jUKBskyftuBXq3hOW0MftZl0N086LhRez8vphvLuHjwSDJvmAqK7eqwqOfDGXagdSjlfc f7QRHOlF4XIQq8oxI4WbaQwSOe/e1UWZgKW7B7fx6AakOE40Pp1zq4EQX4JNGakKkSAuJ NgGqz4nzkfobXBjzYGRnb9VTcyBzA/mgLXOvm+WwCUZs/+XZJhDElzNrAobvGzc+BPImJ KRlURdMfBXICNmDkY7OE4kYUx5LY3mLrYyFmxlJCvHfop2vramLSsMgV7KmlcDqmPsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283133; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=duGklF1Y5d+gutVHJD19pzL6KrChw/8mNSFAI5e5nAQ=; b=QI9wWI48FYtZrgLDj27nNvSS+A3BWsVnIVae2NOuiWD2LcTVYuubI6HGJ712VsFQ2+Xw 32/wKp3hVybwMARxJz77KkussaIMpBwGghXH9cNrFMmDglWrQexFRDSAgqx1diXB/COxd +NyGX7OIJQNp/Hc6nI0phg8fTc05XwXSdCNZh/13qH3aixMCo8mfBRG/7s0NG30Ksfoel oO08f4MebLstgSzQsTEr6oVu5TTr745Xkyd4un9kWB3AUfi/evSt8VatlBGPADzPXq7bD eQCxphGJCiVI5fDTVMkcRw5qbn9o6hTYufDFsaDsVsDD1b8u0h8fZHjgTVqBj0zqnXw== 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=Z1VqJSDl; 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 1B814606A336 for ; Thu, 3 Dec 2026 07:32:12 +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=Z1VqJSDl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76C821F00896; Thu, 3 Dec 2026 07:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796283132; bh=duGklF1Y5d+gutVHJD19pzL6KrChw/8mNSFAI5e5nAQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Z1VqJSDljTEmHNfUUPZ6biLJiqNtxk2J0gCgoRTkLGSzGgrkL605rk4CiRtmmGzDy 139FENNuRnUn63kE/v81oSAGXDbde4Dob3fBYSs3x5iXIq/Nl3BP46OfL+Pu0T3z5F cz9sQ4ZuHSB4lbaPFl8qfWFI8qOjTJ286uZjJOKOHwZgzUdEO0KaNBC6gliIcSIIAk VYbYzWBX+RXGUaFlBAbx483XvQjAzTVp+L0njpxpnC7qNPVgQ86UXcxwCpKch3z4BU 35fgS3TxwCugf54XCjbXYPWsyN7JZJUJhntnp9NwYRMyYYcbif5etE2cs/zvSgAEEX Z1Hqeo/+sW7Qg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 06/17] wifi: cc33xx: Add acx.c, acx.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-7-r-ramalingam@ti.com> References: <20261203070906.1294171-1-r-ramalingam@ti.com> <20261203070906.1294171-7-r-ramalingam@ti.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:32:12 +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: - [Medium] wifi: cc33xx: wrong HE PHY cap byte read in cc33xx_acx_set_peer_cap() - [Medium] wifi: cc33xx: out-of-bounds read on zero tx_rate in cc33xx_acx_get_tx_rate() - [Medium] wifi: cc33xx: missing le16_to_cpu() on tx_rate in cc33xx_acx_get_tx_rate() - [Medium] wifi: cc33xx: FORTIFY_SOURCE write in cc33xx_rx_filter_flatten_fields() - [Medium] wifi: cc33xx: truncated vendor IE entry in cc33xx_acx_beacon_filter_table() - [Medium] wifi: cc33xx: firmware status ignored in cc33xx_acx_set_ba_receiver_session() - [Medium] wifi: cc33xx: off-by-8 CMD_INTERROGATE bounds check in __cc33xx_cmd_send() - [Medium] wifi: cc33xx: native-endian fields in firmware ACX response structs - [Medium] wifi: cc33xx: concurrent init_completion() re-init races with complete() - [Low] wifi: cc33xx: UB walk past bcn_filt_ie0 in cc33xx_acx_beacon_filter_table() - [Low] wifi: cc33xx: error masked as -ENOMEM in cc33xx_acx_statistics() - [Low] wifi: cc33xx: split __free(kfree) NULL declarations in acx.c - [Low] wifi: cc33xx: unused cc33xx_acx_statistics() exceeds command buffer size -- commit 5acddfafa58fc73efd39d8a631b1de2d03702bb8 Author: Michael Nemanov wifi: cc33xx: Add acx.c, acx.h This commit adds the ACX firmware configuration and interrogation helpers along with their wire-format structures for the cc33xx wireless driver. > diff --git a/drivers/net/wireless/ti/cc33xx/acx.c b/drivers/net/wireless/= ti/cc33xx/acx.c > new file mode 100644 > index 0000000000000..b9a56bd26358a > --- /dev/null > +++ b/drivers/net/wireless/ti/cc33xx/acx.c > @@ -0,0 +1,767 @@ [ ... ] > +int cc33xx_acx_clear_statistics(struct cc33xx *cc) > +{ > + struct acx_header *acx __free(kfree) =3D NULL; > + int ret =3D 0; > + > + acx =3D kzalloc_obj(*acx); > + if (!acx) > + return -ENOMEM; [Severity: Low] This isn't a bug, but across all 23 allocating functions in this file the __free(kfree) pointer is declared as NULL at the top and assigned later (including before early returns such as in cc33xx_acx_beacon_filter_opt()). Initializing it in a single statement at the allocation site follows the cleanup API convention. > + ret =3D cc33xx_cmd_configure(cc, ACX_CLEAR_STATISTICS, acx, sizeof(*acx= )); [Severity: Medium] Can calling __cc33xx_cmd_send() from these ACX helpers race with a late command completion? Every ACX configure, interrogate, and debug helper calls into __cc33xx_cmd_send() (added in commit "wifi: cc33xx: Add cmd.c, cmd.h"), which calls init_completion(&cc->command_complete) on every command. If a previous command timed out or was sent asynchronously, a late completion in parse_control_message() runs without cc->cmd_lock while the next command re-initializes the completion's wait.lock and task_list: CPU0 CPU1 __cc33xx_cmd_send() wait_for_completion_timeout() -> times out (-EIO) __cc33xx_cmd_send() guard(mutex)(&cc->cmd_lock) parse_control_message() complete(&cc->command_complete) raw_spin_lock(&x->wait.lock) init_completion(&cc->command_complete) <-- overwrites wait.lock/list The same pattern appears in cc33xx_cmd_remove_peer() with cc->peer_remove_complete, and neither completion is initialized during cc33xx_alloc_hw(). Initializing both once at allocation time and calling reinit_completion() before each wait would avoid re-initializing an in-use lock. [ ... ] > +static int cc33xx_acx_mem_map(struct cc33xx *cc, > + struct acx_header *memory_map, size_t len) > +{ > + int ret; > + > + ret =3D cc33xx_cmd_interrogate(cc, MEM_MAP_INTR, memory_map, > + sizeof(struct acx_header), len); [Severity: Medium] Can this and the other ACX interrogate callers overflow their kzalloc_obj() buffers by up to 8 bytes? All interrogate helpers here pass sizeof(*buf) (which includes the 8-byte struct nab_header) as res_len, but __cc33xx_cmd_send() checks cc->result_length against res_len before copying into buf + sizeof(struct nab_header): drivers/net/wireless/ti/cc33xx/cmd.c:__cc33xx_cmd_send() { ... if (WARN_ON(cc->result_length > res_len)) { dev_err(cc->dev, "Error, insufficient response buffer\n"); return -EINVAL; } switch (id) { case CMD_INTERROGATE: case CMD_DEBUG_READ: case CMD_TEST_MODE: case CMD_BM_READ_DEVICE_INFO: memcpy(buf + sizeof(struct nab_header), cc->command_result, cc->result_length); break; ... } If firmware returns a cc->result_length in (res_len - 8, res_len], the check passes and memcpy() writes past the end of the allocated struct. Checking res_len >=3D sizeof(struct nab_header) and cc->result_length <=3D res_len - sizeof(struct nab_header) for these commands would prevent the overflow. [ ... ] > +int cc33xx_acx_beacon_filter_table(struct cc33xx *cc, struct cc33xx_vif = *wlvif) > +{ > + struct acx_beacon_filter_ie_table *ie_table __free(kfree) =3D NULL; > + struct conf_bcn_filt_rule *r =3D &cc->conf.host_conf.conn.bcn_filt_ie0; > + struct conf_bcn_filt_rule *itr_end; > + int idx =3D 0; > + int ret; > + bool vendor_spec =3D false; > + > + if (WARN_ON(cc->conf.host_conf.conn.bcn_filt_ie_count > CONF_MAX_BCN_FI= LT_IE_COUNT)) > + return -EINVAL; > + > + itr_end =3D r + cc->conf.host_conf.conn.bcn_filt_ie_count; [Severity: Low] Does advancing r past bcn_filt_ie0 invoke undefined behavior when bcn_filt_ie_count > 1? In struct conf_conn_settings, bcn_filt_ie0 through bcn_filt_ie31 are individual scalar struct members rather than an array, so pointer arithmetic across them risks -Warray-bounds warnings or subobject-bounds issues. Replacing them with an array bcn_filt_ie[CONF_MAX_BCN_FILT_IE_COUN= T] would avoid walking past a scalar member. [ ... ] > + while (r < itr_end) { > + ie_table->table[idx++] =3D r->ie; > + ie_table->table[idx++] =3D r->rule; > + > + /* only one vendor specific ie allowed */ > + if (r->ie =3D=3D WLAN_EID_VENDOR_SPECIFIC && !vendor_spec) { > + /* for vendor specific rules configure the > + * additional fields > + */ > + memcpy(&ie_table->table[idx], r->oui, > + CONF_BCN_IE_OUI_LEN); > + idx +=3D CONF_BCN_IE_OUI_LEN; > + ie_table->table[idx++] =3D r->type; > + memcpy(&ie_table->table[idx], r->version, > + CONF_BCN_IE_VER_LEN); > + idx +=3D CONF_BCN_IE_VER_LEN; > + vendor_spec =3D true; > + } > + > + ie_table->num_ie++; > + r++; > + } [Severity: Medium] Does this write a truncated IE 221 entry when cc33xx-conf.bin contains more than one WLAN_EID_VENDOR_SPECIFIC rule? When vendor_spec is already true, r->ie and r->rule are still written and ie_table->num_ie is still incremented, but the mandatory 6-byte OUI, type, and version fields are omitted, causing firmware to misparse the following entries as vendor-specific data. Duplicate vendor-specific rules should be skipped before writing to ie_table->table[] and incrementing num_ie. [ ... ] > +int cc33xx_acx_statistics(struct cc33xx *cc, void *stats) > +{ > + int ret; > + > + ret =3D cc33xx_cmd_interrogate(cc, ACX_STATISTICS, stats, > + sizeof(struct acx_header), > + sizeof(struct cc33xx_acx_statistics)); [Severity: Low] Can cc33xx_acx_statistics() ever succeed with the current command buffer size? struct cc33xx_acx_statistics is 1104 bytes, while read_control_message() and struct cc33xx::command_result are capped at CC33XX_CMD_MAX_SIZE (896 bytes), so a full firmware response would be rejected with -EIO and a command timeout. Since cc33xx_acx_statistics() has no callers in the series, should this dead code be removed or its buffer size fixed? > + if (ret < 0) { > + dev_warn(cc->dev, "acx statistics failed: %d\n", ret); > + return -ENOMEM; > + } [Severity: Low] Should this return ret instead of -ENOMEM? cc33xx_acx_statistics() does not allocate memory, so returning -ENOMEM discards the actual error from cc33xx_cmd_interrogate(). [ ... ] > + ret =3D cc33xx_cmd_configure_failsafe(cc, BA_SESSION_RX_SETUP_CFG, > + acx, sizeof(*acx), > + BIT(CMD_STATUS_NO_RX_BA_SESSION)); > + if (ret < 0) { > + dev_warn(cc->dev, "acx ba receiver session failed: %d\n", ret); > + return ret; > + } > + > + /* sometimes we can't start the session */ > + if (ret =3D=3D CMD_STATUS_NO_RX_BA_SESSION) { > + dev_warn(cc->dev, "no fw rx ba on tid %d\n", tid_index); > + return -EBUSY; > + } [Severity: Medium] Can the CMD_STATUS_NO_RX_BA_SESSION branch ever be reached? cc33xx_cmd_configure_failsafe() calls __cc33xx_cmd_send() with res_len =3D = 0, which returns CMD_STATUS_SUCCESS unconditionally without inspecting the firmware command-complete status in cc->command_result. As a result, when firmware rejects an RX BA session, cc33xx_acx_set_ba_receiver_session() returns 0 instead of -EBUSY and cc33xx_op_ampdu_action() records the session as active in host state. [ ... ] > + if (acx->tx_rate >=3D CONF_HW_RATE_INDEX_MCS0) > + sinfo->txrate.mcs =3D acx->tx_rate - CONF_HW_RATE_INDEX_MCS0; > + else > + sinfo->txrate.legacy =3D cc33xx_idx_to_rate_100kbps[acx->tx_rate - 1]; [Severity: Medium] Can this read out of bounds before cc33xx_idx_to_rate_100kbps[] if firmware reports acx->tx_rate =3D=3D 0? When acx->tx_rate is 0 (for example before any frame has been transmitted or on a short response leaving the kzalloc zero value), acx->tx_rate - 1 evaluates to -1 and reads 2 bytes before the array. [Severity: Medium] Is acx->tx_rate missing a le16_to_cpu() conversion here? struct acx_preamble_and_tx_rate declares u16 tx_rate instead of __le16, so on big-endian hosts a little-endian legacy rate index like 1 is read as 0x0100, taking the MCS branch and reporting a bogus TX bitrate to userspace. [ ... ] > + memcpy(&field->pattern, filter->fields[i].pattern, field->len); > + buf +=3D sizeof(struct cc33xx_rx_filter_field) - sizeof(u8 *); > + buf +=3D field->len; [Severity: Medium] Will this memcpy() trigger a CONFIG_FORTIFY_SOURCE field-spanning write warning whenever a WoWLAN pattern is longer than sizeof(u8 *)? In struct cc33xx_rx_filter_field, pattern is a u8 * pointer rather than a flexible array member, while WoWLAN advertises patterns up to 91 bytes. Using a packed wire struct with a u8 pattern[] flexible array member (or copying to buf + offsetof(struct cc33xx_rx_filter_field, pattern)) would avoid tripping fortify_memcpy_chk(). [ ... ] > + cap_info =3D he_cap->he_cap_elem.phy_cap_info; > + acx->nominal_packet_padding =3D (cap_info[8] & NOMINAL_PACKET_PADDING); [Severity: Medium] Should this read cap_info[9] instead of cap_info[8]? In include/linux/ieee80211-he.h, bits [7:6] (0xc0) of phy_cap_info[8] are IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK, whereas Nominal Packet Padding is in phy_cap_info[9] (IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK). This programs the peer's DCM Max RU bits as the HE packet extension duration on every 802.11ax association. It also leaves the value unshifted rather than shifting right by IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS (6), which is worth checking against the firmware ABI. > diff --git a/drivers/net/wireless/ti/cc33xx/acx.h b/drivers/net/wireless/= ti/cc33xx/acx.h > new file mode 100644 > index 0000000000000..43b6c4b16c574 > --- /dev/null > +++ b/drivers/net/wireless/ti/cc33xx/acx.h [ ... ] > +struct cc33xx_roaming_stats { > + s32 rssi_level; > +} __packed; [Severity: Medium] Should rssi_level here be __le32 (and tx_rate in struct acx_preamble_and_tx_rate be __le16) to match the other packed firmware response structures? Declaring wire-format fields with native-endian types breaks sparse endianness checks and produces byte-swapped values on big-endian hosts. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203070906.1294= 171-1-r-ramalingam@ti.com?part=3D6