All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Shmulik Ladkani <shmulik@metanetworks.com>,
	Alexei Starovoitov <ast@kernel.org>
Cc: Chenbo Feng <fengc@google.com>,
	eyal@metanetworks.com, netdev@vger.kernel.org,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>
Subject: Re: [Q] Unable to load SCHED_CLS/SCHED_ACT bpf programs from outside init_user_ns
Date: Sat, 10 Feb 2018 14:08:58 +0100	[thread overview]
Message-ID: <e9500f88-2484-b03b-e199-ede532d48b26@iogearbox.net> (raw)
In-Reply-To: <20180210094617.3ca6faf8@pixies>

Hi Shmulik,

On 02/10/2018 08:46 AM, Shmulik Ladkani wrote:
> Hi,
> 
> Apparently one cannot use TC cls_bpf/act_bpf if running from a user ns
> other than the init_user_ns, as bpf_prog_load does not permit loading
> these type of progs, snip:
> 
>         if (type != BPF_PROG_TYPE_SOCKET_FILTER &&
>             type != BPF_PROG_TYPE_CGROUP_SKB &&
>             !capable(CAP_SYS_ADMIN))
>                 return -EPERM;
> 
> although the user performing BPF_PROG_LOAD has both CAP_SYS_ADMIN (and
> CAP_NET_ADMIN, as required by RTM_NEWTFILTER) in his current_user_ns.
> 
> This prevents using tc cls_bpf/act_bpf in containerized software
> stacks (where in contrast other tc cls/act are permitted).

Not really, it's correct that it's initns root-only, but for containers
control plane can attach BPF progs out of initns into the host-facing
veth on ingress/egress clsact side to enforce policy, mangle packets etc.
The other option you would have is that controller would load and pin
the prog as a node into BPF fs and you can then get the fd and attach
it to to the veth inside the netns if this is what you're after (the
attach itself in the second step does not require anything extra compared
to rest of tc) provided the mount is shared at setup time (but could
later be removed in the container for example). In future it might be
subject to change to also enable it for userns under the constraint that
verifier puts more restrictions in place in roughly similar fashion to
current unpriv program types, that work just hasn't been tackled yet.

Thanks,
Daniel

> The original restiction comes from
>     1be7f75d1668 "bpf: enable non-root eBPF programs"
> quote:
>     tracing and tc cls/act program types still require root permissions,
>     since tracing actually needs to be able to see all kernel pointers
>     and tc is for root only.
> 
> Can the restriction be relaxed, as done for TYPE_SOCKET_FILTER and later
> for TYPE_CGROUP_SKB?
> 
> Are the SCHED_CLS/SCHED_ACT progs still suspectable of leaking kernel
> pointers?
> If so, can we restrict only certain operations which are guaranteed not
> to leak, so that tc cls_bpf/act_bpf can still be used outside
> init_user_ns?
> 
> Thanks,
> Shmulik

  reply	other threads:[~2018-02-10 13:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-10  7:46 [Q] Unable to load SCHED_CLS/SCHED_ACT bpf programs from outside init_user_ns Shmulik Ladkani
2018-02-10 13:08 ` Daniel Borkmann [this message]
2018-02-10 15:28   ` Shmulik Ladkani

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=e9500f88-2484-b03b-e199-ede532d48b26@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=ast@kernel.org \
    --cc=eyal@metanetworks.com \
    --cc=fengc@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=shmulik@metanetworks.com \
    --cc=xiyou.wangcong@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.