All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: John Ernberg <john.ernberg@actia.se>
Cc: Oliver Neukum <oneukum@suse.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Ming Lei <ming.lei@canonical.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] net: usbnet: Avoid potential RCU stall on LINK_CHANGE event
Date: Fri, 18 Jul 2025 16:18:25 -0700	[thread overview]
Message-ID: <20250718161825.65912e37@kernel.org> (raw)
In-Reply-To: <55147f36-822b-4026-a091-33b909d1eea8@actia.se>

On Fri, 18 Jul 2025 09:07:26 +0000 John Ernberg wrote:
> > Thanks for the analysis, I think I may have misread the code.
> > What I was saying is that we are restoring the carrier while
> > we are still processing the previous carrier off event in
> > the workqueue. My thinking was that if we deferred the
> > netif_carrier_on() to the workqueue this race couldn't happen.
> > 
> > usbnet_bh() already checks netif_carrier_ok() - we're kinda duplicating
> > the carrier state with this RX_PAUSED workaround.
> > 
> > I don't feel strongly about this, but deferring the carrier_on()
> > the the workqueue would be a cleaner solution IMO.
> >   
> 
> I've been thinking about this idea, but I'm concerned for the opposite 
> direction. I cannot think of a way to fully guarantee that the carrier 
> isn't turned on again incorrectly if an off gets queued.
> 
> The most I came up with was adding an extra flag bit to set carrier on, 
> and then test_and_clear_bit() it in the __handle_link_change() function.
> And also clear_bit() in the usbnet_link_change() function if an off 
> arrives. I cannot convince myself that there isn't a way for that to go 
> sideways. But perhaps that would be robust enough?

I think it should be robust enough.. Unless my grep skills are failing
me - no drivers which call usbnet_link_change() twiddle the link state
directly.

Give it a go, if you think your initial patch is cleaner -- it's fine.

> I've also considered the possibility of just not re-submitting the INTR 
> poll URB until the last one was fully processed when handling a link 
> change. But that might cause havoc with ASIX and Sierra devices as they 
> are calling usbnet_link_change() in other ways than through the 
> .status-callback. I don't have any of these devices so I cannot test 
> them for regressions. So this path feels quite dangerous.
> With a sub-driver property to enable this behavior it might work out?

Yeah, that seems more involved.

  reply	other threads:[~2025-07-18 23:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-10  8:50 [PATCH] net: usbnet: Avoid potential RCU stall on LINK_CHANGE event John Ernberg
2025-07-14 23:35 ` Jakub Kicinski
2025-07-15  7:15   ` John Ernberg
2025-07-15 13:54     ` Jakub Kicinski
2025-07-16 14:54       ` John Ernberg
2025-07-16 21:39         ` Jakub Kicinski
2025-07-18  9:07           ` John Ernberg
2025-07-18 23:18             ` Jakub Kicinski [this message]
2025-07-23  9:29               ` John Ernberg
2025-07-15 11:49 ` 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=20250718161825.65912e37@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john.ernberg@actia.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ming.lei@canonical.com \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.