* [PATCH] ppp: require CAP_NET_ADMIN in target netns for unattached ioctls
@ 2026-04-08 4:23 Taegu Ha
2026-04-08 6:28 ` Qingfang Deng
0 siblings, 1 reply; 2+ messages in thread
From: Taegu Ha @ 2026-04-08 4:23 UTC (permalink / raw)
To: netdev
Cc: linux-ppp, qingfang.deng, gnault, jaco, richardbgobert, ericwouds,
Taegu Ha
/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")
Reported-by: Taegu Ha <hataegu0826@gmail.com>
Signed-off-by: Taegu Ha <hataegu0826@gmail.com>
---
drivers/net/ppp/ppp_generic.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index e9b41777be80..99a8557188c0 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1059,6 +1059,9 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
switch (cmd) {
case PPPIOCNEWUNIT:
+ if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+ return -EPERM;
+
/* Create a new ppp unit */
if (get_user(unit, p))
break;
@@ -1073,6 +1076,9 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
break;
case PPPIOCATTACH:
+ if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+ return -EPERM;
+
/* Attach to an existing ppp unit */
if (get_user(unit, p))
break;
@@ -1089,6 +1095,9 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
break;
case PPPIOCATTCHAN:
+ if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+ return -EPERM;
+
if (get_user(unit, p))
break;
err = -ENXIO;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ppp: require CAP_NET_ADMIN in target netns for unattached ioctls
2026-04-08 4:23 [PATCH] ppp: require CAP_NET_ADMIN in target netns for unattached ioctls Taegu Ha
@ 2026-04-08 6:28 ` Qingfang Deng
0 siblings, 0 replies; 2+ messages in thread
From: Qingfang Deng @ 2026-04-08 6:28 UTC (permalink / raw)
To: Taegu Ha, netdev
Cc: linux-ppp, gnault, jaco, richardbgobert, ericwouds,
Cyrill Gorcunov, Matteo Croce
Hi,
Added Cc: Cyrill, and Matteo
On 2026/4/8 12:23, Taegu Ha wrote:
> /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")
For fixes, you should set the target tree to "net" in the patch subject,
using:
git format-patch --subject-prefix="PATCH net"
> Reported-by: Taegu Ha <hataegu0826@gmail.com>
Minor nit: Reported-by tag is not needed if it's the same user as Signed-off-by.
> Signed-off-by: Taegu Ha <hataegu0826@gmail.com>
> ---
> drivers/net/ppp/ppp_generic.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
> index e9b41777be80..99a8557188c0 100644
> --- a/drivers/net/ppp/ppp_generic.c
> +++ b/drivers/net/ppp/ppp_generic.c
> @@ -1059,6 +1059,9 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
>
> switch (cmd) {
> case PPPIOCNEWUNIT:
> + if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
> + return -EPERM;
> +
These three identical checks can be combined into one and placed before
the switch statement.
> /* Create a new ppp unit */
> if (get_user(unit, p))
> break;
> @@ -1073,6 +1076,9 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
> break;
>
> case PPPIOCATTACH:
> + if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
> + return -EPERM;
> +
> /* Attach to an existing ppp unit */
> if (get_user(unit, p))
> break;
> @@ -1089,6 +1095,9 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
> break;
>
> case PPPIOCATTCHAN:
> + if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
> + return -EPERM;
> +
> if (get_user(unit, p))
> break;
> err = -ENXIO;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-08 6:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 4:23 [PATCH] ppp: require CAP_NET_ADMIN in target netns for unattached ioctls Taegu Ha
2026-04-08 6:28 ` Qingfang Deng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox