-
Notifications
You must be signed in to change notification settings - Fork 274
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
warning: "Attempt to use kernel headers from user space #47
Comments
This warning can be elimated by add
However, other |
The recommendation is to use CO-RE and vmlinux.h. If you can't or don't want to, you'll have to make sure you are including the right headers with the right definitions. bool should come from just <stdbool.h>, there rest would come from either UAPI or kernel-internal headers (and kernel-internal is where you are running into issues, probably). Check out bootstrap example for vmlinux.h usage. That makes everything much-much simpler (but you'll need kernel BTF, of course). You might want to check https://github.com/aquasecurity/btfhub and follow the BTFGen discussion which is currently happening upstream. |
Thanks for your reply. Because the BPF program will run Non-BTF OS(CONFIG_DEBUG_INFO_BTF is not set), So I imitated Minimal APP to write this BPF program. |
You can safely use vmlinux.h if you generated it from exactly the same vmlinux image that you are going to run on. Or if you are absolutely sure that you are using only types defined in kernel UAPI (which means they won't change their layout). But the latter doesn't seem true in your case, because you've tried to use internal kernel headers. So, you can use vmlinux.h without relying on CO-RE, you'll just need to make sure that you have a matching vmlinux image. And you'll need to stdbool.h was from standard libc, but you won't need it with vmlinux.h |
I imitated Minimal Makefile and wrote an out-of-kernel tree BPF program which is not CO-RE.
Hence, I include some kernel header which comes form kernel-devel in BPF program. Then I got some error:
And the Makefile:
The BPF program:
So what do we need something else to make out-of-kernel tree Non-CO-RE BPF program build successfully?
The text was updated successfully, but these errors were encountered: