We've disabled eBPF for normal users on our Linux machines

April 17, 2020

In late March, there was a Linux kernel security issue, CVE-2020-8835 (also). This was, to quote the Ubuntu CVE description:

In the Linux kernel 5.5.0 and newer, the bpf verifier (kernel/bpf/verifier.c) did not properly restrict the register bounds for 32-bit operations, leading to out-of-bounds reads and writes in kernel memory. The vulnerability also affects the Linux 5.4 stable series, starting with v5.4.7, [...]

We were lucky. Because we run the standard Ubuntu 18.04 server kernels instead of the HWE kernels, we were not affected by this and did not have to go through a fleet wide kernel update and reboot while working from home.

You might wonder why an issue in eBPF creates a security vulnerability, as I did at the time. The answer is that these days, eBPF programs can be used by ordinary users on their own sockets (contrary to what the current bpf(2) manpage says; per the exploit writeup, this was a change added in kernel 4.4). This means that bugs in the eBPF verifier and JIT translation that allow bad stuff to slip through are fatal; the entire system's security rests on them being completely right all of the time.

Fortunately there is a kernel sysctl that controls whether normal users can use eBPF, kernel.unprivileged_bpf_disabled; if set to '1', normal users can't use eBPF. You can probably guess what we immediately did when this CVE came out, even though it didn't apply to us; we immediately pushed out a local update to all of our machines that turned this on, disabling user eBPF programs. Much like user namespaces (which kept enabling kernel security issues) and overlayfs, we feel that allowing user eBPF programs is too much risk right now for too little potential gain. Perhaps someday there will be a compelling usage for this, but for now we'd rather avoid a whole class of potential security issues.

(If anything has broken as a result of this, people haven't told us.)


Comments on this page:

By first time caller at 2020-04-19 01:45:50:

On the subject of ebpf (but in a good way), you may be interested in 'nfsdtop' - see this thread

https://twitter.com/freebsdfrau/status/1238541870612926465

It can do per-ip/user/group read/write breakdown.

A few issues

  • may need tweaks depending on kernel version due to struct changes (f_dentry becomes f_path.dentry)
  • only nfs 2/3 (not 4)
  • hwe kernel possibly preferable to reduce performance impact

Easiest to test it out on 18.04 with the bpftrace backport: https://chabik.com/2020/01/backporting-bcc-bpftrace/

The author has a number of other bpftrace i/o related utilities on her github: https://github.com/FrauBSD

Written on 17 April 2020.
« Some bits of grep usage are where I disagree with Shellcheck
GMail, POP, and TLS server certificate verification »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Apr 17 23:24:22 2020
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.