Skip to contentSkip to conversation

ovpn: account user-triggered allocations to memcg

PATCH In review Antonio Quartulli 1 participant 5 messages May 25

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

PATCH 1/4 ovpn: account user-triggered allocations to memcg

From: Antonio Quartulli <[email protected]>

Since commit 64f5f0062d77 ("ovpn: netlink - check CAP_NET_ADMIN in source namespace only") an unprivileged userns owner can drive every ovpn genetlink op and, without further mitigation, pin arbitrary amounts of kernel memory by creating interfaces, peers and key slots in a loop.

Tag the affected allocations with __GFP_ACCOUNT so they are charged to the caller's cgroup and capped by memory.max: ovpn_peer, ovpn_socket, the ~128 KiB MP peer hashtable, the crypto key slot, the per-peer dst_cache and netdev trackers, and ovpn_bind when allocated from process context.

ovpn_bind_from_sockaddr() and ovpn_peer_reset_sockaddr() now take an explicit gfp_t. The RX float path runs in softirq, where 'current' is unrelated to the userns owner, so it passes plain GFP_ATOMIC and accepts that those binds go unaccounted. Per-packet datapath allocations are out of scope: short-lived and traffic-driven.

---
 drivers/net/ovpn/bind.c        | 12 ++++++++++--
 drivers/net/ovpn/bind.h        |  3 ++-
 drivers/net/ovpn/crypto_aead.c |  2 +-
 drivers/net/ovpn/main.c        |  2 +-
 drivers/net/ovpn/netlink.c     |  3 ++-
 drivers/net/ovpn/peer.c        | 18 ++++++++++++------
 drivers/net/ovpn/peer.h        |  2 +-
 drivers/net/ovpn/socket.c      |  4 ++--
 8 files changed, 31 insertions(+), 15 deletions(-)
drivers/net/ovpn/bind.c +10 -2
index e42b60cd04a9..a8e9a417e2bf 100644
@@ -17,10 +17,18 @@
 /**
  * ovpn_bind_from_sockaddr - retrieve binding matching sockaddr
  * @ss: the sockaddr to match
+ * @gfp: GFP flags for the allocation. All callers reach this function with
+ *	 peer->lock (a spinlock) held, so the GFP must be atomic regardless of
+ *	 the outer context. Callers in process context (e.g. netlink handlers)
+ *	 should additionally OR in __GFP_ACCOUNT so the charge lands on the
+ *	 caller's memcg; callers on the RX float path (softirq, where current
+ *	 is unrelated to the userns owner) must pass plain GFP_ATOMIC to avoid
+ *	 mis-accounting to a random cgroup.
  *
  * Return: the bind matching the passed sockaddr if found, NULL otherwise
  */
-struct ovpn_bind *ovpn_bind_from_sockaddr(const struct sockaddr_storage *ss)
+struct ovpn_bind *ovpn_bind_from_sockaddr(const struct sockaddr_storage *ss,
+					  gfp_t gfp)
 {
 	struct ovpn_bind *bind;
 	size_t sa_len;
@@ -32,7 +40,7 @@ struct ovpn_bind *ovpn_bind_from_sockaddr(const struct sockaddr_storage *ss)
 	else
 		return ERR_PTR(-EAFNOSUPPORT);
 
-	bind = kzalloc_obj(*bind, GFP_ATOMIC);
+	bind = kzalloc_obj(*bind, gfp);
 	if (unlikely(!bind))
 		return ERR_PTR(-ENOMEM);
 
drivers/net/ovpn/bind.h +2 -1
index 4e0b8398bfd9..cda8c4888a35 100644
@@ -95,7 +95,8 @@ static inline bool ovpn_bind_skb_src_match(const struct ovpn_bind *bind,
 	return true;
 }
 
-struct ovpn_bind *ovpn_bind_from_sockaddr(const struct sockaddr_storage *sa);
+struct ovpn_bind *ovpn_bind_from_sockaddr(const struct sockaddr_storage *sa,
+					  gfp_t gfp);
 void ovpn_bind_reset(struct ovpn_peer *peer, struct ovpn_bind *bind);
 
 #endif /* _NET_OVPN_OVPNBIND_H_ */
drivers/net/ovpn/crypto_aead.c +1 -1
index 8f07c418622b..0a3c93d198fe 100644
@@ -414,7 +414,7 @@ ovpn_aead_crypto_key_slot_new(const struct ovpn_key_config *kc)
 		return ERR_PTR(-EINVAL);
 
 	/* build the key slot */
-	ks = kmalloc_obj(*ks);
+	ks = kmalloc_obj(*ks, GFP_KERNEL_ACCOUNT);
 	if (!ks)
 		return ERR_PTR(-ENOMEM);
 
drivers/net/ovpn/main.c +1 -1
index 9993c1dfe471..425f4367f0ab 100644
@@ -57,7 +57,7 @@ static int ovpn_mp_alloc(struct ovpn_priv *ovpn)
 	/* the peer container is fairly large, therefore we allocate it only in
 	 * MP mode
 	 */
-	ovpn->peers = kzalloc_obj(*ovpn->peers);
+	ovpn->peers = kzalloc_obj(*ovpn->peers, GFP_KERNEL_ACCOUNT);
 	if (!ovpn->peers)
 		return -ENOMEM;
 
drivers/net/ovpn/netlink.c +2 -1
index 4c66c1ec497e..893dccdfaf64 100644
@@ -295,7 +295,8 @@ static int ovpn_nl_peer_modify(struct ovpn_peer *peer, struct genl_info *info,
 		local_ip = ovpn_nl_attr_local_ip(attrs);
 
 		/* set peer sockaddr */
-		ret = ovpn_peer_reset_sockaddr(peer, &ss, local_ip);
+		ret = ovpn_peer_reset_sockaddr(peer, &ss, local_ip,
+					       GFP_ATOMIC | __GFP_ACCOUNT);
 		if (ret < 0) {
 			NL_SET_ERR_MSG_FMT_MOD(info->extack,
 					       "cannot set peer sockaddr: %d",
drivers/net/ovpn/peer.c +12 -6
index a09d61296425..511a7ce9b32b 100644
@@ -95,7 +95,7 @@ struct ovpn_peer *ovpn_peer_new(struct ovpn_priv *ovpn, u32 id)
 	int ret;
 
 	/* alloc and init peer object */
-	peer = kzalloc_obj(*peer);
+	peer = kzalloc_obj(*peer, GFP_KERNEL_ACCOUNT);
 	if (!peer)
 		return ERR_PTR(-ENOMEM);
 
@@ -117,7 +117,7 @@ struct ovpn_peer *ovpn_peer_new(struct ovpn_priv *ovpn, u32 id)
 	ovpn_peer_stats_init(&peer->link_stats);
 	INIT_WORK(&peer->keepalive_work, ovpn_peer_keepalive_send);
 
-	ret = dst_cache_init(&peer->dst_cache, GFP_KERNEL);
+	ret = dst_cache_init(&peer->dst_cache, GFP_KERNEL_ACCOUNT);
 	if (ret < 0) {
 		netdev_err(ovpn->dev,
 			   "cannot initialize dst cache for peer %u\n",
@@ -126,7 +126,7 @@ struct ovpn_peer *ovpn_peer_new(struct ovpn_priv *ovpn, u32 id)
 		return ERR_PTR(ret);
 	}
 
-	netdev_hold(ovpn->dev, &peer->dev_tracker, GFP_KERNEL);
+	netdev_hold(ovpn->dev, &peer->dev_tracker, GFP_KERNEL_ACCOUNT);
 
 	return peer;
 }
@@ -136,12 +136,14 @@ struct ovpn_peer *ovpn_peer_new(struct ovpn_priv *ovpn, u32 id)
  * @peer: peer to recreate the binding for
  * @ss: sockaddr to use as remote endpoint for the binding
  * @local_ip: local IP for the binding
+ * @gfp: GFP flags for the bind allocation. See ovpn_bind_from_sockaddr() for
+ *	 the accounting trade-off between process-context and softirq callers.
  *
  * Return: 0 on success or a negative error code otherwise
  */
 int ovpn_peer_reset_sockaddr(struct ovpn_peer *peer,
 			     const struct sockaddr_storage *ss,
-			     const void *local_ip)
+			     const void *local_ip, gfp_t gfp)
 {
 	struct ovpn_bind *bind;
 	size_t ip_len;
@@ -149,7 +151,7 @@ int ovpn_peer_reset_sockaddr(struct ovpn_peer *peer,
 	lockdep_assert_held(&peer->lock);
 
 	/* create new ovpn_bind object */
-	bind = ovpn_bind_from_sockaddr(ss);
+	bind = ovpn_bind_from_sockaddr(ss, gfp);
 	if (IS_ERR(bind))
 		return PTR_ERR(bind);
 
@@ -281,9 +283,13 @@ void ovpn_peer_endpoints_update(struct ovpn_peer *peer, struct sk_buff *skb)
 	if (likely(!salen))
 		goto unlock;
 
+	/* RX float path runs in softirq context: __GFP_ACCOUNT would charge
+	 * whatever cgroup is on-CPU when the packet arrives, not the userns
+	 * owner, so pass plain GFP_ATOMIC and skip accounting on this path.
+	 */
 	if (unlikely(ovpn_peer_reset_sockaddr(peer,
 					      (struct sockaddr_storage *)&ss,
-					      local_ip) < 0))
+					      local_ip, GFP_ATOMIC) < 0))
 		goto unlock;
 
 	net_dbg_ratelimited("%s: peer %d floated to %pIScp",
drivers/net/ovpn/peer.h +1 -1
index 86c8cffada6d..1bfc66821739 100644
@@ -159,6 +159,6 @@ void ovpn_peer_keepalive_work(struct work_struct *work);
 void ovpn_peer_endpoints_update(struct ovpn_peer *peer, struct sk_buff *skb);
 int ovpn_peer_reset_sockaddr(struct ovpn_peer *peer,
 			     const struct sockaddr_storage *ss,
-			     const void *local_ip);
+			     const void *local_ip, gfp_t gfp);
 
 #endif /* _NET_OVPN_OVPNPEER_H_ */
drivers/net/ovpn/socket.c +2 -2
index 517caa64a4fe..45d6a497bffb 100644
@@ -191,7 +191,7 @@ struct ovpn_socket *ovpn_socket_new(struct socket *sock, struct ovpn_peer *peer)
 
 	/* socket is not owned: attach to this ovpn instance */
 
-	ovpn_sock = kzalloc_obj(*ovpn_sock);
+	ovpn_sock = kzalloc_obj(*ovpn_sock, GFP_KERNEL_ACCOUNT);
 	if (!ovpn_sock) {
 		ovpn_sock = ERR_PTR(-ENOMEM);
 		goto sock_release;
@@ -213,7 +213,7 @@ struct ovpn_socket *ovpn_socket_new(struct socket *sock, struct ovpn_peer *peer)
 		 */
 		ovpn_sock->ovpn = peer->ovpn;
 		netdev_hold(peer->ovpn->dev, &ovpn_sock->dev_tracker,
-			    GFP_KERNEL);
+			    GFP_KERNEL_ACCOUNT);
 	}
 
 	/* the newly created ovpn_socket is holding reference to sk,
Signature · 8 lines
2.53.0



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

PATCH 2/4 ovpn: cap number of peers per multi-peer interface

From: Antonio Quartulli <[email protected]>

Memcg accounting bounds user-driven peer creation only when the calling cgroup has memory.max set; on unconstrained hosts it isn't a hard limit.

Track the live peer count in ovpn_peer_collection::n_peers under the existing ovpn->lock and reject OVPN_CMD_PEER_NEW with -ENOSPC once OVPN_MAX_PEERS (65535) is reached. 65535 matches what userspace OpenVPN servers configure via --max-clients. P2P mode is unaffected.

The same cap also bounds the unaccounted RX-float bind allocations, since binds are owned by peers.

---
 drivers/net/ovpn/ovpnpriv.h | 3 +++
 drivers/net/ovpn/peer.c     | 9 +++++++++
 drivers/net/ovpn/peer.h     | 8 ++++++++
 3 files changed, 20 insertions(+)
drivers/net/ovpn/ovpnpriv.h +3 -0
index 5898f6adada7..113f5f493575 100644
@@ -24,12 +24,15 @@
  *		  rehashed on the fly due to peer IP change)
  * @by_transp_addr: table of peers indexed by transport address (items can be
  *		    rehashed on the fly due to peer IP change)
+ * @n_peers: number of peers currently in the collection, protected by
+ *	     ovpn_priv->lock
  */
 struct ovpn_peer_collection {
 	DECLARE_HASHTABLE(by_id, 12);
 	struct hlist_nulls_head by_vpn_addr4[1 << 12];
 	struct hlist_nulls_head by_vpn_addr6[1 << 12];
 	struct hlist_nulls_head by_transp_addr[1 << 12];
+	u32 n_peers;
 };
 
 /**
drivers/net/ovpn/peer.c +9 -0
index 511a7ce9b32b..1d564888479a 100644
@@ -286,6 +286,8 @@ void ovpn_peer_endpoints_update(struct ovpn_peer *peer, struct sk_buff *skb)
 	/* RX float path runs in softirq context: __GFP_ACCOUNT would charge
 	 * whatever cgroup is on-CPU when the packet arrives, not the userns
 	 * owner, so pass plain GFP_ATOMIC and skip accounting on this path.
+	 * The number of bind objects that can accumulate via float events is
+	 * bounded by the per-MP peer cap, since binds are owned by peers.
 	 */
 	if (unlikely(ovpn_peer_reset_sockaddr(peer,
 					      (struct sockaddr_storage *)&ss,
@@ -703,6 +705,7 @@ static void ovpn_peer_remove(struct ovpn_peer *peer,
 		hlist_nulls_del_init_rcu(&peer->hash_entry_addr4);
 		hlist_nulls_del_init_rcu(&peer->hash_entry_addr6);
 		hlist_nulls_del_init_rcu(&peer->hash_entry_transp_addr);
+		peer->ovpn->peers->n_peers--;
 		break;
 	case OVPN_MODE_P2P:
 		/* prevent double remove */
@@ -959,6 +962,11 @@ static int ovpn_peer_add_mp(struct ovpn_priv *ovpn, struct ovpn_peer *peer)
 		goto out;
 	}
 
+	if (ovpn->peers->n_peers >= OVPN_MAX_PEERS) {
+		ret = -ENOSPC;
+		goto out;
+	}
+
 	bind = rcu_dereference_protected(peer->bind, true);
 	/* peers connected via TCP have bind == NULL */
 	if (bind) {
@@ -994,6 +1002,7 @@ static int ovpn_peer_add_mp(struct ovpn_priv *ovpn, struct ovpn_peer *peer)
 					      sizeof(peer->id)));
 
 	ovpn_peer_hash_vpn_ip(peer);
+	ovpn->peers->n_peers++;
 out:
 	spin_unlock_bh(&ovpn->lock);
 	return ret;
drivers/net/ovpn/peer.h +8 -0
index 1bfc66821739..2efc782130f3 100644
@@ -17,6 +17,14 @@
 #include "socket.h"
 #include "stats.h"
 
+/* Hard cap on number of peers per MP-mode interface. Caps the worst-case
+ * kernel memory an unprivileged userns owner driving OVPN_CMD_PEER_NEW can
+ * pin even when memcg accounting is unconstrained. 65535 matches what
+ * mainstream userspace OpenVPN servers configure via --max-clients, so
+ * legitimate deployments never hit this.
+ */
+#define OVPN_MAX_PEERS 65535
+
 /**
  * struct ovpn_peer - the main remote peer object
  * @ovpn: main openvpn instance this peer belongs to
Signature · 8 lines
2.53.0



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

PATCH 3/4 ovpn: cap number of ovpn devices per netns

In reply to Antonio Quartulli

From: Antonio Quartulli <[email protected]>

The previous patches bound resource use within a single ovpn interface, but a userns owner can still spin many MP-mode devices, each costing ~128 KiB just for its peer hashtables.

Cap the number of ovpn netdevs per netns with a compile-time constant (OVPN_MAX_DEVS, 256). The counter lives in a per-netns struct registered via register_pernet_subsys() - the framework zero-allocates and frees the storage, so no init/exit callbacks are needed. ovpn_net_init() increments and rejects with -ENOSPC past the cap; ovpn_net_uninit() decrements, keeping the counter balanced across both ndo_init failure and normal teardown.

Also set dev->netns_immutable in ovpn_setup() to forbid moving an ovpn device between netns. Without it, ndo_uninit would decrement a different netns' counter than ndo_init incremented, eventually wrapping the atomic_t and defeating the cap - a userns owner with multiple child netns could trigger this on purpose.

A sysctl was rejected: net.* sysctls in a non-init netns are writable by anyone with CAP_NET_ADMIN in that netns, i.e. the exact actor this cap constrains. A compile-time constant cannot be raised by an attacker; 256 is generous for any realistic deployment.

---
 drivers/net/ovpn/main.c | 71 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 63 insertions(+), 8 deletions(-)
drivers/net/ovpn/main.c +63 -8
index 425f4367f0ab..540ba89d81b7 100644
@@ -14,6 +14,8 @@
 #include <linux/inetdevice.h>
 #include <net/gro_cells.h>
 #include <net/ip.h>
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
 #include <net/rtnetlink.h>
 #include <uapi/linux/if_arp.h>
 
@@ -26,6 +28,29 @@
 #include "tcp.h"
 #include "udp.h"
 
+/* Hard cap on number of ovpn netdevs per network namespace. Pairs with the
+ * per-MP-instance OVPN_MAX_PEERS cap to bound total kernel memory an
+ * unprivileged userns owner can pin via repeated `ip link add ... type ovpn`
+ * calls (each MP-mode device costs ~128 KiB just for its peer hashtables).
+ *
+ * This is a compile-time constant on purpose: a sysctl in net.* would be
+ * writable by anyone with CAP_NET_ADMIN in the namespace - i.e. exactly the
+ * unprivileged userns owner this cap is meant to constrain - which would
+ * defeat the defence. 256 is generous for any realistic deployment.
+ */
+#define OVPN_MAX_DEVS 256
+
+struct ovpn_net {
+	atomic_t n_devs;
+};
+
+static unsigned int ovpn_net_id __read_mostly;
+
+static struct pernet_operations ovpn_pernet_ops = {
+	.id	= &ovpn_net_id,
+	.size	= sizeof(struct ovpn_net),
+};
+
 static void ovpn_priv_free(struct net_device *net)
 {
 	struct ovpn_priv *ovpn = netdev_priv(net);
@@ -74,27 +99,40 @@ static int ovpn_mp_alloc(struct ovpn_priv *ovpn)
 static int ovpn_net_init(struct net_device *dev)
 {
 	struct ovpn_priv *ovpn = netdev_priv(dev);
-	int err = gro_cells_init(&ovpn->gro_cells, dev);
+	struct ovpn_net *on = net_generic(dev_net(dev), ovpn_net_id);
+	int err;
+
+	if (atomic_fetch_inc(&on->n_devs) >= OVPN_MAX_DEVS) {
+		atomic_dec(&on->n_devs);
+		return -ENOSPC;
+	}
 
+	err = gro_cells_init(&ovpn->gro_cells, dev);
 	if (err < 0)
-		return err;
+		goto err_dec;
 
 	err = ovpn_mp_alloc(ovpn);
-	if (err < 0) {
-		gro_cells_destroy(&ovpn->gro_cells);
-		return err;
-	}
+	if (err < 0)
+		goto err_gro;
 
 	return 0;
+
+err_gro:
+	gro_cells_destroy(&ovpn->gro_cells);
+err_dec:
+	atomic_dec(&on->n_devs);
+	return err;
 }
 
 static void ovpn_net_uninit(struct net_device *dev)
 {
 	struct ovpn_priv *ovpn = netdev_priv(dev);
+	struct ovpn_net *on = net_generic(dev_net(dev), ovpn_net_id);
 
 	disable_delayed_work_sync(&ovpn->keepalive_work);
 	ovpn_peers_free(ovpn, NULL, OVPN_DEL_PEER_REASON_TEARDOWN);
 	gro_cells_destroy(&ovpn->gro_cells);
+	atomic_dec(&on->n_devs);
 }
 
 static const struct net_device_ops ovpn_netdev_ops = {
@@ -173,6 +211,14 @@ static void ovpn_setup(struct net_device *dev)
 	dev->needed_headroom = ALIGN(OVPN_HEAD_ROOM, 4);
 	dev->needed_tailroom = OVPN_MAX_PADDING;
 
+	/* forbid moving the device between network namespaces: ndo_init and
+	 * ndo_uninit are called in the originating and current netns
+	 * respectively, so a migrated device would dec a different netns'
+	 * n_devs counter than the one it incremented, eventually wrapping it
+	 * and defeating the per-netns cap.
+	 */
+	dev->netns_immutable = true;
+
 	SET_NETDEV_DEVTYPE(dev, &ovpn_type);
 }
 
@@ -233,13 +279,19 @@ static struct rtnl_link_ops ovpn_link_ops = {
 
 static int __init ovpn_init(void)
 {
-	int err = rtnl_link_register(&ovpn_link_ops);
+	int err = register_pernet_subsys(&ovpn_pernet_ops);
 
 	if (err) {
-		pr_err("ovpn: can't register rtnl link ops: %d\n", err);
+		pr_err("ovpn: can't register pernet ops: %d\n", err);
 		return err;
 	}
 
+	err = rtnl_link_register(&ovpn_link_ops);
+	if (err) {
+		pr_err("ovpn: can't register rtnl link ops: %d\n", err);
+		goto unreg_pernet;
+	}
+
 	err = ovpn_nl_register();
 	if (err) {
 		pr_err("ovpn: can't register netlink family: %d\n", err);
@@ -252,6 +304,8 @@ static int __init ovpn_init(void)
 
 unreg_rtnl:
 	rtnl_link_unregister(&ovpn_link_ops);
+unreg_pernet:
+	unregister_pernet_subsys(&ovpn_pernet_ops);
 	return err;
 }
 
@@ -259,6 +313,7 @@ static __exit void ovpn_cleanup(void)
 {
 	ovpn_nl_unregister();
 	rtnl_link_unregister(&ovpn_link_ops);
+	unregister_pernet_subsys(&ovpn_pernet_ops);
 
 	rcu_barrier();
 }
Signature · 8 lines
2.53.0



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

PATCH 4/4 ovpn: netlink - check CAP_NET_ADMIN in source namespace only

In reply to Antonio Quartulli

From: Antonio Quartulli <[email protected]>

Netlink API calls can be allowed as long as the user has CAP_NET_ADMIN in the source namespace.

There is no need to enforce broader capabilities.

Therefore switch to GENL_UNS_ADMIN_PERM for all netlink ops.

---
 Documentation/netlink/specs/ovpn.yaml | 16 ++++++++--------
 drivers/net/ovpn/netlink-gen.c        | 18 +++++++++---------
 2 files changed, 17 insertions(+), 17 deletions(-)
Documentation/netlink/specs/ovpn.yaml +8 -8
index b0c782e59a32..5d1f71b2ff78 100644
@@ -397,7 +397,7 @@ operations:
     -
       name: peer-new
       attribute-set: ovpn-peer-new-input
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: Add a remote peer
       do:
         pre: ovpn-nl-pre-doit
@@ -409,7 +409,7 @@ operations:
     -
       name: peer-set
       attribute-set: ovpn-peer-set-input
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: modify a remote peer
       do:
         pre: ovpn-nl-pre-doit
@@ -421,7 +421,7 @@ operations:
     -
       name: peer-get
       attribute-set: ovpn
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: Retrieve data about existing remote peers (or a specific one)
       do:
         pre: ovpn-nl-pre-doit
@@ -443,7 +443,7 @@ operations:
     -
       name: peer-del
       attribute-set: ovpn-peer-del-input
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: Delete existing remote peer
       do:
         pre: ovpn-nl-pre-doit
@@ -461,7 +461,7 @@ operations:
     -
       name: key-new
       attribute-set: ovpn
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: Add a cipher key for a specific peer
       do:
         pre: ovpn-nl-pre-doit
@@ -473,7 +473,7 @@ operations:
     -
       name: key-get
       attribute-set: ovpn-keyconf-get
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: Retrieve non-sensitive data about peer key and cipher
       do:
         pre: ovpn-nl-pre-doit
@@ -488,7 +488,7 @@ operations:
     -
       name: key-swap
       attribute-set: ovpn-keyconf-swap-input
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: Swap primary and secondary session keys for a specific peer
       do:
         pre: ovpn-nl-pre-doit
@@ -507,7 +507,7 @@ operations:
     -
       name: key-del
       attribute-set: ovpn-keyconf-del-input
-      flags: [admin-perm]
+      flags: [uns-admin-perm]
       doc: Delete cipher key for a specific peer
       do:
         pre: ovpn-nl-pre-doit
drivers/net/ovpn/netlink-gen.c +9 -9
index 2147cec7c2c5..6f1237f65674 100644
@@ -179,7 +179,7 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_peer_new_nl_policy,
 		.maxattr	= OVPN_A_PEER,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
 		.cmd		= OVPN_CMD_PEER_SET,
@@ -188,7 +188,7 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_peer_set_nl_policy,
 		.maxattr	= OVPN_A_PEER,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
 		.cmd		= OVPN_CMD_PEER_GET,
@@ -197,14 +197,14 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_peer_get_do_nl_policy,
 		.maxattr	= OVPN_A_PEER,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
 		.cmd		= OVPN_CMD_PEER_GET,
 		.dumpit		= ovpn_nl_peer_get_dumpit,
 		.policy		= ovpn_peer_get_dump_nl_policy,
 		.maxattr	= OVPN_A_IFINDEX,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DUMP,
 	},
 	{
 		.cmd		= OVPN_CMD_PEER_DEL,
@@ -213,7 +213,7 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_peer_del_nl_policy,
 		.maxattr	= OVPN_A_PEER,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
 		.cmd		= OVPN_CMD_KEY_NEW,
@@ -222,7 +222,7 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_key_new_nl_policy,
 		.maxattr	= OVPN_A_KEYCONF,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
 		.cmd		= OVPN_CMD_KEY_GET,
@@ -231,7 +231,7 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_key_get_nl_policy,
 		.maxattr	= OVPN_A_KEYCONF,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
 		.cmd		= OVPN_CMD_KEY_SWAP,
@@ -240,7 +240,7 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_key_swap_nl_policy,
 		.maxattr	= OVPN_A_KEYCONF,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
 		.cmd		= OVPN_CMD_KEY_DEL,
@@ -249,7 +249,7 @@ static const struct genl_split_ops ovpn_nl_ops[] = {
 		.post_doit	= ovpn_nl_post_doit,
 		.policy		= ovpn_key_del_nl_policy,
 		.maxattr	= OVPN_A_KEYCONF,
-		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+		.flags		= GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 };
 
Signature · 8 lines
2.53.0



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