Netdev List
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Shihuang Liu <shlomojune6@gmail.com>
Cc: netdev@vger.kernel.org, ap420073@gmail.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] amt: fix use-after-free in AMT delayed works
Date: Tue, 21 Jul 2026 14:34:24 +0100	[thread overview]
Message-ID: <20260721133424.GJ19108@horms.kernel.org> (raw)
In-Reply-To: <20260714072705.129262-1-shlomojune6@gmail.com>

On Tue, Jul 14, 2026 at 03:27:05PM +0800, Shihuang Liu wrote:
> When an AMT device is removed, pending delayed works can still access
> the freed amt_dev structure, which may result in kernel crashes or
> memory corruption.
> 
> amt_dev_stop() cancels req_wq and discovery_wq with
> cancel_delayed_work_sync(), but these works can be scheduled again
> from event_wq after the cancellation. This allows delayed works to
> access the freed amt_dev structure after the netdev has been released.
> 
> The following is a simple race scenario:
> 
> CPU0                         CPU1
> 
> amt_dev_stop()
> cancel_delayed_work_sync()
>                              amt_event_work()
>                              mod_delayed_work(req_wq)
> free netdev
>                              req_wq accesses freed amt_dev
> 
> Use disable_delayed_work_sync() in amt_dev_stop() to prevent req_wq and
> discovery_wq from being queued again and wait for running work items
> to complete.
> 
> The delayed works are disabled after initialization in
> amt_newlink() and enabled only when the device is successfully opened.
> This keeps the delayed work lifecycle synchronized with the lifetime
> of the AMT device.
> 
> Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shihuang Liu <shlomojune6@gmail.com>

...

This patch seems fine to me, however, as it was not marked as
being for net our CI tried to apply it to net-next, which failed
due to a conflict there.

Please consider resubmitting with the patch targeted at the net tree like
this:

Subject: [PATCH REPOST net] ...

Feel free to include:

Reviewed-by: Simon Horman <horms@kernel.org>

Thanks!

-- 
pw-bot: changes-requested

      reply	other threads:[~2026-07-21 13:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  7:27 [PATCH] amt: fix use-after-free in AMT delayed works Shihuang Liu
2026-07-21 13:34 ` Simon Horman [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=20260721133424.GJ19108@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ap420073@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shlomojune6@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox