From: "Luka Gejak" <luka.gejak@linux.dev>
To: "Huihui Huang" <hhhuang@smu.edu.sg>, linux-wireless@vger.kernel.org
Cc: "Huihui Huang" <hhhuang@smu.edu.sg>, "Ping-Ke Shih" <pkshih@realtek.com>
Subject: Re: [PATCH rtw-next v3 2/2] wifi: rtw88: check the C2H payload length before reading it
Date: Fri, 06 Nov 2026 14:12:22 +0000 [thread overview]
Message-ID: <1537d31634016c22bbcc8d04f9a09a99b78286f7@linux.dev> (raw)
In-Reply-To: <20261105125958.3891196-3-hhhuang@smu.edu.sg>
November 5, 2026 at 1:59 PM, "Huihui Huang" <hhhuang@smu.edu.sg> wrote:
>
> With the previous patch, a C2H packet holds at least the 2-byte C2H
> header, but its payload can still be shorter than what the handlers
> read. These handlers read fixed payload offsets without checking the
> payload length:
>
> - rtw_fw_scan_result() reads payload[0];
> - rtw_coex_info_response() reads payload[0];
> - rtw_fw_c2h_cmd_handle_ext() reads the sub-command ID in payload[0],
> and rtw_hw_scan_status_report() and rtw_hw_scan_chan_switch() read
> up to payload[2] and payload[4];
> - rtw_tx_report_handle() reads up to payload[6] for C2H_CCX_TX_RPT and
> payload[9] for C2H_CCX_RPT.
>
> With a short payload, these reads are beyond skb->len.
>
> Add rtw_c2h_payload_len() to get the payload length of a C2H skb, and
> ignore C2H packets whose payload is too short for the fields the
> handler reads. For C2H_SCAN_RESULT, check the length before completing
> fw_scan_density, so that a report without payload does not wake the
> waiter. A short HW scan status report is not ignored but completes the
> scan as aborted; otherwise the scan stays pending until something
> aborts it.
>
> For coexistence responses, this only validates the byte inspected by
> rtw_coex_info_response(). Length validation for the queued response's
> GET_COEX_RESP_*() consumers is left for a separate follow-up.
>
> Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
> Fixes: 4136214f7c46 ("rtw88: add BT co-existence support")
> Fixes: a853d234e179 ("rtw88: notify fw when driver in scan-period to avoid potential problem")
> Fixes: 10d162b2ed39 ("rtw88: 8822c: add ieee80211_ops::hw_scan")
> Suggested-by: Luka Gejak <luka.gejak@linux.dev>
> Assisted-by: LLM
> Signed-off-by: Huihui Huang <hhhuang@smu.edu.sg>
> ---
Looking good to me,
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
Best regards,
Luka Gejak
prev parent reply other threads:[~2026-11-06 14:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 12:59 [PATCH rtw-next v3 0/2] wifi: rtw88: check C2H header and payload lengths Huihui Huang
2026-11-05 12:59 ` [PATCH rtw-next v3 1/2] wifi: rtw88: drop C2H packets shorter than the C2H header Huihui Huang
2026-11-05 12:59 ` [PATCH rtw-next v3 2/2] wifi: rtw88: check the C2H payload length before reading it Huihui Huang
2026-11-06 14:12 ` Luka Gejak [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=1537d31634016c22bbcc8d04f9a09a99b78286f7@linux.dev \
--to=luka.gejak@linux.dev \
--cc=hhhuang@smu.edu.sg \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
/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