mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Sicong Huang <congei42@163.com>, netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] net: plip: cancel pending work before freeing device
Date: Tue, 19 May 2026 15:47:38 +0200	[thread overview]
Message-ID: <6ab22cc7-57d1-40d2-888b-76f0905ad5a2@redhat.com> (raw)
In-Reply-To: <20260515063155.3196112-1-congei42@163.com>

On 5/15/26 8:31 AM, Sicong Huang wrote:
> plip_close() stops the IRQ and the poll timer but does not cancel
> the immediate and deferred work items before returning. These two
> work items are initialised in plip_init_netdev() via
> INIT_WORK(&nl->immediate, plip_bh) and
> INIT_DELAYED_WORK(&nl->deferred, plip_kick_bh).
> plip_cleanup_module() calls free_netdev() which frees the
> net_local structure while those work items may still be queued or
> running in the workqueue, resulting in a use-after-free.
> 
> Fix this by calling cancel_delayed_work_sync() and cancel_work_sync()
> after all sources of new work scheduling have been shut down (IRQ
> disabled, poll timer stopped) but before releasing parport and
> freeing any skbs.
> 
> Signed-off-by: Sicong Huang <congei42@163.com>

This is a fix, should target the 'net' tree including such tag in the
subj prefix and should include a suitable 'Fixes:' tag in the tag area.
Please have an accurate read at:

Documentation/process/maintainer-netdev.rst

before reposting.

> ---
>  drivers/net/plip/plip.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c
> index d81163bc910a..4f0ab14f2024 100644
> --- a/drivers/net/plip/plip.c
> +++ b/drivers/net/plip/plip.c
> @@ -1141,6 +1141,9 @@ plip_close(struct net_device *dev)
>  		wait_for_completion(&nl->killed_timer_cmp);
>  	}
>  
> +	cancel_delayed_work_sync(&nl->deferred);
> +	cancel_work_sync(&nl->immediate);

Sashiko noted this is still racy:

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260515063155.3196112-1-congei42%40163.com

you should likely call disable_* at deattach() time.

/P


      reply	other threads:[~2026-05-19 13:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15  6:31 Sicong Huang
2026-05-19 13:47 ` Paolo Abeni [this message]

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=6ab22cc7-57d1-40d2-888b-76f0905ad5a2@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=congei42@163.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®