All of lore.kernel.org
 help / color / mirror / Atom feed
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 06/17] wifi: cc33xx: Add acx.c, acx.h
Date: Thu, 03 Dec 2026 07:32:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-247292@kernel.org> (raw)
In-Reply-To: <20261203070906.1294171-7-r-ramalingam@ti.com>

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 <michael.nemanov@ti.com>

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) = NULL;
> +	int ret = 0;
> +
> +	acx = 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 = 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 = 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 >= sizeof(struct nab_header) and cc->result_length <=
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) = NULL;
> +	struct conf_bcn_filt_rule *r = &cc->conf.host_conf.conn.bcn_filt_ie0;
> +	struct conf_bcn_filt_rule *itr_end;
> +	int idx = 0;
> +	int ret;
> +	bool vendor_spec = false;
> +
> +	if (WARN_ON(cc->conf.host_conf.conn.bcn_filt_ie_count > CONF_MAX_BCN_FILT_IE_COUNT))
> +		return -EINVAL;
> +
> +	itr_end = 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_COUNT]
would avoid walking past a scalar member.

[ ... ]

> +	while (r < itr_end) {
> +		ie_table->table[idx++] = r->ie;
> +		ie_table->table[idx++] = r->rule;
> +
> +		/* only one vendor specific ie allowed */
> +		if (r->ie == 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 += CONF_BCN_IE_OUI_LEN;
> +			ie_table->table[idx++] = r->type;
> +			memcpy(&ie_table->table[idx], r->version,
> +			       CONF_BCN_IE_VER_LEN);
> +			idx += CONF_BCN_IE_VER_LEN;
> +			vendor_spec = 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 = 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 = 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 == 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 = 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 >= 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];

[Severity: Medium]
Can this read out of bounds before cc33xx_idx_to_rate_100kbps[] if firmware
reports acx->tx_rate == 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 += sizeof(struct cc33xx_rx_filter_field) - sizeof(u8 *);
> +		buf += 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 = he_cap->he_cap_elem.phy_cap_info;
> +	acx->nominal_packet_padding = (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.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203070906.1294171-1-r-ramalingam@ti.com?part=6

  reply	other threads:[~2026-12-03  7:32 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 [this message]
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
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-247292@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.