ovpn: disable BHs in async crypto completion callbacks
Subsystems (2)
PATCH 1/1 ovpn: disable BHs in async crypto completion callbacks
From: Antonio Quartulli <[email protected]>
ovpn_encrypt_post() and ovpn_decrypt_post() expect to run with BHs
disabled: they take socket spinlocks shared with softirq context, pass packets to gro_cells and update per-CPU stats. This holds on the synchronous path, but some async crypto drivers complete requests from a workqueue, a kthread or a threaded IRQ with BHs enabled (e.g. qce, starfive, keembay), which can deadlock or corrupt per-CPU state.
Wrap the async completion callbacks in local_bh_disable()/enable().
Fixes 8534731dbf2d ("ovpn: implement packet processing")
Signed-off-by Antonio Quartulli <[email protected]>
--- drivers/net/ovpn/crypto_aead.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/net/ovpn/crypto_aead.c +19 -2
@@ -135,6 +135,23 @@ static struct scatterlist *ovpn_aead_crypto_req_sg(struct crypto_aead *aead, __alignof__(struct scatterlist)); } +/* Async crypto drivers are expected to complete requests with BHs +* disabled, as the RX/TX paths require, but some do not: enforce it. +*/ +static void ovpn_aead_encrypt_done (void *data,int ret) +{ +local_bh_disable (); +ovpn_encrypt_post (data, ret); +local_bh_enable (); +} + +static void ovpn_aead_decrypt_done (void *data,int ret) +{ +local_bh_disable (); +ovpn_decrypt_post (data, ret); +local_bh_enable (); +} +int ovpn_aead_encrypt (struct ovpn_peer *peer,struct ovpn_crypto_key_slot *ks,struct sk_buff *skb) {
@@ -229,7 +246,7 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,/* setup async crypto operation */ aead_request_set_tfm (req, ks->encrypt); -aead_request_set_callback (req,0 , ovpn_encrypt_post, skb); +aead_request_set_callback (req,0 , ovpn_aead_encrypt_done, skb);aead_request_set_crypt (req, sg, sg, skb->len -ovpn_aead_encap_overhead (ks), iv);aead_request_set_ad (req,OVPN_AAD_SIZE );
@@ -316,7 +333,7 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,/* setup async crypto operation */ aead_request_set_tfm (req, ks->decrypt); -aead_request_set_callback (req,0 , ovpn_decrypt_post, skb); +aead_request_set_callback (req,0 , ovpn_aead_decrypt_done, skb);aead_request_set_crypt (req, sg, sg, payload_len + tag_size, iv);aead_request_set_ad (req,OVPN_AAD_SIZE );
Signature · 8 lines
2.56.1 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel