From: Yu Junzhe <junzheyu1@gmail.com>
To: David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG] ipv4: unregister_netdevice hang after flushing a DVMRP tunnel vif
Date: Tue, 1 Dec 2026 11:52:48 +0000 [thread overview]
Message-ID: <20261201115248.289-1-junzheyu1@gmail.com> (raw)
Hello,
I am reporting a netdevice refcount hang in IPv4 multicast routing.
MRT_ADD_VIF with VIFF_TUNNEL creates a dvmrp<vifi> IPIP device. MRT_FLUSH
with MRT_FLUSH_VIFS_STATIC removes that vif and unregisters the device, and
the unregister wait never finishes. The kernel prints:
unregister_netdevice: waiting for dvmrp3 to become free. Usage count = 2
netdev_wait_allrefs_any() returns only when the count is 1, so one reference
is still held. This needs CAP_NET_ADMIN (root in a new network namespace, no
user namespace). I do not claim privilege escalation. The result is a local
hang inside the flush setsockopt.
Summary
=======
On Linux 7.3.0-rc4 (93f51579e, tag v7.3-rc4), net/ipv4/ipmr.c:
ipmr_new_tunnel() issues SIOCADDTUNNEL on tunl0, names the device
dvmrp<vifi>, opens it, then dev_hold() and dev_set_allmulti(+1). The
reproducer does not call MRT_INIT. CAP_NET_ADMIN is enough for MRT_ADD_VIF,
and the socket is not the mroute socket, so the vif is VIFF_STATIC.
MRT_FLUSH (value MRT_FLUSH_VIFS_STATIC) calls mroute_clean_tables() with a
kill list. vif_delete() clears v->dev, dev_set_allmulti(-1), queues the
device with unregister_netdevice_queue() because it is VIFF_TUNNEL, and then
netdev_put(). unregister_netdevice_many() runs after that. The wait is in
the later netdev_run_todo() path.
So the ipmr hold is dropped before the wait. A stuck count of 2 is some
other reference that is still alive when the wait starts. I have not pinned
which one. The program also does one sendmsg on a still-open AF_INET6 raw
socket between the add and the flush. That socket is open for the whole
wait. I am not claiming that dst is the leftover hold.
MRT_DEL_VIF is a different order: a NULL kill list makes
unregister_netdevice_queue() wait inside vif_delete() before netdev_put().
This program uses MRT_FLUSH.
Guest log from the minimized program (2026-11-18):
[ 47.264753] dvmrp3: entered allmulticast mode
[ 47.265016] dvmrp3: left allmulticast mode
[ 57.280310] unregister_netdevice: waiting for dvmrp3 to become free. Usage count = 2
The ten second gap is netdev_unregister_timeout_secs. A packaged QEMU guest
on 7.3.0-rc4 (93f51579e) running the minimized program with syz-execprog
reproduces the same wait line. Config: CONFIG_IP_MROUTE=y, CONFIG_NET_IPIP=y, CONFIG_IP_PIMSM_V1=y,
CONFIG_IP_PIMSM_V2=y. CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set.
CONFIG_NET_DEV_REFCNT_TRACKER is not set.
Reproducer
==========
Syzkaller program, sandbox none, one thread. unshare flags are
CLONE_NEWNET|CLONE_NEWPID|CLONE_NEWIPC|CLONE_NEWNS|CLONE_FILES.
unshare(0x68020400)
r0 = socket$igmp(0x2, 0x3, 0x2)
setsockopt$MRT_ADD_VIF(r0, 0x0, 0xca, &(0x7f00000002c0)={0x3, 0x1, 0x9, 0x7, @vifc_lcl_addr=@broadcast, @dev={0xac, 0x14, 0x14, 0x1d}}, 0x10)
r1 = socket$inet6(0xa, 0x3, 0xff)
setsockopt$SO_TIMESTAMPING(r1, 0x1, 0x25, &(0x7f00000004c0)=0x6700, 0x4)
sendmsg(r1, &(0x7f0000000000)={&(0x7f0000000040)=@nl=@unspec={0x0, 0xff00, 0x0, 0x80fe}, 0x80, &(0x7f0000000140)=[{&(0x7f00000001c0)="b1b55feb45ef2b41bab2f4e24c5941c38be94acafd45f150ff54a2fd9aaefb5379116f0bf38357e8", 0x28}], 0x1}, 0x4048844)
setsockopt$MRT_FLUSH(r0, 0x0, 0xd4, &(0x7f0000000000)=0x8, 0x4)
MRT_ADD_VIF is optname 0xca (202). The vifctl is vifi 3, flags VIFF_TUNNEL
(1), local 255.255.255.255, remote 172.20.20.29, so the device is dvmrp3.
MRT_FLUSH is optname 0xd4 (212) with value 8 (MRT_FLUSH_VIFS_STATIC).
The hang starts inside the flush setsockopt, not at process exit.
Thanks,
Yu Junzhe <junzheyu1@gmail.com>
next reply other threads:[~2026-12-01 11:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 11:52 Yu Junzhe [this message]
2026-12-01 15:53 ` [BUG] ipv4: unregister_netdevice hang after flushing a DVMRP tunnel vif Ido Schimmel
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=20261201115248.289-1-junzheyu1@gmail.com \
--to=junzheyu1@gmail.com \
--cc=dsahern@kernel.org \
--cc=idosch@nvidia.com \
--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