]> git.ipfire.org Git - thirdparty/linux.git/commit
net: udp_tunnel: prevent double queueing in udp_tunnel_nic_device_sync
authorEric Dumazet <edumazet@google.com>
Thu, 25 Jun 2026 06:59:36 +0000 (06:59 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Jun 2026 15:35:51 +0000 (08:35 -0700)
commitecf69d4b43370c587e48d4d70289dbdb7e039d4d
tree864b0868e13ff9b06174d62b2d08815fdb3e028c
parent02f144fbb4c86c360495d33debe307cb46a57f95
net: udp_tunnel: prevent double queueing in udp_tunnel_nic_device_sync

Yue Sun reported a use-after-free and debugobjects warning in
udp_tunnel_nic_device_sync_work() during concurrent device operations.

The workqueue core clears the internal pending bit before invoking the
worker. At that point, a concurrent thread can queue the work again.
When the already running worker eventually clears the work_pending flag
to 0, it mistakenly clears the flag for the newly queued instance.
udp_tunnel_nic_unregister() then observes work_pending as 0 and frees
the structure while the second work item is still active in the queue,
leading to UAF.

Fix this by returning early in udp_tunnel_nic_device_sync() if
work_pending is already set, preventing redundant work queueing.

Fixes: cc4e3835eff4 ("udp_tunnel: add central NIC RX port offload infrastructure")
Reported-by: Yue Sun <samsun1006219@gmail.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260625065938.654652-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/udp_tunnel_nic.c