From: "Luka Gejak" <luka.gejak@linux.dev>
To: "Ping-Ke Shih" <pkshih@realtek.com>,
"Huihui Huang" <hhhuang@smu.edu.sg>,
linux-wireless@vger.kernel.org
Subject: Re: [PATCH rtw-next v3 2/2] wifi: rtw88: check the C2H payload length before reading it
Date: Sun, 08 Nov 2026 07:25:08 +0000 [thread overview]
Message-ID: <bd0f7a6723a11810263d3e35eb41cd9a096f051d@linux.dev> (raw)
In-Reply-To: <bdb47a1dc13347448cff24a26a231478@realtek.com>
Hi Ping-Ke,
Just one comment on the struct idea.
November 8, 2026 at 3:56 AM, "Ping-Ke Shih" <pkshih@realtek.com> wrote:
>
> Huihui Huang <hhhuang@smu.edu.sg> wrote:
>
>>
>> + if (rtw_c2h_payload_len(skb) < 3) {
>
> The 3 is because of GET_SCAN_REPORT_RETURN_CODE(). How does people understand
> what 3 means?
>
> Maybe, we should define specific struct for status_report, like
>
> struct status_report {
> u8 id;
> u8 seq;
> u8 rsvd[2]
> u8 retrun_code;
> };
>
> struct status_report *status_report = get_c2h_from_skb(skb);
>
> if (rtw_c2h_payload_len(skb) < sizeof(*status_report))
Agreed, a struct is much easier to follow than the bare numbers. One
small thing though. This struct starts at the C2H header, but
rtw_c2h_payload_len() leaves the two header bytes out. So as far as I can
see the check would ask for 5 payload bytes while only 3 are read, and a
valid report with 3 or 4 payload bytes would be treated as too short.
Maybe the struct could cover only the payload, like struct rtw_c2h_ra_rpt
and struct rtw_c2h_adaptivity already do:
struct rtw_c2h_scan_status_rpt {
u8 rsvd[2];
u8 return_code;
} __packed;
Then it compares with rtw_c2h_payload_len() directly, and the same would
work for the channel switch report and the two TX report formats.
Best regards,
Luka Gejak
next prev parent reply other threads:[~2026-11-08 7:25 UTC|newest]
Thread overview: 8+ 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-08 2:31 ` Ping-Ke Shih
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
2026-11-08 2:56 ` Ping-Ke Shih
2026-11-08 7:25 ` Luka Gejak [this message]
2026-11-09 2:07 ` Ping-Ke Shih
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=bd0f7a6723a11810263d3e35eb41cd9a096f051d@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