Skip to contentSkip to conversation

ovpn: assorted cleanups

PATCH New Ralf Lici 1 participant 4 messages Nov 26

Subsystems (2)
lore
Share & tools
lore

Ralf Lici

author reviewer
#0 lore raw

cover ovpn: assorted cleanups

Hi,

This series collects three small cleanups with no functional change.

Patch 1 uses rcu_dereference_protected instead of rcu_access_pointer in ovpn_crypto_kill_key, as the slot pointers are dereferenced under the update-side lock.

Patch 2 corrects the kdoc of ovpn_udp_output: the skb is consumed only on success, as the caller frees it when an error is returned.

Patch 3 drops a redundant forward declaration of struct workqueue_struct that was added together with ovpn_wq.

Patches 1 and 2 link to the Sashiko reports that flagged them.

Thanks,

Ralf Lici
Mandelbit Srl

---
Ralf Lici (3):
ovpn: use the right RCU primitive in ovpn_crypto_kill_key
ovpn: correct kdoc return statement in ovpn_udp_output
ovpn: drop redundant workqueue_struct forward declaration

 drivers/net/ovpn/crypto.c   | 6 ++++--
 drivers/net/ovpn/ovpnpriv.h | 2 --
 drivers/net/ovpn/udp.c      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

base-commit: 7ccc5e05043b1bb84326b19a2b05938d8f7a2ae6

Signature · 8 lines
2.56.0



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

PATCH 3/3 ovpn: drop redundant workqueue_struct forward declaration

ovpnpriv.h includes linux/workqueue.h, which already defines struct workqueue_struct, and needs it for the delayed work in struct ovpn_priv. Remove the redundant forward declaration added with ovpn_wq.

---
 drivers/net/ovpn/ovpnpriv.h | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ovpn/ovpnpriv.h +0 -2
index 84499140e4bd..0f56da4eb65c 100644
@@ -15,8 +15,6 @@
 #include <uapi/linux/if_link.h>
 #include <uapi/linux/ovpn.h>
 
-struct workqueue_struct;
-
 extern struct workqueue_struct *ovpn_wq;
 
 /**
Signature · 8 lines
2.56.0



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

PATCH 1/3 ovpn: use the right RCU primitive in ovpn_crypto_kill_key

In reply to Ralf Lici

The kdoc for rcu_access_pointer says it is meant for cases where the pointer value is used but not dereferenced, that rcu_dereference_protected should be used when update-side locks prevent the pointer from changing, and that assigning the rcu_access_pointer return value to a local variable "results in an accident waiting to happen".

Swap rcu_access_pointer with rcu_dereference_protected in ovpn_crypto_kill_key, adopting the same pattern of ovpn_crypto_key_slots_swap.

---
 drivers/net/ovpn/crypto.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ovpn/crypto.c +4 -2
index 7e545428900a..cec39147e011 100644
@@ -54,10 +54,12 @@ bool ovpn_crypto_kill_key(struct ovpn_crypto_state *cs, u8 key_id)
 	int slot = 0;
 
 	spin_lock_bh(&cs->lock);
-	tmp = rcu_access_pointer(cs->slots[slot]);
+	tmp = rcu_dereference_protected(cs->slots[slot],
+					lockdep_is_held(&cs->lock));
 	if (!tmp || tmp->key_id != key_id) {
 		slot = 1;
-		tmp = rcu_access_pointer(cs->slots[slot]);
+		tmp = rcu_dereference_protected(cs->slots[slot],
+						lockdep_is_held(&cs->lock));
 	}
 
 	if (tmp && tmp->key_id == key_id)
Signature · 8 lines
2.56.0



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

PATCH 2/3 ovpn: correct kdoc return statement in ovpn_udp_output

In reply to Ralf Lici

Fix the return statement of ovpn_udp_output by stating that the skb is consumed only on success, not unconditionally.

---
 drivers/net/ovpn/udp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ovpn/udp.c +1 -1
index 055cdb1bee13..422c1f6e0c76 100644
@@ -407,7 +407,7 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct ovpn_bind *bind,
  * @key: route key snapshot used for cache validation and flow lookup
  *
  * rcu_read_lock should be held on entry.
- * On return, the skb is consumed.
+ * On success, the skb is consumed.
  *
  * Return: 0 on success or a negative error code otherwise
  */
Signature · 8 lines
2.56.0



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