ppp: require CAP_NET_ADMIN in target netns for unattached ioctls
Subsystems (3)
PATCH 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.
--- drivers/net/ppp/ppp_generic.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ppp/ppp_generic.c +9 -0
@@ -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 ;
Signature · 1 line
2.43.0
Hi,
Added Cc: Cyrill, and Matteo
Quoted 8 lines · Taegu Ha
/dev/pppopen is currently authorized againstfile->f_cred->user_ns, while unattached administrative ioctls operate oncurrent->nsproxy->net_ns.As a result, a local unprivileged user can create a new user namespace with
CLONE_NEWUSER, gainCAP_NET_ADMINonly in that new user namespace, and still issue PPPIOCNEWUNIT, PPPIOCATTACH, or PPPIOCATTCHAN against an inherited network namespace.
Quoted 8 lines
Require
CAP_NET_ADMINin 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"
Quoted 1 line
Reported-by Taegu Ha <[email protected]>
Minor nit: Reported-by tag is not needed if it's the same user as Signed-off-by.
Quoted 10 lines
Signed-off-by Taegu Ha <[email protected]>--- drivers/net/ppp/ppp_generic.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/ppp/ppp_generic.c +0
-0
drivers/net/ppp/ppp_generic.c static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, · line 1064
Quoted 6 lines
drivers/net/ppp/ppp_generic.c +3
-0@@ -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.
Quoted 23 lines
drivers/net/ppp/ppp_generic.c +6
-0/* 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 ;
Quoted 18 lines · Qingfang Deng
Quoted 2 lines
Hi,
Added Cc: Cyrill, and Matteo
Quoted 11 lines · Taegu Ha
/dev/pppopen is currently authorized againstfile->f_cred->user_ns, while unattached administrative ioctls operate oncurrent->nsproxy->net_ns.As a result, a local unprivileged user can create a new user namespace with
CLONE_NEWUSER, gainCAP_NET_ADMINonly in that new user namespace, and still issue PPPIOCNEWUNIT, PPPIOCATTACH, or PPPIOCATTCHAN against an inherited network namespace.Require
CAP_NET_ADMINin the user namespace that owns the target network namespace before handling these unattached PPP administrative ioctls.
Quoted 9 lines
Quoted 5 lines
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:
LGTM as long as it's still possible to start a pppd from within a user an network namespace.
Regards,
Signature · 1 line
Matteo Croce