]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ovpn: defer key slot crypto freeing to workqueue
authorRalf Lici <ralf@mandelbit.com>
Wed, 29 Jul 2026 10:21:46 +0000 (12:21 +0200)
committerAntonio Quartulli <antonio@openvpn.net>
Sun, 9 Aug 2026 20:47:57 +0000 (22:47 +0200)
commit2da3dfa1ddfe55a065f484750c83660e3bd4ac00
treec652a881684149ba031a27a80b82011df2be702f
parente9714db8041763f59dde152c812b96b3de05c6d9
ovpn: defer key slot crypto freeing to workqueue

Key slots are released through a kref and the existing release path
frees the AEAD transforms from an RCU callback. That is not safe for all
crypto implementations: crypto_free_aead can sleep, for example when an
async or hardware implementation has teardown work to complete.

Use queue_rcu_work for key-slot release. This keeps the RCU grace period
needed by lockless key-slot readers, but runs the actual crypto teardown
from workqueue context where sleeping is allowed. Once the rcu_work
callback runs, pre-existing RCU readers are gone, and the final kref put
already proves that no transform user remains, so the worker can release
the AEAD transforms and free the slot directly.

The previous patch drains ovpn_wq during module exit, so queued key-slot
teardown work cannot outlive module text.

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/crypto.c
drivers/net/ovpn/crypto.h
drivers/net/ovpn/crypto_aead.c
drivers/net/ovpn/crypto_aead.h