Skip to contentSkip to conversation

ovpn: fix key and workqueue lifetime issues

PATCH Applied Ralf Lici 2 participants 13 messages Jul 29 – Aug 9

Subsystems (2)
lore
Share & tools
lore
author reviewer
#2 lore raw

PATCH v6 2/6 ovpn: use nla_put_u32 for the key ID attribute in ovpn_nl_key_swap_notify

In reply to Ralf Lici

Currently, in ovpn_nl_key_swap_notify, the OVPN_A_KEYCONF_KEY_ID attribute is packed as a 16-bit value despite being defined as a 32-bit u32 attribute in the YAML policy.

Fix this inconsistency by using nla_put_u32.

Fixes 89d3c0e4612a ("ovpn: kill key and notify userspace in case of IV exhaustion")

---
Changes since v5 https://lore.kernel.org/openvpn-devel/6e44855f0fcd704da43dd83b42a1236cb804c76e.1783336121.git.ralf@mandelbit.com/
- Add Sabrina's Reviewed-by tag.

Changes since v4 of this series https://lore.kernel.org/openvpn-devel/981d2ea51cca45138210aa52c6e5a0e55c0da7a0.1783099626.git.ralf@mandelbit.com/
- Add this previously posted standalone fix to the series so the whole
set can be picked in order.
- No changes since v1 of the original single patch
https://lore.kernel.org/openvpn-devel/8577555cc95646d0bd58a5b78e59c7e6a9b1a0c6.1783058844.git.ralf@mandelbit.com/

 drivers/net/ovpn/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ovpn/netlink.c +1 -1
index 4c66c1ec497e..abf038206a62 100644
@@ -1335,7 +1335,7 @@ int ovpn_nl_key_swap_notify(struct ovpn_peer *peer, u8 key_id)
 	if (nla_put_u32(msg, OVPN_A_KEYCONF_PEER_ID, peer->id))
 		goto err_cancel_msg;
 
-	if (nla_put_u16(msg, OVPN_A_KEYCONF_KEY_ID, key_id))
+	if (nla_put_u32(msg, OVPN_A_KEYCONF_KEY_ID, key_id))
 		goto err_cancel_msg;
 
 	nla_nest_end(msg, k_attr);
Signature · 8 lines
2.55.0



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

Ralf Lici

author reviewer
#0 lore raw

v6 cover ovpn: fix key and workqueue lifetime issues

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(-)
Signature · 8 lines
2.55.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
author reviewer
#1 lore raw

PATCH v6 1/6 ovpn: fix NULL dereference when killing missing key

ovpn_crypto_kill_key assumes both crypto slots are populated and dereferences each slot before checking it. That is not guaranteed: a peer can have only one installed key, and the kill path may be asked to remove a key that is not present.

Read each slot once while holding the crypto state lock, check for NULL before looking at key_id, and only replace the slot that actually matches.

Fixes 89d3c0e4612a ("ovpn: kill key and notify userspace in case of IV exhaustion")

---
Changes since v5 https://lore.kernel.org/openvpn-devel/b2f5120a3efa20c62a83397d96e949eac6a983df.1783336121.git.ralf@mandelbit.com/
- Rework using the slot-based shape (Sabrina).

Changes since v4 of this series https://lore.kernel.org/openvpn-devel/981d2ea51cca45138210aa52c6e5a0e55c0da7a0.1783099626.git.ralf@mandelbit.com/
- Add this previously posted standalone fix to the series so the whole
set can be picked in order.
- No changes since v2 of the original single patch
https://lore.kernel.org/openvpn-devel/19318904cf077d067cd4ec628a22bab03ed7dd29.1782993857.git.ralf@mandelbit.com/

Changes since v1 of the original single patch https://lore.kernel.org/openvpn-devel/9fc33e6f9fae10b9e372a3e06934d697edf5b024.1782829171.git.ralf@mandelbit.com/
- Remove unnecessary braces around single-statement if/else branches.

 drivers/net/ovpn/crypto.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/ovpn/crypto.c +10 -6
index 90580e32052f..2e95f29514fc 100644
@@ -58,15 +58,19 @@ void ovpn_crypto_state_release(struct ovpn_crypto_state *cs)
 bool ovpn_crypto_kill_key(struct ovpn_crypto_state *cs, u8 key_id)
 {
 	struct ovpn_crypto_key_slot *ks = NULL;
+	struct ovpn_crypto_key_slot *tmp;
+	int slot = 0;
 
 	spin_lock_bh(&cs->lock);
-	if (rcu_access_pointer(cs->slots[0])->key_id == key_id) {
-		ks = rcu_replace_pointer(cs->slots[0], NULL,
-					 lockdep_is_held(&cs->lock));
-	} else if (rcu_access_pointer(cs->slots[1])->key_id == key_id) {
-		ks = rcu_replace_pointer(cs->slots[1], NULL,
-					 lockdep_is_held(&cs->lock));
+	tmp = rcu_access_pointer(cs->slots[slot]);
+	if (!tmp || tmp->key_id != key_id) {
+		slot = 1;
+		tmp = rcu_access_pointer(cs->slots[slot]);
 	}
+
+	if (tmp && tmp->key_id == key_id)
+		ks = rcu_replace_pointer(cs->slots[slot], NULL,
+					 lockdep_is_held(&cs->lock));
 	spin_unlock_bh(&cs->lock);
 
 	if (ks)
Signature · 8 lines
2.55.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
author reviewer
#3 lore raw

PATCH v6 3/6 ovpn: initialize TCP state before registering UAPI

In reply to Ralf Lici

ovpn_tcp_init initializes the TCP proto and proto_ops templates used when a TCP socket is attached to an ovpn peer, but ovpn_init registers the generic netlink family before initializing those templates. Once the family is visible, userspace can create an ovpn device and configure a TCP socket while the TCP templates are still zero-initialized.

Initialize the TCP templates before publishing the netlink interfaces, so externally reachable setup paths can only observe initialized TCP state.

Fixes 11851cbd60ea ("ovpn: implement TCP transport")

---
Changes since v5 https://lore.kernel.org/openvpn-devel/8f7261c5719fd67b8f0da4d0e89f2c4517fa8168.1783336121.git.ralf@mandelbit.com/
- Reword the message and drop the extra comment in the code (Sabrina).

New patch added in v5.

 drivers/net/ovpn/main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ovpn/main.c +4 -3
index 9993c1dfe471..5093a3b5aba6 100644
@@ -233,8 +233,11 @@ static struct rtnl_link_ops ovpn_link_ops = {
 
 static int __init ovpn_init(void)
 {
-	int err = rtnl_link_register(&ovpn_link_ops);
+	int err;
 
+	ovpn_tcp_init();
+
+	err = rtnl_link_register(&ovpn_link_ops);
 	if (err) {
 		pr_err("ovpn: can't register rtnl link ops: %d\n", err);
 		return err;
@@ -246,8 +249,6 @@ static int __init ovpn_init(void)
 		goto unreg_rtnl;
 	}
 
-	ovpn_tcp_init();
-
 	return 0;
 
 unreg_rtnl:
Signature · 8 lines
2.55.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
author reviewer
#5 lore raw

PATCH v6 4/6 ovpn: finish crypto callback cleanup before peer release

In reply to Ralf Lici

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")

---
No changes since v5 https://lore.kernel.org/openvpn-devel/7336c4c945f4d8f816b57da2525c8f7b037cfa46.1783336121.git.ralf@mandelbit.com/

No changes since v4 https://lore.kernel.org/openvpn-devel/981d2ea51cca45138210aa52c6e5a0e55c0da7a0.1783099626.git.ralf@mandelbit.com/

No changes since v3 https://lore.kernel.org/openvpn-devel/f367b736f2597edb1677794173997d5a0f9f599c.1783080055.git.ralf@mandelbit.com/

Changes since v2 https://lore.kernel.org/openvpn-devel/567de7a9371ce72b0632158799dd11bb543cae08.1783068961.git.ralf@mandelbit.com/
- Also free the remaining TX skb before dropping the peer reference, so
crypto callbacks do not continue cleanup after peer release.

 drivers/net/ovpn/io.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ovpn/io.c +5 -5
index 9a66d693039a..9526f8096da6 100644
@@ -204,10 +204,10 @@ void ovpn_decrypt_post(void *data, int ret)
 		ovpn_dev_dstats_rx_dropped(peer->ovpn->dev);
 	kfree_skb(skb);
 drop_nocount:
-	if (likely(peer))
-		ovpn_peer_put(peer);
 	if (likely(ks))
 		ovpn_crypto_key_slot_put(ks);
+	if (likely(peer))
+		ovpn_peer_put(peer);
 }
 
 /* RX path entry point: decrypt packet and forward it to the device */
@@ -302,11 +302,11 @@ void ovpn_encrypt_post(void *data, int ret)
 err:
 	if (unlikely(skb))
 		ovpn_dev_dstats_tx_dropped(peer->ovpn->dev);
-	if (likely(peer))
-		ovpn_peer_put(peer);
+	kfree_skb(skb);
 	if (likely(ks))
 		ovpn_crypto_key_slot_put(ks);
-	kfree_skb(skb);
+	if (likely(peer))
+		ovpn_peer_put(peer);
 }
 
 static bool ovpn_encrypt_one(struct ovpn_peer *peer, struct sk_buff *skb)
Signature · 8 lines
2.55.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
author reviewer
#6 lore raw

PATCH v6 5/6 ovpn: run deferred work on a module-owned workqueue

In reply to Ralf Lici

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")

---
Changes since v5 https://lore.kernel.org/openvpn-devel/d530ecfc3719845075fbddd0cd7c34752bc2ce16.1783336121.git.ralf@mandelbit.com/
- Update the module-exit ordering for the queue_rcu_work-based key-slot
release: flush ordinary ovpn work before rcu_barrier, then destroy the
workqueue after RCU callbacks have queued their cleanup work.

Changes since v4 https://lore.kernel.org/openvpn-devel/6edfcc51e0855bfd34286b86d4e7f26bb3bcd3f7.1783099626.git.ralf@mandelbit.com/
- Rebase on the pending keepalive and TCP deferred-work refcount fixes,
preserving their hold-before-queue and queue-failure put handling when
converting schedule_work to queue_work.

Changes since v3 https://lore.kernel.org/openvpn-devel/49f38f89340e18ed30543d3990a7a7e20595b6af.1783080055.git.ralf@mandelbit.com/
- Replace the RCU-deferred peer netdev reference release with a
module-owned workqueue that drains all ovpn work callbacks before
module text can be freed.

 drivers/net/ovpn/main.c     | 19 ++++++++++++++++++-
 drivers/net/ovpn/ovpnpriv.h |  4 ++++
 drivers/net/ovpn/peer.c     |  8 ++++----
 drivers/net/ovpn/tcp.c      |  9 ++++-----
 4 files changed, 30 insertions(+), 10 deletions(-)
drivers/net/ovpn/main.c +18 -1
index 5093a3b5aba6..80d10f9ef7d8 100644
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/inetdevice.h>
+#include <linux/workqueue.h>
 #include <net/gro_cells.h>
 #include <net/ip.h>
 #include <net/rtnetlink.h>
@@ -26,6 +27,9 @@
 #include "tcp.h"
 #include "udp.h"
 
+/* module-owned workqueue on which all ovpn-specific work is queued */
+struct workqueue_struct *ovpn_wq;
+
 static void ovpn_priv_free(struct net_device *net)
 {
 	struct ovpn_priv *ovpn = netdev_priv(net);
@@ -237,10 +241,16 @@ static int __init ovpn_init(void)
 
 	ovpn_tcp_init();
 
+	ovpn_wq = alloc_workqueue("ovpn", 0, 0);
+	if (!ovpn_wq) {
+		pr_err("ovpn: cannot allocate workqueue\n");
+		return -ENOMEM;
+	}
+
 	err = rtnl_link_register(&ovpn_link_ops);
 	if (err) {
 		pr_err("ovpn: can't register rtnl link ops: %d\n", err);
-		return err;
+		goto destroy_wq;
 	}
 
 	err = ovpn_nl_register();
@@ -253,6 +263,9 @@ static int __init ovpn_init(void)
 
 unreg_rtnl:
 	rtnl_link_unregister(&ovpn_link_ops);
+destroy_wq:
+	destroy_workqueue(ovpn_wq);
+	ovpn_wq = NULL;
 	return err;
 }
 
@@ -261,7 +274,11 @@ static __exit void ovpn_cleanup(void)
 	ovpn_nl_unregister();
 	rtnl_link_unregister(&ovpn_link_ops);
 
+	flush_workqueue(ovpn_wq);
 	rcu_barrier();
+
+	destroy_workqueue(ovpn_wq);
+	ovpn_wq = NULL;
 }
 
 module_init(ovpn_init);
drivers/net/ovpn/ovpnpriv.h +4 -0
index 5898f6adada7..84499140e4bd 100644
@@ -15,6 +15,10 @@
 #include <uapi/linux/if_link.h>
 #include <uapi/linux/ovpn.h>
 
+struct workqueue_struct;
+
+extern struct workqueue_struct *ovpn_wq;
+
 /**
  * struct ovpn_peer_collection - container of peers for MultiPeer mode
  * @by_id: table of peers index by ID
drivers/net/ovpn/peer.c +4 -4
index a21d02ac715e..a80e85a62af5 100644
@@ -62,7 +62,7 @@ void ovpn_peer_keepalive_set(struct ovpn_peer *peer, u32 interval, u32 timeout)
 	/* now that interval and timeout have been changed, kick
 	 * off the worker so that the next delay can be recomputed
 	 */
-	mod_delayed_work(system_percpu_wq, &peer->ovpn->keepalive_work, 0);
+	mod_delayed_work(ovpn_wq, &peer->ovpn->keepalive_work, 0);
 }
 
 /**
@@ -1287,7 +1287,7 @@ static time64_t ovpn_peer_keepalive_work_single(struct ovpn_peer *peer,
 			   peer->id);
 		if (WARN_ON(!ovpn_peer_hold(peer)))
 			return 0;
-		if (!schedule_work(&peer->keepalive_work))
+		if (!queue_work(ovpn_wq, &peer->keepalive_work))
 			ovpn_peer_put(peer);
 	}
 
@@ -1379,8 +1379,8 @@ void ovpn_peer_keepalive_work(struct work_struct *work)
 		netdev_dbg(ovpn->dev,
 			   "scheduling keepalive work: now=%llu next_run=%llu delta=%llu\n",
 			   next_run, now, next_run - now);
-		schedule_delayed_work(&ovpn->keepalive_work,
-				      (next_run - now) * HZ);
+		queue_delayed_work(ovpn_wq, &ovpn->keepalive_work,
+				   (next_run - now) * HZ);
 	}
 	unlock_ovpn(ovpn, &release_list);
 }
drivers/net/ovpn/tcp.c +4 -5
index 0af14055c39a..8fe8a8e750a4 100644
@@ -151,7 +151,7 @@ static void ovpn_tcp_rcv(struct strparser *strp, struct sk_buff *skb)
 	/* take reference for deferred peer deletion. should never fail */
 	if (WARN_ON(!ovpn_peer_hold(peer)))
 		goto err_nopeer;
-	if (!schedule_work(&peer->tcp.defer_del_work))
+	if (!queue_work(ovpn_wq, &peer->tcp.defer_del_work))
 		ovpn_peer_put(peer);
 	ovpn_dev_dstats_rx_dropped(peer->ovpn->dev);
 err_nopeer:
@@ -284,13 +284,12 @@ static void ovpn_tcp_send_sock(struct ovpn_peer *peer, struct sock *sk)
 			 * stream therefore we abort the connection
 			 */
 			ovpn_peer_hold(peer);
-			if (!schedule_work(&peer->tcp.defer_del_work))
+			if (!queue_work(ovpn_wq, &peer->tcp.defer_del_work))
 				ovpn_peer_put(peer);
 
 			/* we bail out immediately and keep tx_in_progress set
 			 * to true. This way we prevent more TX attempts
-			 * which would lead to more invocations of
-			 * schedule_work()
+			 * which would lead to more invocations of queue_work()
 			 */
 			return;
 		}
@@ -487,7 +486,7 @@ static void ovpn_tcp_write_space(struct sock *sk)
 	rcu_read_lock();
 	sock = rcu_dereference_sk_user_data(sk);
 	if (likely(sock && sock->peer)) {
-		schedule_work(&sock->tcp_tx_work);
+		queue_work(ovpn_wq, &sock->tcp_tx_work);
 		sock->peer->tcp.sk_cb.sk_write_space(sk);
 	}
 	rcu_read_unlock();
Signature · 8 lines
2.55.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
author reviewer
#11 lore raw

PATCH v6 6/6 ovpn: defer key slot crypto freeing to workqueue

In reply to Ralf Lici

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")

---
Changes since v5 https://lore.kernel.org/openvpn-devel/5e4de5963ea48d7e7431e55192f0d6a5784c2a47.1783336121.git.ralf@mandelbit.com/
- Use queue_rcu_work for key-slot release so RCU readers are preserved
without adding a key-slot reference in ovpn_crypto_config_get
(Sabrina).

No changes since v4 https://lore.kernel.org/openvpn-devel/b53ae1a9714bae7081c71bdab7b30623ce3cb77b.1783099626.git.ralf@mandelbit.com/

Changes since v3 https://lore.kernel.org/openvpn-devel/ac2842c8e759849c51447126343376dcc793c7ae.1783080055.git.ralf@mandelbit.com/
- Reuse the module-owned ovpn workqueue instead of allocating a
crypto-specific workqueue for key-slot teardown.

Changes since v2 https://lore.kernel.org/openvpn-devel/b5dfebec718f230783ff47aa354c3b3fa1aa2ed7.1783068961.git.ralf@mandelbit.com/
- Reword the message to note the dependency on patch 1.

Changes since v1 https://lore.kernel.org/openvpn-devel/350f6b48c363dde5a8d0bdf7a1b9fd2abb8b1034.1783057762.git.ralf@mandelbit.com/
- Fix a potential AEAD transform UAF in ovpn_crypto_config_get by
holding a slot kref while reading the cipher algorithm.

 drivers/net/ovpn/crypto.c      | 10 +---------
 drivers/net/ovpn/crypto.h      |  4 +++-
 drivers/net/ovpn/crypto_aead.c | 19 ++++++++++++++-----
 drivers/net/ovpn/crypto_aead.h |  1 -
 4 files changed, 18 insertions(+), 16 deletions(-)
drivers/net/ovpn/crypto.c +1 -9
index 2e95f29514fc..7e545428900a 100644
@@ -18,20 +18,12 @@
 #include "crypto_aead.h"
 #include "crypto.h"
 
-static void ovpn_ks_destroy_rcu(struct rcu_head *head)
-{
-	struct ovpn_crypto_key_slot *ks;
-
-	ks = container_of(head, struct ovpn_crypto_key_slot, rcu);
-	ovpn_aead_crypto_key_slot_destroy(ks);
-}
-
 void ovpn_crypto_key_slot_release(struct kref *kref)
 {
 	struct ovpn_crypto_key_slot *ks;
 
 	ks = container_of(kref, struct ovpn_crypto_key_slot, refcount);
-	call_rcu(&ks->rcu, ovpn_ks_destroy_rcu);
+	queue_rcu_work(ovpn_wq, &ks->free_work);
 }
 
 /* can only be invoked when all peer references have been dropped (i.e. RCU
drivers/net/ovpn/crypto.h +3 -1
index 0e284fec3a75..e3feb16d5498 100644
@@ -10,6 +10,8 @@
 #ifndef _NET_OVPN_OVPNCRYPTO_H_
 #define _NET_OVPN_OVPNCRYPTO_H_
 
+#include <linux/workqueue.h>
+
 #include "pktid.h"
 #include "proto.h"
 
@@ -45,8 +47,8 @@ struct ovpn_crypto_key_slot {
 
 	struct ovpn_pktid_recv pid_recv ____cacheline_aligned_in_smp;
 	struct ovpn_pktid_xmit pid_xmit ____cacheline_aligned_in_smp;
+	struct rcu_work free_work;
 	struct kref refcount;
-	struct rcu_head rcu;
 };
 
 struct ovpn_crypto_state {
drivers/net/ovpn/crypto_aead.c +14 -5
index 8f07c418622b..74eaf6fac2f5 100644
@@ -9,6 +9,7 @@
 
 #include <crypto/aead.h>
 #include <linux/skbuff.h>
+#include <linux/workqueue.h>
 #include <net/ip.h>
 #include <net/ipv6.h>
 #include <net/udp.h>
@@ -380,13 +381,19 @@ static struct crypto_aead *ovpn_aead_init(const char *title,
 	return ERR_PTR(ret);
 }
 
-void ovpn_aead_crypto_key_slot_destroy(struct ovpn_crypto_key_slot *ks)
+static void ovpn_aead_crypto_key_slot_free(struct ovpn_crypto_key_slot *ks)
 {
-	if (!ks)
-		return;
-
 	crypto_free_aead(ks->encrypt);
 	crypto_free_aead(ks->decrypt);
+}
+
+static void ovpn_aead_crypto_key_slot_free_work(struct work_struct *work)
+{
+	struct ovpn_crypto_key_slot *ks;
+
+	ks = container_of(to_rcu_work(work), struct ovpn_crypto_key_slot,
+			  free_work);
+	ovpn_aead_crypto_key_slot_free(ks);
 	kfree(ks);
 }
 
@@ -420,6 +427,7 @@ ovpn_aead_crypto_key_slot_new(const struct ovpn_key_config *kc)
 
 	ks->encrypt = NULL;
 	ks->decrypt = NULL;
+	INIT_RCU_WORK(&ks->free_work, ovpn_aead_crypto_key_slot_free_work);
 	kref_init(&ks->refcount);
 	ks->key_id = kc->key_id;
 
@@ -453,7 +461,8 @@ ovpn_aead_crypto_key_slot_new(const struct ovpn_key_config *kc)
 	return ks;
 
 destroy_ks:
-	ovpn_aead_crypto_key_slot_destroy(ks);
+	ovpn_aead_crypto_key_slot_free(ks);
+	kfree(ks);
 	return ERR_PTR(ret);
 }
 
drivers/net/ovpn/crypto_aead.h +0 -1
index 65a2ff307898..fae3b585a43b 100644
@@ -22,7 +22,6 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,
 
 struct ovpn_crypto_key_slot *
 ovpn_aead_crypto_key_slot_new(const struct ovpn_key_config *kc);
-void ovpn_aead_crypto_key_slot_destroy(struct ovpn_crypto_key_slot *ks);
 
 enum ovpn_cipher_alg ovpn_aead_crypto_alg(struct ovpn_crypto_key_slot *ks);
 
Signature · 8 lines
2.55.0



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

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

In reply to Ralf Lici

From: Antonio Quartulli <[email protected]>

Quoted 10 lines · Ralf Lici

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.

[...]

Applied, thanks!

[1/6] ovpn: fix NULL dereference when killing missing key

      commit: eeb8f94b9b0fbd7f08ac81361d937c3d11d9df00
[2/6] ovpn: use nla_put_u32 for the key ID attribute in ovpn_nl_key_swap_notify
      commit: 1425d5ff5add800187371aef1519cb029f83959c
[4/6] ovpn: finish crypto callback cleanup before peer release
      commit: 0627b2c23ee28fe6f8e7ae1b62602b59831c6ec6
[5/6] ovpn: run deferred work on a module-owned workqueue
      commit: 0c377eff1548138430a6fd1a19f014e4aa87d1c0
[6/6] ovpn: defer key slot crypto freeing to workqueue
      commit: 217b85519877263bf59d38c2c00781d3fe93c676

Best regards,

Signature · 7 lines
Antonio Quartulli <[email protected]>


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

Re: [Openvpn-devel] [PATCH ovpn net v6 3/6] ovpn: initialize TCP state before registering UAPI

In reply to Ralf Lici

Hi,

Quoted 6 lines · Ralf Lici

ovpn_tcp_init initializes the TCP proto and proto_ops templates used when a TCP socket is attached to an ovpn peer, but ovpn_init registers the generic netlink family before initializing those templates. Once the family is visible, userspace can create an ovpn device and configure a TCP socket while the TCP templates are still zero-initialized.

Quoted 6 lines

Initialize the TCP templates before publishing the netlink interfaces, so externally reachable setup paths can only observe initialized TCP state.

Fixes 11851cbd60ea ("ovpn: implement TCP transport")

This patch was dropped in favour of another patch of mine which was basically colliding on the same change.

The mentioned patch has already landed in net.

Regards,

Signature · 8 lines
Antonio Quartulli



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

Re: [Openvpn-devel] [PATCH ovpn net v6 5/6] ovpn: run deferred work on a module-owned workqueue

In reply to Ralf Lici

Hi Ralf,

Quoted 70 lines · Ralf Lici

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")

---
Changes since v5 https://lore.kernel.org/openvpn-devel/d530ecfc3719845075fbddd0cd7c34752bc2ce16.1783336121.git.ralf@mandelbit.com/
- Update the module-exit ordering for the queue_rcu_work-based key-slot
release: flush ordinary ovpn work before rcu_barrier, then destroy the
workqueue after RCU callbacks have queued their cleanup work.

Changes since v4 https://lore.kernel.org/openvpn-devel/6edfcc51e0855bfd34286b86d4e7f26bb3bcd3f7.1783099626.git.ralf@mandelbit.com/
- Rebase on the pending keepalive and TCP deferred-work refcount fixes,
preserving their hold-before-queue and queue-failure put handling when
converting schedule_work to queue_work.

Changes since v3 https://lore.kernel.org/openvpn-devel/49f38f89340e18ed30543d3990a7a7e20595b6af.1783080055.git.ralf@mandelbit.com/
- Replace the RCU-deferred peer netdev reference release with a
module-owned workqueue that drains all ovpn work callbacks before
module text can be freed.

  drivers/net/ovpn/main.c     | 19 ++++++++++++++++++-
  drivers/net/ovpn/ovpnpriv.h |  4 ++++
  drivers/net/ovpn/peer.c     |  8 ++++----
  drivers/net/ovpn/tcp.c      |  9 ++++-----
  4 files changed, 30 insertions(+), 10 deletions(-)
drivers/net/ovpn/main.c +4 -0
index 5093a3b5aba6..80d10f9ef7d8 100644
@@ -12,6 +12,7 @@
  #include <linux/module.h>
  #include <linux/netdevice.h>
  #include <linux/inetdevice.h>
+#include <linux/workqueue.h>
  #include <net/gro_cells.h>
  #include <net/ip.h>
  #include <net/rtnetlink.h>
@@ -26,6 +27,9 @@
  #include "tcp.h"
  #include "udp.h"
 
+/* module-owned workqueue on which all ovpn-specific work is queued */
+struct workqueue_struct *ovpn_wq;
+
  static void ovpn_priv_free(struct net_device *net)
  {
  	struct ovpn_priv *ovpn = netdev_priv(net);

drivers/net/ovpn/main.c static int __init ovpn_init(void) · line 244

Quoted 4 lines
drivers/net/ovpn/main.c +1 -0
@@ -237,10 +241,16 @@ static int __init ovpn_init(void)
 
  	ovpn_tcp_init();
 
+	ovpn_wq = alloc_workqueue("ovpn", 0, 0);

This is triggering:

workqueue: ovpn is using neither WQ_PERCPU or WQ_UNBOUND. Setting WQ_PERCPU.

WARNING: kernel/workqueue.c:5852 at __alloc_workqueue+0x1cf5/0x2060, CPU#0: swapper/0/1

Can you fix it and resend this patch only please?

Regards,

Signature · 8 lines
Antonio Quartulli



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
author reviewer
#8 lore raw

Re: [Openvpn-devel] [PATCH ovpn net v6 5/6] ovpn: run deferred work on a module-owned workqueue

From: [email protected]

Quoted 81 lines · Antonio Quartulli

Hi Ralf,

Quoted 70 lines · Ralf Lici

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")

---
Changes since v5 https://lore.kernel.org/openvpn-devel/d530ecfc3719845075fbddd0cd7c34752bc2ce16.1783336121.git.ralf@mandelbit.com/
- Update the module-exit ordering for the queue_rcu_work-based key-slot
release: flush ordinary ovpn work before rcu_barrier, then destroy the
workqueue after RCU callbacks have queued their cleanup work.

Changes since v4 https://lore.kernel.org/openvpn-devel/6edfcc51e0855bfd34286b86d4e7f26bb3bcd3f7.1783099626.git.ralf@mandelbit.com/
- Rebase on the pending keepalive and TCP deferred-work refcount fixes,
preserving their hold-before-queue and queue-failure put handling when
converting schedule_work to queue_work.

Changes since v3 https://lore.kernel.org/openvpn-devel/49f38f89340e18ed30543d3990a7a7e20595b6af.1783080055.git.ralf@mandelbit.com/
- Replace the RCU-deferred peer netdev reference release with a
module-owned workqueue that drains all ovpn work callbacks before
module text can be freed.

  drivers/net/ovpn/main.c     | 19 ++++++++++++++++++-
  drivers/net/ovpn/ovpnpriv.h |  4 ++++
  drivers/net/ovpn/peer.c     |  8 ++++----
  drivers/net/ovpn/tcp.c      |  9 ++++-----
  4 files changed, 30 insertions(+), 10 deletions(-)
drivers/net/ovpn/main.c +4 -0
index 5093a3b5aba6..80d10f9ef7d8 100644
@@ -12,6 +12,7 @@
  #include <linux/module.h>
  #include <linux/netdevice.h>
  #include <linux/inetdevice.h>
+#include <linux/workqueue.h>
  #include <net/gro_cells.h>
  #include <net/ip.h>
  #include <net/rtnetlink.h>
@@ -26,6 +27,9 @@
  #include "tcp.h"
  #include "udp.h"
 
+/* module-owned workqueue on which all ovpn-specific work is queued */
+struct workqueue_struct *ovpn_wq;
+
  static void ovpn_priv_free(struct net_device *net)
  {
  	struct ovpn_priv *ovpn = netdev_priv(net);

drivers/net/ovpn/main.c static int __init ovpn_init(void) · line 244

Quoted 4 lines
drivers/net/ovpn/main.c +1 -0
@@ -237,10 +241,16 @@ static int __init ovpn_init(void)
 
  	ovpn_tcp_init();
 
+	ovpn_wq = alloc_workqueue("ovpn", 0, 0);

This is triggering:

Quoted 7 lines

workqueue: ovpn is using neither WQ_PERCPU or WQ_UNBOUND. Setting WQ_PERCPU.

WARNING: kernel/workqueue.c:5852 at __alloc_workqueue+0x1cf5/0x2060, 

CPU#0: swapper/0/1

Can you fix it and resend this patch only please?

Sure. Apparently the development tree used for this series predated commit 21c05ca88a54 ("workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present"), which now warns when the selection is implicit.

I'll resend this patch, explicitly selecting WQ_PERCPU to preserve the existing workqueue behavior.

Quoted 3 lines

Regards,

Regards,

Signature · 8 lines
Ralf Lici
Mandelbit Srl


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
author reviewer
#9 lore raw

PATCH v7 1/1 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")

---
Changes since v6 https://lore.kernel.org/openvpn-devel/51a8febf0da1fe17e5fc0b857e8d0a8797002ea2.1785318038.git.ralf@mandelbit.com/
- Pass WQ_PERCPU to alloc_workqueue to satisfy the new workqueue API
contract (syzbot).

Changes since v5 https://lore.kernel.org/openvpn-devel/d530ecfc3719845075fbddd0cd7c34752bc2ce16.1783336121.git.ralf@mandelbit.com/
- Update the module-exit ordering for the queue_rcu_work-based key-slot
release: flush ordinary ovpn work before rcu_barrier, then destroy the
workqueue after RCU callbacks have queued their cleanup work.

Changes since v4 https://lore.kernel.org/openvpn-devel/6edfcc51e0855bfd34286b86d4e7f26bb3bcd3f7.1783099626.git.ralf@mandelbit.com/
- Rebase on the pending keepalive and TCP deferred-work refcount fixes,
preserving their hold-before-queue and queue-failure put handling when
converting schedule_work to queue_work.

Changes since v3 https://lore.kernel.org/openvpn-devel/49f38f89340e18ed30543d3990a7a7e20595b6af.1783080055.git.ralf@mandelbit.com/
- Replace the RCU-deferred peer netdev reference release with a
module-owned workqueue that drains all ovpn work callbacks before
module text can be freed.

 drivers/net/ovpn/main.c     | 19 ++++++++++++++++++-
 drivers/net/ovpn/ovpnpriv.h |  4 ++++
 drivers/net/ovpn/peer.c     |  8 ++++----
 drivers/net/ovpn/tcp.c      |  9 ++++-----
 4 files changed, 30 insertions(+), 10 deletions(-)
drivers/net/ovpn/main.c +18 -1
index 168cfe9b59a9..0708249e9607 100644
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/inetdevice.h>
+#include <linux/workqueue.h>
 #include <net/gro_cells.h>
 #include <net/ip.h>
 #include <net/rtnetlink.h>
@@ -26,6 +27,9 @@
 #include "tcp.h"
 #include "udp.h"
 
+/* module-owned workqueue on which all ovpn-specific work is queued */
+struct workqueue_struct *ovpn_wq;
+
 static void ovpn_priv_free(struct net_device *net)
 {
 	struct ovpn_priv *ovpn = netdev_priv(net);
@@ -264,10 +268,16 @@ static int __init ovpn_init(void)
 
 	ovpn_tcp_init();
 
+	ovpn_wq = alloc_workqueue("ovpn", WQ_PERCPU, 0);
+	if (!ovpn_wq) {
+		pr_err("ovpn: cannot allocate workqueue\n");
+		return -ENOMEM;
+	}
+
 	err = rtnl_link_register(&ovpn_link_ops);
 	if (err) {
 		pr_err("ovpn: can't register rtnl link ops: %d\n", err);
-		return err;
+		goto destroy_wq;
 	}
 
 	err = ovpn_nl_register();
@@ -280,6 +290,9 @@ static int __init ovpn_init(void)
 
 unreg_rtnl:
 	rtnl_link_unregister(&ovpn_link_ops);
+destroy_wq:
+	destroy_workqueue(ovpn_wq);
+	ovpn_wq = NULL;
 	return err;
 }
 
@@ -288,7 +301,11 @@ static __exit void ovpn_cleanup(void)
 	ovpn_nl_unregister();
 	rtnl_link_unregister(&ovpn_link_ops);
 
+	flush_workqueue(ovpn_wq);
 	rcu_barrier();
+
+	destroy_workqueue(ovpn_wq);
+	ovpn_wq = NULL;
 }
 
 module_init(ovpn_init);
drivers/net/ovpn/ovpnpriv.h +4 -0
index 5898f6adada7..84499140e4bd 100644
@@ -15,6 +15,10 @@
 #include <uapi/linux/if_link.h>
 #include <uapi/linux/ovpn.h>
 
+struct workqueue_struct;
+
+extern struct workqueue_struct *ovpn_wq;
+
 /**
  * struct ovpn_peer_collection - container of peers for MultiPeer mode
  * @by_id: table of peers index by ID
drivers/net/ovpn/peer.c +4 -4
index b0519f9840d8..c95656ca7c35 100644
@@ -62,7 +62,7 @@ void ovpn_peer_keepalive_set(struct ovpn_peer *peer, u32 interval, u32 timeout)
 	/* now that interval and timeout have been changed, kick
 	 * off the worker so that the next delay can be recomputed
 	 */
-	mod_delayed_work(system_percpu_wq, &peer->ovpn->keepalive_work, 0);
+	mod_delayed_work(ovpn_wq, &peer->ovpn->keepalive_work, 0);
 }
 
 /**
@@ -1371,7 +1371,7 @@ static time64_t ovpn_peer_keepalive_work_single(struct ovpn_peer *peer,
 			   peer->id);
 		if (WARN_ON(!ovpn_peer_hold(peer)))
 			return 0;
-		if (!schedule_work(&peer->keepalive_work))
+		if (!queue_work(ovpn_wq, &peer->keepalive_work))
 			ovpn_peer_put(peer);
 	}
 
@@ -1463,8 +1463,8 @@ void ovpn_peer_keepalive_work(struct work_struct *work)
 		netdev_dbg(ovpn->dev,
 			   "scheduling keepalive work: now=%llu next_run=%llu delta=%llu\n",
 			   next_run, now, next_run - now);
-		schedule_delayed_work(&ovpn->keepalive_work,
-				      (next_run - now) * HZ);
+		queue_delayed_work(ovpn_wq, &ovpn->keepalive_work,
+				   (next_run - now) * HZ);
 	}
 	unlock_ovpn(ovpn, &release_list);
 }
drivers/net/ovpn/tcp.c +4 -5
index 0af14055c39a..8fe8a8e750a4 100644
@@ -151,7 +151,7 @@ static void ovpn_tcp_rcv(struct strparser *strp, struct sk_buff *skb)
 	/* take reference for deferred peer deletion. should never fail */
 	if (WARN_ON(!ovpn_peer_hold(peer)))
 		goto err_nopeer;
-	if (!schedule_work(&peer->tcp.defer_del_work))
+	if (!queue_work(ovpn_wq, &peer->tcp.defer_del_work))
 		ovpn_peer_put(peer);
 	ovpn_dev_dstats_rx_dropped(peer->ovpn->dev);
 err_nopeer:
@@ -284,13 +284,12 @@ static void ovpn_tcp_send_sock(struct ovpn_peer *peer, struct sock *sk)
 			 * stream therefore we abort the connection
 			 */
 			ovpn_peer_hold(peer);
-			if (!schedule_work(&peer->tcp.defer_del_work))
+			if (!queue_work(ovpn_wq, &peer->tcp.defer_del_work))
 				ovpn_peer_put(peer);
 
 			/* we bail out immediately and keep tx_in_progress set
 			 * to true. This way we prevent more TX attempts
-			 * which would lead to more invocations of
-			 * schedule_work()
+			 * which would lead to more invocations of queue_work()
 			 */
 			return;
 		}
@@ -487,7 +486,7 @@ static void ovpn_tcp_write_space(struct sock *sk)
 	rcu_read_lock();
 	sock = rcu_dereference_sk_user_data(sk);
 	if (likely(sock && sock->peer)) {
-		schedule_work(&sock->tcp_tx_work);
+		queue_work(ovpn_wq, &sock->tcp_tx_work);
 		sock->peer->tcp.sk_cb.sk_write_space(sk);
 	}
 	rcu_read_unlock();
Signature · 8 lines
2.55.0



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

Re: [Openvpn-devel] [PATCH ovpn net v7] ovpn: run deferred work on a module-owned workqueue

From: Antonio Quartulli <[email protected]>

Quoted 11 lines · Ralf Lici

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.

[...]

Applied, thanks!

[1/1] ovpn: run deferred work on a module-owned workqueue

      commit: e9714db8041763f59dde152c812b96b3de05c6d9

Best regards,

Signature · 7 lines
Antonio Quartulli <[email protected]>


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