From: Simon Horman <horms@kernel.org>
To: Omar Ramadan <omar@blockcast.net>
Cc: Taehee Yoo <ap420073@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] amt: tear down every amt device on an unregistering lower
Date: Wed, 11 Nov 2026 17:21:08 +0000 [thread overview]
Message-ID: <20261111172108.GH18859@horms.kernel.org> (raw)
In-Reply-To: <20261105232302.494171-1-omar@blockcast.net>
On Thu, Nov 05, 2026 at 11:23:02PM +0000, Omar Ramadan wrote:
> amt_device_event() acts only on the amt device that
> amt_lookup_upper_dev() returns, which is the first amt device bound to
> the event's lower. Several amt devices can share one lower, for
> example two gateways.
>
> On NETDEV_UNREGISTER, only the first device is unlinked and
> unregistered. The others stay upper-linked to the lower, and
> unregister_netdevice_many_notify() warns, because the notifier chain
> must detach every upper device. They also still hold a reference on
> the lower, so each is torn down only when netdev_wait_allrefs_any(),
> called from netdev_run_todo(), rebroadcasts NETDEV_UNREGISTER. By then
> the lower's sysfs directory is gone, so unlinking it trips a kernfs
> WARN, and unregistering it from inside the rebroadcast trips the WARN
> in __rtnl_unlock(). On NETDEV_CHANGEMTU, only the first device is
> resized.
>
> Walk every amt device in the lower's netns and act on each one bound
> to the lower. On NETDEV_UNREGISTER, queue them all and unregister them
> in one batch. amt_dellink() unlinks each device but leaves it on the
> netns device list until unregister_netdevice_many(), so the walk stays
> valid under RTNL.
>
> To reproduce:
>
> ip link add lower0 type dummy
> ip link add amtg1 type amt mode gateway local 192.0.2.1 \
> discovery 192.0.2.2 dev lower0
> ip link add amtg2 type amt mode gateway local 192.0.2.1 \
> discovery 192.0.2.2 dev lower0
> ip link del lower0
>
> Without this patch, the last command logs:
>
> WARNING: net/core/dev.c:12773 at unregister_netdevice_many_notify+0x13e5/0x1940, CPU#3: ip/216
> kernfs: can not remove 'upper_amtg2', no directory
> WARNING: fs/kernfs/dir.c:1784 at kernfs_remove_by_name_ns+0xc9/0xd0, CPU#0: ip/216
> WARNING: net/core/rtnetlink.c:141 at __rtnl_unlock+0xb2/0xf0, CPU#0: ip/216
> WARNING: net/core/rtnetlink.c:141 at __rtnl_unlock+0xb2/0xf0, CPU#0: ip/216
>
> With it, the commands log nothing and remove both amt devices, and
> tools/testing/selftests/net/amt.sh passes on a KASAN and lockdep
> kernel.
>
> Found by a selftest for our upcoming AMT offload RFC, which deletes a
> lower carrying two amt gateways, on our 6.18-based driver. The
> commands above reproduce it on net.
>
> Fixes: b9022b53adad ("amt: add control plane of amt interface")
> Assisted-by: LLM
> Signed-off-by: Omar Ramadan <omar@blockcast.net>
Reviewed-by: Simon Horman <horms@kernel.org>
prev parent reply other threads:[~2026-11-11 17:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 23:23 Omar Ramadan
2026-11-11 17:21 ` 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=20261111172108.GH18859@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=omar@blockcast.net \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®