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 14/17] wifi: cc33xx: Add conf.h
Date: Thu, 03 Dec 2026 07:50:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-247326@kernel.org> (raw)
In-Reply-To: <20261203070906.1294171-15-r-ramalingam@ti.com>
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 <michael.nemanov@ti.com>
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 != CONF_TX_MAX_AC_COUNT)
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 = 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);
}
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 = 1,
> + CONF_HW_RATE_INDEX_2MBPS = 2,
> + CONF_HW_RATE_INDEX_5_5MBPS = 3,
> + CONF_HW_RATE_INDEX_11MBPS = 4,
> + CONF_HW_RATE_INDEX_6MBPS = 5,
> + CONF_HW_RATE_INDEX_9MBPS = 6,
> + CONF_HW_RATE_INDEX_12MBPS = 7,
> + CONF_HW_RATE_INDEX_18MBPS = 8,
> + CONF_HW_RATE_INDEX_24MBPS = 9,
> + CONF_HW_RATE_INDEX_36MBPS = 10,
> + CONF_HW_RATE_INDEX_48MBPS = 11,
> + CONF_HW_RATE_INDEX_54MBPS = 12,
> + CONF_HW_RATE_INDEX_MCS0 = 13,
> + CONF_HW_RATE_INDEX_MCS1 = 14,
> + CONF_HW_RATE_INDEX_MCS2 = 15,
> + CONF_HW_RATE_INDEX_MCS3 = 16,
> + CONF_HW_RATE_INDEX_MCS4 = 17,
> + CONF_HW_RATE_INDEX_MCS5 = 18,
> + CONF_HW_RATE_INDEX_MCS6 = 19,
> + CONF_HW_RATE_INDEX_MCS7 = 20,
> +
> + CONF_HW_RATE_INDEX_MAX = 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 >= CONF_HW_RATE_INDEX_MCS0)
sinfo->txrate.mcs = acx->tx_rate - CONF_HW_RATE_INDEX_MCS0;
else
sinfo->txrate.legacy = cc33xx_idx_to_rate_100kbps[acx->tx_rate - 1];
}
With u16 acx->tx_rate == 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 >= 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 = 0,
> + CONF_PS_SCHEME_UPSD_TRIGGER = 1,
> + CONF_PS_SCHEME_LEGACY_PSPOLL = 2,
> + CONF_PS_SCHEME_SAPSD = 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 = 2, PS_SCHEME_LEGACY_PSPOLL = 3, and
PS_SCHEME_SAPSD = 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 = NULL;
cc->bands[NL80211_BAND_2GHZ].n_iftype_data = 0;
cc->bands[NL80211_BAND_5GHZ].iftype_data = NULL;
cc->bands[NL80211_BAND_5GHZ].n_iftype_data = 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203070906.1294171-1-r-ramalingam@ti.com?part=14
prev parent reply other threads:[~2026-12-03 7:51 UTC|newest]
Thread overview: 30+ 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 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 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
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
[not found] ` <20261203070906.1294171-16-r-ramalingam@ti.com>
2026-12-03 7:43 ` [PATCH v6 15/17] wifi: cc33xx: Add ps.c, ps.h sashiko-bot
[not found] ` <20261203070906.1294171-18-r-ramalingam@ti.com>
2026-12-03 7:46 ` [PATCH v6 17/17] wifi: cc33xx: Add Kconfig, Makefile sashiko-bot
[not found] ` <20261203070906.1294171-17-r-ramalingam@ti.com>
2026-12-03 7:48 ` [PATCH v6 16/17] wifi: cc33xx: Add testmode.c, testmode.h sashiko-bot
[not found] ` <20261203070906.1294171-15-r-ramalingam@ti.com>
2026-12-03 7:50 ` sashiko-bot [this message]
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-247326@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox