Skip to contentSkip to conversation

net: ovpn: use correct array size to parse nested attributes in ovpn_nl_key_swap_doit

PATCH In review Sabrina Dubroca 2 participants 2 messages Jul 14, 2025 – Jul 18, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ovpn: use correct array size to parse nested attributes in ovpn_nl_key_swap_doit

In ovpn_nl_key_swap_doit, the attributes array used to parse the OVPN_A_KEYCONF uses OVPN_A_PEER_MAX instead of OVPN_A_KEYCONF_MAX. Note that this does not cause any bug, since currently OVPN_A_KEYCONF_MAX < OVPN_A_PEER_MAX.

Fixes 203e2bf55990 ("ovpn: implement key add/get/del/swap via netlink")

---
This patch is not urgent since the array ends up being too big for our needs, so there is no bug.

 drivers/net/ovpn/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ovpn/netlink.c +1 -1
index a4ec53def46e..655f9d674d57 100644
@@ -1027,7 +1027,7 @@ int ovpn_nl_key_get_doit(struct sk_buff *skb, struct genl_info *info)
 int ovpn_nl_key_swap_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct ovpn_priv *ovpn = info->user_ptr[0];
-	struct nlattr *attrs[OVPN_A_PEER_MAX + 1];
+	struct nlattr *attrs[OVPN_A_KEYCONF_MAX + 1];
 	struct ovpn_peer *peer;
 	u32 peer_id;
 	int ret;
Signature · 1 line
2.50.0
#1 lore raw
Quoted 7 lines · Sabrina Dubroca

In ovpn_nl_key_swap_doit, the attributes array used to parse the OVPN_A_KEYCONF uses OVPN_A_PEER_MAX instead of OVPN_A_KEYCONF_MAX. Note that this does not cause any bug, since currently OVPN_A_KEYCONF_MAX < OVPN_A_PEER_MAX.

Fixes 203e2bf55990 ("ovpn: implement key add/get/del/swap via netlink")

Nice catch, thanks a lot!
As you suggested I fixed the reverse christmas-tree while applying this patch.

It's now queued for sending to net-next.

Regards,

Signature · 1 line
Antonio Quartulli