Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Eric Dumazet <edumazet@kernel.org>,
	 "David S . Miller" <davem@davemloft.net>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Willem de Bruijn <willemb@google.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>,
	 Simon Horman <horms@kernel.org>,
	 netdev@vger.kernel.org,  Eric Dumazet <edumazet@kernel.org>
Subject: Re: [PATCH net-next 1/4] tap: detach queues from the NETDEV_UNREGISTER notifier
Date: Thu, 19 Nov 2026 18:46:19 -0500	[thread overview]
Message-ID: <willemdebruijn.kernel.16a070b2d3ffc@gmail.com> (raw)
In-Reply-To: <20261119072258.3157902-2-edumazet@kernel.org>

Eric Dumazet wrote:
> tap_del_queues() is currently called from the macvtap and ipvtap
> dellink handlers. Two things in this area only work because
> tap_open() runs under RTNL, which a following patch removes:
> 
> 1) Not all unregistrations go through dellink. If register_netdevice()
>    fails after the NETDEV_REGISTER notifier created the char device,
>    or if macvlan_common_newlink() / ipvlan_link_new() fail after
>    register_netdevice(), the device is unregistered without
>    tap_del_queues() being called. Nothing can open the char device in
>    this window today, because RTNL is held from the minor allocation
>    to its release.
> 
> 2) tap_del_queues() sets tap->numvtaps to MAX_TAP_QUEUES to "guarantee
>    that any future tap_set_queue will fail", but since commit
>    815f236d6227 ("macvtap: add TUNSETQUEUE ioctl") tap_set_queue()
>    tests tap->numqueues, which is zero at this point. A later
>    tap_set_queue() would succeed and write to tap->taps[MAX_TAP_QUEUES],
>    one element past the array. Again, this can not happen today since
>    the minor is released in the same RTNL section.
> 
> Call tap_del_queues() from the NETDEV_UNREGISTER notifier instead, so
> that every unregistration path is covered. The notifier is also invoked
> when the device moves to another netns, in which case the queues must
> stay attached: only act when the device is really being unregistered.
> 
> Replace the numvtaps trick with an explicit tap->dead flag, tested in
> tap_set_queue().
> 
> No functional change intended: none of the above is reachable as long
> as tap_open() holds RTNL. These issues were found by code inspection,
> with the help of an AI coding assistant, while looking at RTNL removal
> in tap. They were not triggered.
> 
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>

Reviewed-by: Willem de Bruijn <willemb@google.com>

  reply	other threads:[~2026-11-19 23:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  7:22 [PATCH net-next 0/4] tap: do not hold RTNL in open(), release() and queue ioctls Eric Dumazet
2026-11-19  7:22 ` [PATCH net-next 1/4] tap: detach queues from the NETDEV_UNREGISTER notifier Eric Dumazet
2026-11-19 23:46   ` Willem de Bruijn [this message]
2026-11-19  7:22 ` [PATCH net-next 2/4] tap: add a mutex to protect queue management Eric Dumazet
2026-11-19 23:49   ` Willem de Bruijn
2026-11-19  7:22 ` [PATCH net-next 3/4] tap: do not hold RTNL in open(), release() and queue ioctls Eric Dumazet
2026-11-19  7:22 ` [PATCH net-next 4/4] tap: remove tap_get_tap_dev() and tap_put_tap_dev() Eric Dumazet

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=willemdebruijn.kernel.16a070b2d3ffc@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.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