Linux wireless drivers development
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Maoyi Xie <maoyixie.tju@gmail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH rtw-next v2 1/4] wifi: rtw89: pci: reject oversized RX packets
Date: Fri, 4 Dec 2026 00:38:21 +0000	[thread overview]
Message-ID: <910e0b25dc5a425fbaa522873ebad7df@realtek.com> (raw)
In-Reply-To: <CAHPEe=GZXNAzrwVQHpV2zJz9ugAATNvo0dbHw=90HzLe5S3RFQ@mail.gmail.com>

Maoyi Xie <maoyixie.tju@gmail.com> wrote:
> Ping-Ke Shih <pkshih@realtek.com> wrote:
> > > +       if (unlikely(offset + copy_len > RTW89_PCI_RX_BUF_SIZE)) {
> >
> > You have validated 'rx_info->len <= RTW89_PCI_RX_BUF_SIZE', and
> >
> > u32 copy_len = rx_info->len - offset;
> >
> > I think this validation is unnecessary.
> 
> When rx_info->len is below offset, copy_len wraps. For fs && ls, the
> code then copies desc_info->pkt_size bytes, which the rx_info->len
> check does not bound.
> 
> Would a check in that branch be fine instead, like below?
> 
>                 if (fs && ls &&
>                     offset + desc_info->pkt_size <= RTW89_PCI_RX_BUF_SIZE) {

Did you mean this:

                /* length of a single segment skb is desc_info->pkt_size */
-               if (fs && ls) {
+               if (fs && ls &&
+                   offset + desc_info->pkt_size <= RTW89_PCI_RX_BUF_SIZE) {
                        copy_len = desc_info->pkt_size;
                } else {

It is in an unlikely path, so fine to me. 

By the way, in data path, I'd minimize validations. I think hardware will
report correct values as design. If not, how can it work... 

Ping-Ke


  reply	other threads:[~2026-12-04  0:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:05 [PATCH rtw-next v2 0/4] wifi: rtw89: check lengths and indices reported by the chip Maoyi Xie
2026-12-02  9:05 ` [PATCH rtw-next v2 1/4] wifi: rtw89: pci: reject oversized RX packets Maoyi Xie
2026-12-03  9:05   ` Ping-Ke Shih
2026-12-03 10:52     ` Maoyi Xie
2026-12-04  0:38       ` Ping-Ke Shih [this message]
2026-12-02  9:05 ` [PATCH rtw-next v2 2/4] wifi: rtw89: pci: validate hardware index of BD ring Maoyi Xie
2026-12-02  9:05 ` [PATCH rtw-next v2 3/4] wifi: rtw89: fw: check C2H event length Maoyi Xie
2026-12-03  9:10   ` Ping-Ke Shih
2026-12-02  9:05 ` [PATCH rtw-next v2 4/4] wifi: rtw89: phy: check cur_idx of TAS power report Maoyi Xie

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=910e0b25dc5a425fbaa522873ebad7df@realtek.com \
    --to=pkshih@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=maoyixie.tju@gmail.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