I'm trying to run the tools in CoreOS toolbox, but keep getting the following error:
[root@ip-10-224-55-200 tools]# ./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?
BPF_PERF_OUTPUT(events);
^
/virtual/include/bcc/helpers.h:88:4: note: expanded from macro 'BPF_PERF_OUTPUT'
}; \
^
/virtual/main.c:26:5: error: bpf_table events failed to open
events.perf_submit(ctx, data, sizeof(struct data_t));
^
/virtual/main.c:74:5: error: bpf_table events failed to open
events.perf_submit(ctx, &data, sizeof(data));
^
3 errors generated.
Traceback (most recent call last):
File "./execsnoop", line 132, in <module>
b = BPF(text=bpf_text.replace("MAXARG", args.max_args))
File "/usr/lib/python2.7/site-packages/bcc/__init__.py", line 301, in __init__
raise Exception("Failed to compile BPF module %s" % src_file)
Exception: Failed to compile BPF module
I followed the instructions to install from source here https://github.com/iovisor/bcc/blob/master/INSTALL.md#fedora---source. That all worked fine, and the tools compile and install. First I had this error:
chdir(/lib/modules/4.13.9-coreos/build): No such file or directory
So I symlinked the required directory:
ln -s /media/root/lib/modules/ /lib/modules
When I strace the process I can see the bpf call it is returning EPERM:
[root@ip-10-224-55-200 tools]# strace ./execsnoop 2>&1 | grep -i permi
bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_PERF_EVENT_ARRAY, key_size=4, value_size=4, max_entries=15, map_flags=0, inner_map_fd=0, ...}, 72) = -1 EPERM (Operation not permitted)
bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_PERF_EVENT_ARRAY, key_size=4, value_size=4, max_entries=15, map_flags=0, inner_map_fd=0, ...}, 72) = -1 EPERM (Operation not permitted)
I think the BPF stuff is enabled in the kernel:
[root@ip-10-224-55-200 tools]# zgrep -i bpf /proc/config.gz
# CONFIG_CGROUP_BPF is not set
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_NET_CLS_BPF=m
# CONFIG_NET_ACT_BPF is not set
CONFIG_BPF_JIT=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
# CONFIG_TEST_BPF is not set
The man page for bpf says the following:
EPERM The call was made without sufficient privilege (without the
CAP_SYS_ADMIN capability).
but it looks like toolbox includes this:
sudo systemd-nspawn \
--directory="${machinepath}" \
--capability=all \
--share-system \
${TOOLBOX_BIND} \
${TOOLBOX_ENV} \
--user="${TOOLBOX_USER}" "$@"
I'm running toolbox as root.
System details:
~ $ uname -a
Linux ip-10-224-55-200 4.13.9-coreos #1 SMP Thu Oct 26 03:21:00 UTC 2017 x86_64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz GenuineIntel GNU/Linux
Any idea why this is not working? Should it even work?
I'm trying to run the tools in CoreOS toolbox, but keep getting the following error:
I followed the instructions to install from source here https://github.com/iovisor/bcc/blob/master/INSTALL.md#fedora---source. That all worked fine, and the tools compile and install. First I had this error:
So I symlinked the required directory:
When I strace the process I can see the
bpfcall it is returningEPERM:I think the BPF stuff is enabled in the kernel:
The man page for
bpfsays the following:but it looks like
toolboxincludes this:I'm running
toolboxas root.System details:
Any idea why this is not working? Should it even work?