hello_world.py problem in Ubuntu Xenial
I installed bcc-tools following instructions in INSTALL.md. However, the test script hello_world.py fails to run:
~ sudo python /usr/share/bcc/examples/hello_world.py bpf: Operation not permitted
Traceback (most recent call last):
File "/usr/share/bcc/examples/hello_world.py", line 11, in
I'm confused as I thought we had super-user privileges via sudo.
I checked the kernel config as discussed at the top of INSTALL.md. I have also read the FAQ. What have I missed? Here is my uname output:
~ uname -a Linux jfgreen-ThinkPad-P50 4.10.0-33-generic #37~16.04.1-Ubuntu SMP Fri Aug 11 14:07:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Any help appreciated, also, please direct me if there is a more appropriate forum for questions like this, thanks.
PS "privilges" appears to be a misspelling/typo in ".../bcc/init.py"
Hitting the same error on my Ubuntu desktop,
Linux cparikh 4.10.0-35-generic #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Have you checked your build config? Is CONFIG_BPF enabled?
Yes, I checked the build config following instructions from INSTALL.md. I find these lines in /boot/config-4.10.0-33-generic:
CONFIG_BPF=y CONFIG_BPF_SYSCALL=y CONFIG_NET_CLS_BPF=m CONFIG_NET_ACT_BPF=m CONFIG_BPF_JIT=y CONFIG_BPF_JIT=y CONFIG_HAVE_EBPF_JIT=y (not CONFIG_HAVE_BPF_JIT as in INSTALL.md) CONFIG_BPF_EVENTS=y CONFIG_NET_SCH_SFQ=m CONFIG_NET_ACT_POLICE=m CONFIG_NET_ACT_GACT=m CONFIG_DUMMY=m CONFIG_VXLAN=m
Just to be sure I did not have something messed up or out of sync with kernel/header versions or other software issues, I did a clean install of Ubuntu 16.04, kernel 4.10.0-38-generic. After carefully following the INSTALL.md instructions, I get the same error as before from hello_world.py; all other examples and tools throw errors, too, similar to this one from execsnoop:
/virtual/main.c:21:1: error: could not open bpf map: Operation not permitted is maps/perf_output map type enabled in your kernel?
I don't have a second physical machine to test on, so I tried a clean install from the exact same install media into a Virtualbox VM running under Windows 10 (I am dual booting this Thinkpad P50 laptop). In the VM hello_world.py and other examples and tools I tested (I didn't try them all, but many) run fine.
So it appears (to me at least) the issue is not the kernel or software but something peculiar to the laptop itself: Lenovo Thinkpad P50, Xeon E3-1505M v5 CPU. this is a new-ish machine purchased in January of this year.
Just for good measure I wiped it again, did another clean install, and built bcc-tools from source. That went smoothly according to the source build instructions in INSTALL.md, but I get exactly the same results/errors. Kind of what I was expecting but I tried it just in case.
Make sure you have linux-headers installed (in your case linux-headers-4.10.0-38-generic).
Thanks for your comment. Installing headers to match the running kernel is part of the process described in INSTALL.md instructions. But, checking just to make sure, it seems I do:
jfgreen@Jim-ThinkPad-P50:~ $ dpkg-query -s linux-headers-4.10.0-38-generic Package: linux-headers-4.10.0-38-generic Status: install ok installed Priority: optional Section: devel Installed-Size: 7371 Maintainer: Ubuntu Kernel Team [email protected] Architecture: amd64 Source: linux-hwe Version: 4.10.0-38.42~16.04.1 Provides: linux-headers, linux-headers-3.0 Depends: linux-headers-4.10.0-38, libc6 (>= 2.14), libssl1.0.0 (>= 1.0.0) Description: Linux kernel headers for version 4.10.0 on 64 bit x86 SMP This package provides kernel header files for version 4.10.0 on 64 bit x86 SMP. . This is for sites that want the latest kernel headers. Please read /usr/share/doc/linux-headers-4.10.0-38/debian.README.gz for details.
I am beginning to think bcc-tools does not run on my hardware, though that seems weird.
Through trial and error I have discovered that disabling Secure Boot in the BIOS (UEFI) fixes (works around) this problem. I'm not knowledgeable about secure boot, but from what I've read it seems it blocks kernel modules that are not signed with a trusted secure key. Or something like that. I'm going to close this since it does not seem to be an issue with bcc-tools. Could think about mentioning in the FAQ or somewhere...