]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ppp: require CAP_NET_ADMIN in target netns for unattached ioctls
authorTaegu Ha <hataegu0826@gmail.com>
Thu, 9 Apr 2026 07:11:15 +0000 (16:11 +0900)
committerJakub Kicinski <kuba@kernel.org>
Sun, 12 Apr 2026 20:47:45 +0000 (13:47 -0700)
/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 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")
Signed-off-by: Taegu Ha <hataegu0826@gmail.com>
Link: https://patch.msgid.link/20260409071117.4354-1-hataegu0826@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ppp/ppp_generic.c

index e9b41777be809acebf17196538a7f93a94e5e17d..c2024684b10d522e9861c1e3562734b7dcaadf01 100644 (file)
@@ -1057,6 +1057,9 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
        struct ppp_net *pn;
        int __user *p = (int __user *)arg;
 
+       if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+               return -EPERM;
+
        switch (cmd) {
        case PPPIOCNEWUNIT:
                /* Create a new ppp unit */