netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Shanker Wang <miao.wang@tuna.tsinghua.edu.cn>, netdev@vger.kernel.org
Cc: "Hannes Frederic Sowa" <hannes@stressinduktion.org>,
	"Richard Weinberger" <richard.weinberger@gmail.com>,
	"Guillaume Nault" <g.nault@alphalink.fr>,
	王邈 <shankerwangmiao@gmail.com>
Subject: Re: [PATCH] net:ppp: replace too strict capability restriction on opening /dev/ppp
Date: Sun, 19 Jun 2016 12:13:32 +0200	[thread overview]
Message-ID: <5766704C.6060309@nod.at> (raw)
In-Reply-To: <15AED149-BC4D-4B8F-B173-3F652A46FA35@tuna.tsinghua.edu.cn>

Am 19.06.2016 um 07:21 schrieb Shanker Wang:
> This patch removes the check for CAP_NET_ADMIN in the initial namespace
> when opening /dev/open. Instead, CAP_NET_ADMIN is checked in the user
> namespace the net namespace was created so that /dev/ppp cat get opened
> in a unprivileged container.
> 
> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
> Cc: Richard Weinberger <richard.weinberger@gmail.com>
> Cc: Guillaume Nault <g.nault@alphalink.fr>
> Cc: Miao Wang <shankerwangmiao@gmail.com>
> Signed-off-by: Miao Wang <miao.wang@tuna.tsinghua.edu.cn>
> ---
> drivers/net/ppp/ppp_generic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
> index f572b31..4b3b2b5 100644
> --- a/drivers/net/ppp/ppp_generic.c
> +++ b/drivers/net/ppp/ppp_generic.c
> @@ -380,7 +380,7 @@ static int ppp_open(struct inode *inode, struct file *file)
> 	/*
> 	 * This could (should?) be enforced by the permissions on /dev/ppp.
> 	 */
> -	if (!capable(CAP_NET_ADMIN))
> +	if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
> 		return -EPERM;

Shouldn't this be a ns_capable(net->user_ns, ...?
Otherwise an user can create a new user_ns followed by a new net_ns and has
CAP_NET_ADMIN. We need to check whether he is allowed in the user_ns of the
net_ns which belongs to the ppp net device which you want to open.

Thanks,
//richard

  parent reply	other threads:[~2016-06-19 10:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-19  5:21 [PATCH] net:ppp: replace too strict capability restriction on opening /dev/ppp Shanker Wang
2016-06-19  5:24 ` David Miller
2016-06-19  5:31   ` Shanker Wang
2016-06-19 10:13 ` Richard Weinberger [this message]
2016-06-19 10:36   ` Shanker Wang
2016-06-19 10:40     ` Richard Weinberger
2016-07-16  9:41       ` Shanker Wang
  -- strict thread matches above, loose matches on Subject: below --
2016-06-18 23:38 Shanker Wang
2016-06-20  5:02 ` Andi Kleen
2016-06-20  6:47   ` Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5766704C.6060309@nod.at \
    --to=richard@nod.at \
    --cc=g.nault@alphalink.fr \
    --cc=hannes@stressinduktion.org \
    --cc=miao.wang@tuna.tsinghua.edu.cn \
    --cc=netdev@vger.kernel.org \
    --cc=richard.weinberger@gmail.com \
    --cc=shankerwangmiao@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).