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=1796284261; b=JaV9D325RVK9cAXN/uWinbwFBQq5XpxAw9yf9fHb+kwe+CiglJFCQqNP3wBbCUKXbsMP jPbBvEyQB9u9DV928QyRqNZZHmOFm4WphxFvVSib3lcsMc2bnKZVgrIDaBZoPV85W/u1g 7XReYfhks5Z1SKy0QjetiEyB1FgNj5cb9YPrnfBMszvOlGKJP+/TayJpVjDfb0XwduTzn 0IJcvnR2J9+udaEq3EkZxx2eFxqiBWiCtME9S0Z68hR+CPYA8v3PV94VVsIwIRZhdvDte INBEFGGXsrT50KE8+Ol2aS9T+0AUXzfrGqPR/m8smSoeiqZiztd9fvlvwlVp1m7uP1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796284261; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=rasZ1yHD1Vc6hXjo/fiISY6YDCL7n3DWrtzK2EU0TfI=; b=D3ScW86+4folzkhnIuc7+Fr6EDJ/x/bVheIPm90lXkpJL3+krbrDHoKaRHKvkqgM0JqX PpVe9CRTPamfvKpQRhO4DqllqD1GO4fQFpb7/RazYsA+ya3JO/fYhAaK1orWpYuDjR6qr DGbQq8QBdWBHuLcT9J2aV+RpNpu3RoS1MH8qvHNei1WPv/14TCfA7w2+l+qOVLSnAKXWX 9zMJkpa4qan2PwXMdmElKnD4IHvmly7/I9+As4YLN2HDGomq0gMs+fa6dRebzne2hGEKG HnsIqH0hVYacS2tGpV1o3TEKsbaiQT7z7ojZ55gE/UmV9V8X9MN1NoSjbelM5+uSbiQ== 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=mKqhJZiI; 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 52DDB606A322 for ; Thu, 3 Dec 2026 07:51:01 +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=mKqhJZiI Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC20A1F000C1; Thu, 3 Dec 2026 07:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796284261; bh=rasZ1yHD1Vc6hXjo/fiISY6YDCL7n3DWrtzK2EU0TfI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=mKqhJZiIruf6sPkjv4TQCnTQN4xArguzPkvuSeVG74emgfYRMlBtDj3ngXGXzARgy I4z2uAECfCYZa06y6LlaKIIEQp4uSfyqP6ugjwcS5Es/fnCDotwFIccsiHGeB5wRIU uP7vdm6pfK+469bMjTUDiY58SzMSDv0p92i3OcR9ecITyJvfYEdj7MbBlQHUFoRt68 xlrod2QQfwmRPV3uhhxGFsl78i3zEGX7V8xxwWzqNnR+Sutq6Jvo23wPhk4sPkdJm6 CyJfj8vctiXCy0UI+Qqk++mAHyc49y9CyGgAPLChivyvbC3rvwttHxUnAG4DceKWsy s6Up5LDJe4vsg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 14/17] wifi: cc33xx: Add conf.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-15-r-ramalingam@ti.com> References: <20261203070906.1294171-1-r-ramalingam@ti.com> <20261203070906.1294171-15-r-ramalingam@ti.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:50:57 +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 8 potential issues to consider: - [High] wifi: cc33xx: slab out-of-bounds read past cc->cmd_buf in send_buffer() - [Medium] wifi: cc33xx: host-endian payload fields in little-endian cc33xx_conf_file - [Medium] wifi: cc33xx: unrolled scalar fields in conf.h cause OOB pointer arithmetic - [Medium] wifi: cc33xx: out-of-bounds read in cc33xx_acx_get_tx_rate() when tx_rate is 0 - [Medium] wifi: cc33xx: cc33xx_init_ieee80211() unconditionally overwrites he_enable - [Medium] wifi: cc33xx: cc33xx_ini_bin_init() leaves all-zero conf on fallback - [Low] wifi: cc33xx: conflicting CONF_PS_SCHEME and PS_SCHEME enum values - [Low] wifi: cc33xx: unused CC33XX_CONF_VERSION check and dead defs in conf.h -- commit 660c730a527a7e9f1d8ab53bd35ec0f25cac9f39 Author: Michael Nemanov wifi: cc33xx: Add conf.h This commit adds conf.h defining the binary configuration file layout, hardware rate definitions, and firmware/driver control structures for the TI CC33xx wireless driver. > diff --git a/drivers/net/wireless/ti/cc33xx/conf.h b/drivers/net/wireless= /ti/cc33xx/conf.h > new file mode 100644 > index 0000000000000..a6aa2c0dc9630 > --- /dev/null > +++ b/drivers/net/wireless/ti/cc33xx/conf.h > @@ -0,0 +1,1241 @@ [ ... ] > +struct cc33xx_conf_header { > + __le32 magic; > + __le32 version; > + __le32 checksum; > +} __packed; > + > +#define CC33XX_CONF_MAGIC 0x10e100ca > +#define CC33XX_CONF_VERSION 0x01070070 > +#define CC33XX_CONF_MASK 0x0000ffff [Severity: Medium] What populates cc->conf when loading the configuration binary fails? In drivers/net/wireless/ti/cc33xx/main.c, cc33xx_ini_bin_init() logs "falling back to default config" and returns 0 when cc33xx_load_ini_bin_file() fails, leaving cc->conf all-zero. Probe then downloads an all-zero struct cc33xx_conf_file to the firmware, and bringing up any VIF hits WARN_ON(tx_settings->ac_conf_count !=3D CONF_TX_MAX_AC_COUN= T) in cc33xx_init_vif_specific() and fails with -EINVAL. In addition, cc33xx_load_ini_bin_file() never checks header.version against CC33XX_CONF_VERSION or validates header.checksum, so a mismatched or corrupted binary of the same size is silently accepted. > +#define CC33X_CONF_SIZE (sizeof(struct cc33xx_conf_file)) [Severity: High] Can send_buffer() read past the end of cc->cmd_buf during INI download? CC33X_CONF_SIZE is 1353 bytes, which sizes cc->cmd_buf to CC33XX_INI_CMD_MAX_SIZE (1373 bytes) in drivers/net/wireless/ti/cc33xx/cc33xx.h. During firmware init, cc33xx_download_ini_params_and_wait() calls cc33xx_set_max_buffer_size(cc, INI_MAX_BUFFER_SIZE), which adds the command header and u32 size a second time (1393 bytes), and send_buffer() then aligns the transfer length up to 256 bytes (1536 bytes): 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); } Passing 1536 bytes to sdio_writesb() reads 163 bytes past cc->cmd_buf and roughly 114 bytes past the end of struct cc33xx on every boot, triggering KASAN slab-out-of-bounds reports and transmitting adjacent heap memory over SDIO. Even without the double header addition, aligning 1373 up to 256 bytes still requires 1536 bytes, so CC33XX_CMD_BUFFER_SIZE should be aligned to CC33XX_BUS_BLOCK_SIZE * 2 as well. [ ... ] > +enum { > + CONF_HW_RATE_INDEX_1MBPS =3D 1, > + CONF_HW_RATE_INDEX_2MBPS =3D 2, > + CONF_HW_RATE_INDEX_5_5MBPS =3D 3, > + CONF_HW_RATE_INDEX_11MBPS =3D 4, > + CONF_HW_RATE_INDEX_6MBPS =3D 5, > + CONF_HW_RATE_INDEX_9MBPS =3D 6, > + CONF_HW_RATE_INDEX_12MBPS =3D 7, > + CONF_HW_RATE_INDEX_18MBPS =3D 8, > + CONF_HW_RATE_INDEX_24MBPS =3D 9, > + CONF_HW_RATE_INDEX_36MBPS =3D 10, > + CONF_HW_RATE_INDEX_48MBPS =3D 11, > + CONF_HW_RATE_INDEX_54MBPS =3D 12, > + CONF_HW_RATE_INDEX_MCS0 =3D 13, > + CONF_HW_RATE_INDEX_MCS1 =3D 14, > + CONF_HW_RATE_INDEX_MCS2 =3D 15, > + CONF_HW_RATE_INDEX_MCS3 =3D 16, > + CONF_HW_RATE_INDEX_MCS4 =3D 17, > + CONF_HW_RATE_INDEX_MCS5 =3D 18, > + CONF_HW_RATE_INDEX_MCS6 =3D 19, > + CONF_HW_RATE_INDEX_MCS7 =3D 20, > + > + CONF_HW_RATE_INDEX_MAX =3D CONF_HW_RATE_INDEX_MCS7, > +}; [Severity: Medium] Can cc33xx_acx_get_tx_rate() read out of bounds when firmware reports tx_rate 0? Because the hardware rate indices start at 1, a zero tx_rate from firmware falls into the else branch in drivers/net/wireless/ti/cc33xx/acx.c: drivers/net/wireless/ti/cc33xx/acx.c:cc33xx_acx_get_tx_rate() { 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]; } With u16 acx->tx_rate =3D=3D 0, acx->tx_rate - 1 promotes to -1 and reads 2 bytes before cc33xx_idx_to_rate_100kbps[] in .rodata, triggering KASAN or UBSAN global-out-of-bounds reports when NL80211_CMD_GET_STATION runs. Values above CONF_HW_RATE_INDEX_MAX (such as CONF_HW_RXTX_RATE_UNSUPPORTED) also pass the >=3D CONF_HW_RATE_INDEX_MCS0 check and report an invalid MCS. Validating that tx_rate is within [CONF_HW_RATE_INDEX_1MBPS, CONF_HW_RATE_INDEX_MAX] would prevent both. [ ... ] > +struct cc33xx_clk_cfg { > + u32 n; > + u32 m; > + u32 p; > + u32 q; > + u8 swallow; > +}; [Severity: Low] Are struct cc33xx_clk_cfg, the CLOCK_CONFIG_* enum, and struct conf_channel_power_limit used anywhere in cc33xx? None of these definitions are referenced in the driver or embedded in struct cc33xx_conf_file. CC33XX_CONF_VERSION and CC33XX_CONF_MASK are also unused because cc33xx_load_ini_bin_file() skips version checking (and logs __le32 header.magic without le32_to_cpu()). Finally, CC33X_CONF_SIZE is missing an X compared to the other CC33XX_CONF_* macros, and several array sizes (507, 13, 3, 2) duplicate the adjacent REG_RULES_COUNT, ACX_RATE_MGMT_NUM_OF_RATES, CONF_BCN_IE_OUI_LEN, and CONF_BCN_IE_VER_LEN macros. [ ... ] > +enum { > + CONF_PS_SCHEME_LEGACY =3D 0, > + CONF_PS_SCHEME_UPSD_TRIGGER =3D 1, > + CONF_PS_SCHEME_LEGACY_PSPOLL =3D 2, > + CONF_PS_SCHEME_SAPSD =3D 3, > +}; [Severity: Low] Do these CONF_PS_SCHEME_* values conflict with the PS_SCHEME_* enum in drivers/net/wireless/ti/cc33xx/acx.h? acx.h defines PS_SCHEME_MIXED_MODE =3D 2, PS_SCHEME_LEGACY_PSPOLL =3D 3, and PS_SCHEME_SAPSD =3D 4, whereas here 2 is LEGACY_PSPOLL and 3 is SAPSD. Both enums are passed into cc33xx_tx_param_cfg() for the same firmware ps_scheme field; today cc33xx_op_conf_tx() only passes 0 and 1, which match, but using any higher value would silently misconfigure the firmware. Removing the duplicate enum and using PS_SCHEME_* consistently would avoid that. [ ... ] > + /*struct conf_tx_ac_category ac_conf[CONF_TX_MAX_AC_COUNT];*/ > + struct conf_tx_ac_category ac_conf0; > + struct conf_tx_ac_category ac_conf1; > + struct conf_tx_ac_category ac_conf2; > + struct conf_tx_ac_category ac_conf3; [Severity: Medium] Can stepping pointers across unrolled scalar fields like ac_conf0..ac_conf3 trigger undefined behavior and bounds-check failures? cc33xx_init_vif_specific() in drivers/net/wireless/ti/cc33xx/init.c starts at &tx_settings->ac_conf0 and increments conf_ac++ across ac_conf1..ac_conf3. Similarly, struct conf_conn_settings unrolls bcn_filt_ie0..bcn_filt_ie31 (and struct conf_tx_settings unrolls tid_conf0..tid_conf7), and cc33xx_acx_beacon_filter_table() in acx.c walks r++ from &bcn_filt_ie0 up to r + bcn_filt_ie_count and passes r->oui and r->version to memcpy(). Advancing a pointer past a single non-array member into neighboring fields is C undefined behavior and can trip UBSAN, FORTIFY_SOURCE subobject bounds checks, or -Warray-bounds. Since all of these structs are __packed, declaring fixed-size arrays (ac_conf[CONF_TX_MAX_AC_COUNT], tid_conf[CONF_TX_MAX_TID_COUNT], and bcn_filt_ie[CONF_MAX_BCN_FILT_IE_COUNT]) keeps the identical wire layout. [ ... ] > +struct cc33xx_mac_conf { > + u8 ps_scheme; > + u8 he_enable; > + u8 ap_max_num_stations; > +} __packed; [Severity: Medium] Does cc33xx_init_ieee80211() unconditionally undo clearing HE capabilities when he_enable is 0? In drivers/net/wireless/ti/cc33xx/main.c: drivers/net/wireless/ti/cc33xx/main.c:cc33xx_init_ieee80211() { if (!cc->conf.mac.he_enable) { cc->bands[NL80211_BAND_2GHZ].iftype_data =3D NULL; cc->bands[NL80211_BAND_2GHZ].n_iftype_data =3D 0; cc->bands[NL80211_BAND_5GHZ].iftype_data =3D NULL; cc->bands[NL80211_BAND_5GHZ].n_iftype_data =3D 0; } ieee80211_set_sband_iftype_data(&cc->bands[NL80211_BAND_2GHZ], iftype_data= _2ghz); ieee80211_set_sband_iftype_data(&cc->bands[NL80211_BAND_5GHZ], iftype_data= _5ghz); } The trailing ieee80211_set_sband_iftype_data() calls immediately overwrite iftype_data and n_iftype_data on both bands, so mac80211 still advertises HE support even when the OEM configuration disables it in firmware. Moving those calls into an else branch would fix this. [ ... ] > +struct cc33xx_conf_file { > + struct cc33xx_conf_header header; > + struct cc33xx_phy_conf phy; > + struct cc33xx_mac_conf mac; > + struct cc33xx_core_conf core; > + struct cc33xx_host_conf host_conf; > +} __packed; [Severity: Medium] Should the multi-byte fields inside struct cc33xx_conf_file use __le16 and __le32 instead of host-endian u16 and u32? struct cc33xx_conf_header uses __le32, cc33xx_load_ini_bin_file() copies the little-endian binary directly into cc->conf via memcpy(), and cc33xx_download_ini_params_and_wait() sends cc->conf verbatim to firmware. Because Kconfig does not restrict CC33XX to little-endian systems, reading u16 and u32 fields directly on big-endian hosts produces byte-swapped values in callers such as cc33xx_scan_get_channels(), cc33xx_tx_param_cfg(), cc33xx_event_beacon_loss(), and cc33xx_init_vif_data(), and prevents sparse from flagging the missing le16_to_cpu() and le32_to_cpu() conversions. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203070906.1294= 171-1-r-ramalingam@ti.com?part=3D14