[Openvpn-devel] [PATCH ovpn net v6 0/6] ovpn: fix key and workqueue lifetime issues

Ralf Lici <[email protected]> Wed, 29 Jul 2026 12:21:40 +0200
Newsgroups net.sourceforge.lists.openvpn-devel
Message-ID <[email protected]>
Hi,

This is a respin of the series that collects various ovpn fixes around
key-slot handling, netlink key notifications, TCP initialization
ordering, and teardown of deferred work.

This version has no more pending dependencies and incorporates the
changes discussed with Sabrina. In particular, patch 6/6 now uses
queue_rcu_work for key-slot release, instead of adding a key-slot
reference in ovpn_crypto_config_get.

The first three patches fix independent correctness issues: a NULL slot
dereference in the key-kill path, the key-id size used in key-swap
notifications, and TCP template initialization before the generic
netlink family is registered.

The last three patches fix lifetime problems where callback/workqueue
cleanup could continue after the reference that pins netdev/module
teardown had already been dropped. The series first makes crypto
callbacks finish their own cleanup before releasing the peer, then moves
ovpn work items to a module-owned workqueue that is flushed during
module exit, and finally defers key-slot AEAD transform freeing through
rcu_work so crypto_free_aead does not run from an RCU callback.

Thanks,

Ralf Lici
Mandelbit Srl

---
Changes since v5 https://lore.kernel.org/openvpn-devel/[email protected]/
- Rebase on top of OpenVPN/ovpn-net-next/main to include the missing
  dependencies from v5.
- Rework the key-kill NULL-slot fix using the slot-based shape
  (Sabrina).
- Add Sabrina's Reviewed-by tag to the key-id notification fix.
- Reword the TCP initialization fix and drop the extra comment
  (Sabrina).
- Use queue_rcu_work for key-slot release and update the module-exit
  ordering to flush ovpn_wq before rcu_barrier and destroy_workqueue
  (Sabrina).

Changes since v4 https://lore.kernel.org/openvpn-devel/981d2ea51cca45138210aa52c6e5a0e55c0da7a0.1783099626.git.ralf@mandelbit.com/
- Include the NULL-slot and key-id notification fixes in this series so
  the whole set can be picked in order.
- Add the TCP initialization ordering fix before the teardown/workqueue
  fixes.
- Rebase the workqueue conversion on the pending keepalive and TCP
  deferred-work refcount fixes listed above.

Ralf Lici (6):
  ovpn: fix NULL dereference when killing missing key
  ovpn: use nla_put_u32 for the key ID attribute in
    ovpn_nl_key_swap_notify
  ovpn: initialize TCP state before registering UAPI
  ovpn: finish crypto callback cleanup before peer release
  ovpn: run deferred work on a module-owned workqueue
  ovpn: defer key slot crypto freeing to workqueue

 drivers/net/ovpn/crypto.c      | 26 +++++++++++---------------
 drivers/net/ovpn/crypto.h      |  4 +++-
 drivers/net/ovpn/crypto_aead.c | 19 ++++++++++++++-----
 drivers/net/ovpn/crypto_aead.h |  1 -
 drivers/net/ovpn/io.c          | 10 +++++-----
 drivers/net/ovpn/main.c        | 26 ++++++++++++++++++++++----
 drivers/net/ovpn/netlink.c     |  2 +-
 drivers/net/ovpn/ovpnpriv.h    |  4 ++++
 drivers/net/ovpn/peer.c        |  8 ++++----
 drivers/net/ovpn/tcp.c         |  9 ++++-----
 10 files changed, 68 insertions(+), 41 deletions(-)

-- 
2.55.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel