]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ovpn: run deferred work on a module-owned workqueue
authorRalf Lici <ralf@mandelbit.com>
Fri, 7 Aug 2026 07:55:43 +0000 (09:55 +0200)
committerAntonio Quartulli <antonio@openvpn.net>
Sun, 9 Aug 2026 20:47:57 +0000 (22:47 +0200)
commite9714db8041763f59dde152c812b96b3de05c6d9
tree006b5a86ad8d5ee293da109a8e6bac2912850a84
parent9e163917a86c6adfbe150e13f4c73653a54616de
ovpn: run deferred work on a module-owned workqueue

ovpn queues several work items whose callbacks execute module text.
These works currently run on the global system workqueues, so module
exit has no driver-owned drain point that guarantees the callbacks have
fully returned before the module text can be freed.

Object references protect the objects used by the callbacks, but they do
not prove that a workqueue function has returned. In particular, a
worker can drop the final reference that unblocks device teardown while
it is still executing ovpn code.

Add a module-owned workqueue and queue all ovpn work items on it. During
module exit, unregister rtnl and netlink first, flush the workqueue so
ordinary ovpn workers finish, run the final RCU barrier, and destroy the
workqueue last. This keeps the workqueue available for cleanup work
queued from RCU callbacks, while ensuring no ovpn work item can outlive
the module text.

The per-device delayed keepalive work remains explicitly disabled during
netdev teardown (disable_delayed_work_sync in ndo_uninit), since
flush_workqueue does not flush delayed work that is still only pending
on its timer.

Fixes: 3ecfd9349f40 ("ovpn: implement keepalive mechanism")
Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
drivers/net/ovpn/main.c
drivers/net/ovpn/ovpnpriv.h
drivers/net/ovpn/peer.c
drivers/net/ovpn/tcp.c