From: Brian Norris <briannorris@chromium.org>
To: Pin-yen Lin <treapking@chromium.org>
Cc: linux-wireless@vger.kernel.org, Kalle Valo <kvalo@kernel.org>,
Polaris Pi <pinkperfect2021@gmail.com>,
Matthew Wang <matthewmwang@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet
Date: Thu, 14 Sep 2023 16:38:13 -0700 [thread overview]
Message-ID: <ZQOZZZgHP2EeDNix@google.com> (raw)
In-Reply-To: <CAEXTbpc=QC6wC-W2VZCaRCp6rSpyNSsq5M6cxNcqAQxciNj0vg@mail.gmail.com>
On Thu, Sep 14, 2023 at 03:09:47PM +0800, Pin-yen Lin wrote:
> On Thu, Sep 14, 2023 at 4:31 AM Brian Norris <briannorris@chromium.org> wrote:
> > I'd appreciate another review/test from one of the others here
> > (Matthew?), even though I know y'all are already working together.
I'd still appreciate some comment here.
> > > - if ((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header,
> > > - sizeof(bridge_tunnel_header))) ||
> > > - (!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header,
> > > - sizeof(rfc1042_header)) &&
> > > - ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_AARP &&
> > > - ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_IPX)) {
> > > + if (sizeof(*rx_pkt_hdr) + rx_pkt_off <= skb->len &&
> >
> > Are you sure you want this length check to fall back to the non-802.3
> > codepath? Isn't it an error to look like an 802.3 frame but to be too
> > small? I'd think we want to drop such packets, not process them as-is.
>
> I did that because I saw other drivers (e.g., [1], [2]) use similar
> approaches, and I assumed that the rest of the pipeline will
> eventually drop it if the packet cannot be recognized. But, yes, we
> can just drop the packet here if it doesn't look good.
>
> [1]: https://elixir.bootlin.com/linux/latest/source/drivers/net/wireless/intersil/hostap/hostap_80211_rx.c#L1035
> [2]: https://elixir.bootlin.com/linux/latest/source/drivers/net/wireless/intel/ipw2x00/libipw_rx.c#L735
Hmm, I suppose. I'm frankly not sure how exactly all upper layers handle
this, but at least in a non-raw mode, we'll drop them. (We might be
delivering awfully weird packets to tcpdump though, but this is already
a weird situation, if it's such a weird-looking packet.)
> > If I'm correct, then this check should move inside the 'if' branch of
> > this if/else.
>
> We can't simply move the check inside the if branch because the
> condition also checks rx_pkt_hdr->rfc1042_hdr.snap_type. Though, of
> course, it is doable by adding another `if` conditions.
Right.
I guess this is probably OK as-is:
Acked-by: Brian Norris <briannorris@chromium.org>
next prev parent reply other threads:[~2023-09-14 23:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 10:41 [PATCH v3] wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet Pin-yen Lin
2023-09-13 20:31 ` Brian Norris
2023-09-14 7:09 ` Pin-yen Lin
2023-09-14 23:38 ` Brian Norris [this message]
2023-09-18 7:50 ` Matthew Wang
2023-09-18 13:06 ` Kalle Valo
2023-09-18 13:19 ` Kalle Valo
2023-09-19 12:31 ` Matthew Wang
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=ZQOZZZgHP2EeDNix@google.com \
--to=briannorris@chromium.org \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=matthewmwang@chromium.org \
--cc=pinkperfect2021@gmail.com \
--cc=treapking@chromium.org \
/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;
as well as URLs for NNTP newsgroup(s).