netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Oliver Neukum <oneukum@suse.com>
Cc: Ren Mingshuai <renmingshuai@huawei.com>,
	kuba@kernel.org, caowangbao@huawei.com, davem@davemloft.net,
	khlebnikov@openvz.org, liaichun@huawei.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	yanan@huawei.com
Subject: Re: [PATCH] net: usbnet: Fix potential NULL pointer dereference
Date: Mon, 06 Nov 2023 11:55:49 +0100	[thread overview]
Message-ID: <871qd3up56.fsf@miraculix.mork.no> (raw)
In-Reply-To: <80af8b7a-c543-4386-bb0c-a356189581a0@suse.com> (Oliver Neukum's message of "Mon, 6 Nov 2023 11:18:39 +0100")

Oliver Neukum <oneukum@suse.com> writes:

> yes it looks like NCM does funky things, but what does that mean?
>
> ndp_to_end_store()
>
>         /* flush pending data before changing flag */
>         netif_tx_lock_bh(dev->net);
>         usbnet_start_xmit(NULL, dev->net);
>         spin_lock_bh(&ctx->mtx);
>         if (enable)
>
> expects some odd semantics from it. The proposed patch simply
> increases the drop counter, which is by itself questionable, as
> we drop nothing.
>
> But it definitely does no IO, so we flush nothing.
> That is, we clearly have bug(s) but the patch only papers over
> them.
> And frankly, the basic question needs to be answered:
> Are you allowed to call ndo_start_xmit() with a NULL skb?
>
> My understanding until now was that you must not.

Yuck.  I see that I'm to blame for that code, so I've tried to figure
out what the idea behind it could possibly have been.

I believe that code is based on the (safe?) assumption that the struct
usbnet driver_info->tx_fixup points to cdc_ncm_tx_fixup().  And
cdc_ncm_tx_fixup does lots of weird stuff, including special handling of
NULL skb. It might return a valid skb for further processing by
usbnet_start_xmit().  If it doesn't, then we jump straight to
"not_drop", like we do when cdc_ncm_tx_fixup decides to eat the passed
skb.

But "funky" is i precise description of all this...  If someone feels
like it, then all that open coded skb queing inside cdc_ncm should be
completely rewritten.



Bjørn

  reply	other threads:[~2023-11-06 11:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 12:35 [PATCH] net: usbnet: Fix potential NULL pointer dereference Ren Mingshuai
2023-11-01 12:55 ` Ren Mingshuai
2023-11-02  4:38   ` Jakub Kicinski
2023-11-02  9:06     ` Ren Mingshuai
2023-11-06 10:18       ` Oliver Neukum
2023-11-06 10:55         ` Bjørn Mork [this message]
2023-11-06 12:53           ` Oliver Neukum
2023-11-06 12:59       ` Oliver Neukum

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=871qd3up56.fsf@miraculix.mork.no \
    --to=bjorn@mork.no \
    --cc=caowangbao@huawei.com \
    --cc=davem@davemloft.net \
    --cc=khlebnikov@openvz.org \
    --cc=kuba@kernel.org \
    --cc=liaichun@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=renmingshuai@huawei.com \
    --cc=yanan@huawei.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;
as well as URLs for NNTP newsgroup(s).