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 10/17] wifi: cc33xx: Add rx.c, rx.h
Date: Thu, 03 Dec 2026 07:33:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-247293@kernel.org> (raw)
In-Reply-To: <20261203070906.1294171-11-r-ramalingam@ti.com>
Thank you for your contribution! Sashiko AI review found 11 potential
issues to consider:
- [High] wifi: cc33xx: concurrent cc33xx_flush_deferred_work() races
with netstack_work
- [High] wifi: cc33xx: desc->length underflow causes infinite loop or
OOB read in rx.c
- [High] wifi: cc33xx: unchecked nab_rx_header->len causes OOB read in
cc33xx_rx()
- [High] wifi: cc33xx: teardown ordering UAF in cc33xx_remove() and
cc33xx_turn_off()
- [Medium] wifi: cc33xx: OOB read on split descriptor in
cc33xx_rx_handle_packet()
- [Medium] wifi: cc33xx: missing skb->len checks in
cc33xx_rx_get_packet_data()
- [Medium] wifi: cc33xx: partial_rx.skb leaked on firmware recovery and
driver removal
- [Medium] wifi: cc33xx: cc33xx_rx_status() passes unsupported rate_idx
to mac80211
- [Low] wifi: cc33xx: unratelimited dev_warn()/dev_err() in RX path
under cc->mutex
- [Low] wifi: cc33xx: missing le16_to_cpu() on __le16 fields in rx.c
debug logs
- [Low] wifi: cc33xx: double subtraction of pad_len in
cc33xx_rx_get_packet_data()
--
commit 0a5e47272fafbb9009679e3984d494d3dc15af9f
Author: Michael Nemanov <michael.nemanov@ti.com>
wifi: cc33xx: Add rx.c, rx.h
This commit adds RX buffer parsing, descriptor handling, and RX filter
helpers for the TI CC33xx wireless driver.
> diff --git a/drivers/net/wireless/ti/cc33xx/rx.c b/drivers/net/wireless/ti/cc33xx/rx.c
> new file mode 100644
> index 0000000000000..81e16749ed0be
> --- /dev/null
> +++ b/drivers/net/wireless/ti/cc33xx/rx.c
> @@ -0,0 +1,385 @@
[ ... ]
> + rate_idx = cc33xx_rate_to_idx(desc->rate, status->band);
> + if (rate_idx == CONF_HW_RXTX_RATE_UNSUPPORTED)
> + dev_err(cc->dev, "Invalid RX rate from HW: %d\n", desc->rate);
> +
> + status->rate_idx = rate_idx;
[Severity: Medium]
Can passing CONF_HW_RXTX_RATE_UNSUPPORTED (0xff) in status->rate_idx trigger
warnings in mac80211?
When firmware reports an unmapped rate (such as desc->rate == 0 or a rate
above CONF_HW_RATE_INDEX_MAX), cc33xx_rx_status() logs an error but still
passes 0xff to ieee80211_rx_ni(). ieee80211_rx_list() treats an out-of-range
rate_idx as a driver bug, emitting WARN/WARN_ON/WARN_ONCE splats before
dropping the frame. Should this clamp rate_idx to a valid fallback (such as
0) or drop the frame instead?
[ ... ]
> + if (unlikely(desc_err_code & CC33XX_RX_DESC_MIC_FAIL)) {
> + status->flag |= RX_FLAG_MMIC_ERROR;
> + dev_warn(cc->dev, "Michael MIC error. Desc: 0x%x\n",
> + desc_err_code);
> + }
[Severity: Low]
Should this dev_warn(), along with the dev_err() for invalid RX rates above
and the dev_warn() for CC33XX_RX_DESC_DECRYPT_FAIL in
cc33xx_rx_get_packet_descriptor(), be ratelimited?
All three run per received packet while cc->mutex is held in
cc33xx_irq_work(). A nearby peer sending forged frames that fail decryption
or Michael MIC verification can flood the kernel log and stall operations
waiting on cc->mutex.
[ ... ]
> + /* Descriptor was fully copied */
> + pkt_data_len = cc->partial_rx.original_bytes;
> + pkt_data_len -= sizeof(struct cc33xx_rx_descriptor);
> +
> + if (unlikely(cc->partial_rx.desc.status & CC33XX_RX_DESC_DECRYPT_FAIL)) {
> + dev_warn(cc->dev, "corrupted packet in RX: status: 0x%x len: %d\n",
> + cc->partial_rx.desc.status & CC33XX_RX_DESC_STATUS_MASK,
> + pkt_data_len);
> +
> + /* If frame can be fully dropped */
> + if (pkt_data_len <= *raw_buffer_len) {
> + *raw_buffer_len -= pkt_data_len;
> + cc->partial_rx.status = CURR_RX_START;
> + } else {
> + cc->partial_rx.handled_bytes += *raw_buffer_len;
> + cc->partial_rx.status = CURR_RX_DROP;
> + *raw_buffer_len = 0;
> + }
> + goto out;
> + }
[Severity: High]
Can a malformed descriptor with desc->length < sizeof(struct
cc33xx_rx_descriptor) cause an infinite loop or an out-of-bounds read?
Without a lower-bound check on original_bytes, subtracting 16 underflows u16
pkt_data_len to 65520..65535. On the normal path this requests a ~64 KB
allocation under cc->mutex and absorbs subsequent RX traffic.
On the drop path (decrypt failure or __dev_alloc_skb() failure),
handled_bytes becomes greater than original_bytes, status becomes
CURR_RX_DROP, and *raw_buffer_len is set to 0. cc33xx_rx_handle_packet()
then immediately calls cc33xx_rx_drop_packet_data(), where signed promotion
makes (original_bytes - handled_bytes) negative:
drivers/net/wireless/ti/cc33xx/rx.c:cc33xx_rx_drop_packet_data() {
if (*raw_buffer_len >=
(cc->partial_rx.original_bytes - cc->partial_rx.handled_bytes)) {
*raw_buffer_len -= cc->partial_rx.original_bytes -
cc->partial_rx.handled_bytes;
cc->partial_rx.handled_bytes = 0;
cc->partial_rx.status = CURR_RX_START;
}
}
That increases *raw_buffer_len instead of decreasing it. Back in
cc33xx_rx(), consumed_bytes becomes 0 (looping forever while holding
cc->mutex) or underflows u16 if the descriptor was split across transfers,
advancing pkt_offset ~65 KB past cc->aggr_buf.
> + skb = __dev_alloc_skb(pkt_data_len, GFP_KERNEL);
[ ... ]
> + cc->partial_rx.skb = skb;
> + cc->partial_rx.status = CURR_RX_DATA;
[Severity: Medium]
Does cc->partial_rx.skb leak if firmware recovery or device removal happens
while a split RX frame is in CURR_RX_DATA?
cc->partial_rx.skb is never cleared to NULL after being queued to
deferred_rx_queue, and neither cc33xx_turn_off() nor cc33xx_free_hw() frees
an in-progress partial_rx.skb. Adding an RX reset helper that frees and
clears partial_rx.skb during teardown and recovery would prevent the leak.
[ ... ]
> + rx_align = cc->partial_rx.desc.header_alignment;
> + if (rx_align == CC33XX_RX_BUF_PADDED)
> + skb_pull(cc->partial_rx.skb, RX_BUF_ALIGN);
> +
> + extra_bytes = cc->partial_rx.desc.pad_len;
> + if (extra_bytes != 0)
> + skb_trim(cc->partial_rx.skb,
> + cc->partial_rx.skb->len - extra_bytes);
> +
> + hdr = (struct ieee80211_hdr *)cc->partial_rx.skb->data;
> +
> + if (ieee80211_is_beacon(hdr->frame_control))
> + beacon = 1;
> + if (ieee80211_is_probe_resp(hdr->frame_control))
> + is_probe_resp = 1;
> +
> + cc33xx_rx_status(cc, &cc->partial_rx.desc,
> + IEEE80211_SKB_RXCB(cc->partial_rx.skb),
> + beacon, is_probe_resp);
> +
> + seq_num = le16_get_bits(hdr->seq_ctrl, IEEE80211_SCTL_SEQ);
[Severity: Medium]
Can this read past skb->tail or underflow skb_trim() on short or malformed
frames?
skb_pull() and skb_trim() are called without checking that skb->len is at
least RX_BUF_ALIGN or extra_bytes; if extra_bytes > skb->len, the unsigned
subtraction wraps near UINT_MAX so skb_trim() leaves the frame untrimmed.
In addition, hdr->frame_control and hdr->seq_ctrl (offset 22..23) are read
unconditionally without checking skb->len. Any frame shorter than 24 bytes,
such as an 802.11 control frame, reads past skb->tail into uninitialized
buffer memory or skb_shared_info.
> + cc33xx_debug(cc->dev, DEBUG_RX, "rx skb 0x%p: %d B %s seq %d link id %d\n",
> + cc->partial_rx.skb,
> + cc->partial_rx.skb->len - cc->partial_rx.desc.pad_len,
> + beacon ? "beacon" : "", seq_num, cc->partial_rx.desc.hlid);
[Severity: Low]
Does this debug log subtract cc->partial_rx.desc.pad_len twice? skb_trim()
already removed extra_bytes from cc->partial_rx.skb->len just above.
> + cc33xx_debug(cc->dev, DEBUG_RX, "rx frame. frame type 0x%x, frame length 0x%x, frame address %p\n",
> + hdr->frame_control, cc->partial_rx.skb->len,
> + cc->partial_rx.skb->data);
[Severity: Low]
Should hdr->frame_control here and desc->length in cc33xx_rx_handle_packet()
be wrapped in le16_to_cpu()? Both are __le16 fields passed directly to 0x%x,
which causes sparse warnings and byte-swapped output on big-endian hosts.
> + /* Adding frame to queue */
> + skb_queue_tail(&cc->deferred_rx_queue, cc->partial_rx.skb);
> + cc->rx_counter++;
> + cc->partial_rx.status = CURR_RX_START;
> +
> + /* Make sure the deferred queues don't get too long */
> + defer_count = skb_queue_len(&cc->deferred_tx_queue);
> + defer_count += skb_queue_len(&cc->deferred_rx_queue);
> + if (defer_count >= CC33XX_RX_QUEUE_MAX_LEN)
> + cc33xx_flush_deferred_work(cc);
> + else
> + queue_work(cc->freezable_netstack_wq, &cc->netstack_work);
[Severity: High]
Can calling cc33xx_flush_deferred_work() directly here race with
cc33xx_netstack_work() and violate mac80211's RX serialization contract?
CPU0 (freezable_wq) CPU1 (freezable_netstack_wq)
cc33xx_irq_work() cc33xx_netstack_work()
guard(mutex)(&cc->mutex) cc33xx_flush_deferred_work()
cc33xx_rx() ieee80211_rx_ni()
cc33xx_rx_get_packet_data()
if (defer_count >= 256)
cc33xx_flush_deferred_work()
ieee80211_rx_ni() <-- concurrent mac80211 RX
Under heavy traffic, both workers dequeue from deferred_rx_queue and
deferred_tx_queue at the same time and call ieee80211_rx_ni() and
ieee80211_tx_status_ni() concurrently for the same ieee80211_hw. mac80211
forbids concurrent calls to these functions; doing so races on unlocked
fragment reassembly state in ieee80211_reassemble_add() (risking SKB list
corruption or out-of-bounds cache indexing) and CCMP PN replay tracking in
ieee80211_crypto_ccmp_decrypt(). Running the flush synchronously here also
holds cc->mutex across network-stack delivery, stalling hardware I/O and
mac80211 control ops.
[Severity: High]
Can this queue_work() path and cc33xx_turn_off() trigger a use-after-free on
cc->hw during device removal?
CPU0 CPU1
cc33xx_remove()
cc33xx_unregister_hw()
cc33xx_turn_off()
cc33xx_flush_deferred_work()
ieee80211_rx_ni() <-- hw already unregistered
cancel_work_sync(&netstack_work)
cc33xx_irq_work()
cc33xx_rx_get_packet_data()
queue_work(..., &netstack_work)
cancel_work_sync(&irq_deferred_work)
cc33xx_free_hw()
destroy_workqueue(freezable_netstack_wq)
cc33xx_netstack_work()
ieee80211_rx_ni() <-- use-after-free
In main.c, cc33xx_remove() calls cc33xx_unregister_hw() before
cc33xx_turn_off(), so cc33xx_flush_deferred_work() feeds frames into an
already-unregistered ieee80211_hw. Inside cc33xx_turn_off(),
cancel_work_sync(&cc->netstack_work) also runs before
cancel_work_sync(&cc->irq_deferred_work), allowing an in-flight
cc33xx_irq_work() to re-queue netstack_work after it was cancelled. Stopping
IRQs and cancelling irq_deferred_work before netstack_work, and shutting down
RX before ieee80211_unregister_hw(), would avoid both races.
[ ... ]
> + if (cc->partial_rx.status == CURR_RX_START) {
> + WARN_ON(*raw_buffer_len < 2);
> + desc = (struct cc33xx_rx_descriptor *)raw_buffer_ptr;
> + cc->partial_rx.original_bytes = le16_to_cpu(desc->length);
> + cc->partial_rx.handled_bytes = 0;
> + cc->partial_rx.status = CURR_RX_DESC;
> +
> + cc33xx_debug(cc->dev, DEBUG_RX, "rx frame. desc length 0x%x, alignment 0x%x, padding 0x%x\n",
> + desc->length, desc->header_alignment, desc->pad_len);
> + }
[Severity: Medium]
Can a split RX descriptor cause an out-of-bounds read and corrupt
cc->partial_rx.original_bytes here?
WARN_ON(*raw_buffer_len < 2) does not stop execution. If a transfer boundary
leaves 1 byte, desc->length reads 1 byte past the valid RX buffer into
partial_rx.original_bytes, and cc33xx_rx_get_packet_descriptor() never
reloads original_bytes from cc->partial_rx.desc.length after reassembly
completes, permanently desynchronizing the RX stream.
Even for larger split descriptors (*raw_buffer_len < 16), the debug print
reads desc->header_alignment and desc->pad_len (up to offset 14) past the
valid buffer when DEBUG_RX is enabled. Deferring both the length read and
the debug print until cc33xx_rx_get_packet_descriptor() finishes copying all
16 bytes would avoid reading incomplete descriptors.
[ ... ]
> +int cc33xx_rx(struct cc33xx *cc, u8 *rx_buf_ptr, u16 rx_buf_len)
> +{
> + u16 local_rx_buffer_len = rx_buf_len;
> + u16 pkt_offset = 0;
> + u16 consumed_bytes;
> + u16 prev_rx_buf_len;
> +
> + /* Split data into separate packets */
> + while (local_rx_buffer_len > 0) {
[Severity: High]
Can cc33xx_rx() read tens of kilobytes past cc->aggr_buf if
nab_rx_header->len is smaller than 8 or larger than the read transfer?
cc33xx_rx() trusts rx_buf_len directly, while its caller in main.c computes
it without bounds checking:
drivers/net/wireless/ti/cc33xx/main.c:cc33xx_irq_work() {
...
nab_rx_header = (struct nab_rx_header *)cc->aggr_buf;
rx_buf_len = le16_to_cpu(nab_rx_header->len) - 8;
if (rx_buf_len != 0) {
rx_buf_ptr = (u8 *)cc->aggr_buf + sizeof(struct nab_rx_header);
cc33xx_rx(cc, rx_buf_ptr, rx_buf_len);
...
}
If a bus glitch or hung firmware returns nab_rx_header->len < 8 (for example
0), u16 rx_buf_len underflows to 65528..65535, bypassing the rx_buf_len == 0
recovery path and causing cc33xx_rx() to parse well past the 32 KB
cc->aggr_buf allocation. The caller should validate nab_rx_header->len >= 8
and bound rx_buf_len against the actual read length and cc->aggr_buf_size.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203070906.1294171-1-r-ramalingam@ti.com?part=10
next prev parent reply other threads:[~2026-12-03 7:33 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 [this message]
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 ` [PATCH v6 14/17] wifi: cc33xx: Add conf.h 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-247293@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