Skip to contentSkip to conversation

ppp: require CAP_NET_ADMIN in target netns for unattached ioctls

PATCH Superseded Taegu Ha 2 participants 2 messages Apr 8

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Taegu Ha

author
#0 lore raw

PATCH v2 1/1 ppp: require CAP_NET_ADMIN in target netns for unattached ioctls

/dev/ppp open is currently authorized against file->f_cred->user_ns, while unattached administrative ioctls operate on current->nsproxy->net_ns.

As a result, a local unprivileged user can create a new user namespace with CLONE_NEWUSER, gain CAP_NET_ADMIN only in that new user namespace, and still issue PPPIOCNEWUNIT, PPPIOCATTACH, or PPPIOCATTCHAN against an inherited network namespace.

Require CAP_NET_ADMIN in the user namespace that owns the target network namespace before handling these unattached PPP administrative ioctls.

This preserves normal pppd operation in the network namespace it is actually privileged in, while rejecting the userns-only inherited-netns case.

Fixes 273ec51dd7ce ("net: ppp_generic - introduce net-namespace functionality v2")
---
 drivers/net/ppp/ppp_generic.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ppp/ppp_generic.c +6 -0
index e9b41777be80..4435c594f587 100644
@@ -1057,6 +1057,12 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
 	struct ppp_net *pn;
 	int __user *p = (int __user *)arg;
 
+	if ((cmd == PPPIOCNEWUNIT ||
+	     cmd == PPPIOCATTACH ||
+	     cmd == PPPIOCATTCHAN) &&
+	    !ns_capable(net->user_ns, CAP_NET_ADMIN))
+		return -EPERM;
+
 	switch (cmd) {
 	case PPPIOCNEWUNIT:
 		/* Create a new ppp unit */
Signature · 1 line
2.43.0