iovisor / iovisor/bcc

better permission denied error messages when not root/privileged

Open
#1,325 7 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted prio:low
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
5d 13h
Merged PRs (30d)
3

Description

Sent to me by a coworker:

```$ /usr/share/bcc/tools/stackcount __alloc_fd
/virtual/main.c:8:1: error: could not open bpf map: Operation not permitted
is maps/hash map type enabled in your kernel?
BPF_HASH(counts, struct key_t);
^
/virtual/include/bcc/helpers.h:119:48: note: expanded from macro 'BPF_HASH'
BPF_HASHX(__VA_ARGS__, BPF_HASH4, BPF_HASH3, BPF_HASH2, BPF_HASH1)(__VA_ARGS__)
^
/virtual/main.c:9:1: error: could not open bpf map: Operation not permitted
is maps/stacktrace map type enabled in your kernel?
BPF_STACK_TRACE(stack_traces, 1024);
^
/virtual/include/bcc/helpers.h:154:3: note: expanded from macro 'BPF_STACK_TRACE'
BPF_TABLE("stacktrace", int, struct bpf_stacktrace, _name, _max_entries);
^
/virtual/include/bcc/helpers.h:59:76: note: expanded from macro 'BPF_TABLE'
#define BPF_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries) \
^
/virtual/include/bcc/helpers.h:55:4: note: expanded from macro '\
BPF_F_TABLE'
}; \
^
/virtual/main.c:16:19: error: bpf_table stack_traces failed to open
key.stackid = stack_traces.get_stackid(ctx, BPF_F_REUSE_STACKID);
^
3 errors generated.
Failed to compile BPF module
```

Is there a way we can improve this? Eg, if it said:

```
$ /usr/share/bcc/tools/stackcount __alloc_fd
Permission denied (not root or unprivileged). Use -v for verbose.
```

And the BPF() call could be passed a verbose flag (which would default to verbose, so tools that supported a "-v" could then overwrite it to be not verbose when -v was not used).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported /usr/share/bcc/tools/stackcount __alloc_fd failure and trace the BPF() call that reports the permission error. Determine where the generic compiler and map-opening messages are produced, then verify that non-root failures give a clearer hint while verbose output remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
devtools, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.