-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check CAP_BPF should use bit shift #714
Comments
The current implementation To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Indeed. Pls send a PR to fix it. If CAP_BPF is not available, pls check CAP_SYS_ADMIN instead. |
Okay, i will send a pr later today. |
More hint for you: static inline bool bpf_capable(void)
{
return capable(CAP_BPF) || capable(CAP_SYS_ADMIN);
} From commit torvalds/linux@a17b53c ("bpf, capability: Introduce CAP_BPF") v5.8 kernel. |
The way to check whether CAP_BPF is available is to read /proc/sys/kernel/cap_last_cap. |
Describe the bug
Current code:
ecapture/cli/cmd/env_detection.go
Lines 46 to 61 in 91b8be1
Use
haveBpfCap := data[0].Permitted&unix.CAP_BPF != 0
.But according to the linux man pages: https://man7.org/linux/man-pages/man2/capset.2.html:
It should change to
haveBpfCap := data[0].Permitted&(1<<unix.CAP_BPF) != 0
.If this is indeed a mistake, i can submit a pr to fix it.
The text was updated successfully, but these errors were encountered: