ovpn: finish crypto callback cleanup before peer release
authorRalf Lici <ralf@mandelbit.com>
Wed, 29 Jul 2026 10:21:44 +0000 (12:21 +0200)
committerAntonio Quartulli <antonio@openvpn.net>
Fri, 7 Aug 2026 00:12:13 +0000 (02:12 +0200)
commit9e163917a86c6adfbe150e13f4c73653a54616de
treec4012ab06c231265b40bfc392cf01bdd477e08fc
parent41d44ac7a61e2f74453af40d4fe1b82af9ea0ada
ovpn: finish crypto callback cleanup before peer release

Crypto completion callbacks hold both key-slot and peer references. The
peer reference pins the netdev, and dropping the last peer reference can
let netdev unregistration and module removal make progress.

Do not release that peer reference before the callback has finished its
own cleanup. If ovpn_crypto_key_slot_put runs after ovpn_peer_put, it can
schedule an RCU callback backed by module text after ovpn_cleanup
rcu_barrier has already run. The TX error path also freed the remaining
skb after ovpn_peer_put, leaving callback cleanup outside the peer/netdev
lifetime window.

Release the key slot and free any remaining skb first, then drop the peer
reference as the last callback action.

Fixes: 8534731dbf2d ("ovpn: implement packet processing")
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
drivers/net/ovpn/io.c