Skip to content
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

fix(driver/bpf): fixed bpf probe build on kernel >= 6.2 #922

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Feb 22, 2023

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area driver-bpf

Does this PR require a change in the driver versions?

What this PR does / why we need it:

Fixes build of old bpf probe on kernel >= 6.2.0.
See: torvalds/linux@f1a7941

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(driver/bpf): fixed build of bpf probe on linux >= 6.2

@FedeDP
Copy link
Contributor Author

FedeDP commented Feb 22, 2023

Driverkit was finally able to build both kmod and ebpf drivers for 6.2.0:

DEBU 5clang -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h \
DEBU    -D__KERNEL__ -fmacro-prefix-map=./= \
DEBU     \
DEBU     \
DEBU    -D__KERNEL__ \
DEBU    -D__BPF_TRACING__ \
DEBU    -Wno-gnu-variable-sized-type-not-at-end \
DEBU    -Wno-address-of-packed-member \
DEBU    -fno-jump-tables \
DEBU    -fno-stack-protector \
DEBU    -Wno-tautological-compare \
DEBU    -O2 -g -emit-llvm -c /tmp/driver/bpf/probe.c -o /tmp/driver/bpf/probe.ll
DEBU {In file included from /tmp/driver/bpf/probe.c:16:
DEBU In file included from ./include/linux/sched.h:12:
DEBU In file included from ./arch/x86/include/asm/current.h:9:
DEBU In file included from ./include/linux/cache.h:6:
DEBU In file included from ./arch/x86/include/asm/cache.h:5:
DEBU In file included from ./include/linux/linkage.h:8:
DEBU In file included from ./arch/x86/include/asm/linkage.h:6:
DEBU ./arch/x86/include/asm/ibt.h:77:8: warning: 'nocf_check' attribute ignored; use -fcf-protection to enable the attribute [-Wignored-attributes]
DEBU extern __noendbr u64 ibt_save(void);
DEBU        ^
DEBU ./arch/x86/include/asm/ibt.h:32:34: note: expanded from macro '__noendbr'
DEBU ]#define __noendbr       __attribute__((nocf_check))
DEBU                                        ^
DEBU �./arch/x86/include/asm/ibt.h:78:8: warning: 'nocf_check' attribute ignored; use -fcf-protection to enable the attribute [-Wignored-attributes]
DEBU �extern __noendbr void ibt_restore(u64 save);
DEBU        ^
DEBU ./arch/x86/include/asm/ibt.h:32:34: note: expanded from macro '__noendbr'
DEBU ]#define __noendbr       __attribute__((nocf_check))
DEBU                                        ^
DEBU 2 warnings generated.
DEBU Qllc -march=bpf -filetype=obj -o /tmp/driver/bpf/probe.o /tmp/driver/bpf/probe.ll
DEBU )  MODPOST /tmp/driver/bpf/Module.symvers
DEBU )make[1]: Leaving directory '/tmp/kernel'
DEBU + ls -l probe.o
DEBU 4-rw-r--r-- 1 root root 4489856 Feb 22 14:16 probe.o
DEBU log pipe close                                error=EOF
INFO kernel module available                       path=/tmp/arch.ko
INFO eBPF probe available                          path=/tmp/arch.o

/cc @Molter73 @Andreagit97

@poiana poiana requested a review from Molter73 February 22, 2023 14:17
@FedeDP
Copy link
Contributor Author

FedeDP commented Feb 22, 2023

/milestone next-driver

@poiana poiana added this to the next-driver milestone Feb 22, 2023
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@FedeDP
Copy link
Contributor Author

FedeDP commented Feb 22, 2023

Rebased on top of master. 🙏 should work fine now!

@FedeDP
Copy link
Contributor Author

FedeDP commented Feb 22, 2023

@github-actions
CI Build / build-libs-driverkit (linux-2.6.x) (pull_request) Successful in 39s
[Details](https://github.com/falcosecurity/libs/actions/runs/4243809261/jobs/7377047371)
@github-actions
CI Build / build-libs-driverkit (linux-3.x) (pull_request) Successful in 32s
[Details](https://github.com/falcosecurity/libs/actions/runs/4243809261/jobs/7377047570)
@github-actions
CI Build / build-libs-driverkit (linux-4.x) (pull_request) Successful in 42s
[Details](https://github.com/falcosecurity/libs/actions/runs/4243809261/jobs/7377047766)
@github-actions
CI Build / build-libs-driverkit (linux-5.x) (pull_request) Successful in 1m
[Details](https://github.com/falcosecurity/libs/actions/runs/4243809261/jobs/7377047937)
@github-actions
CI Build / build-libs-driverkit (linux-6.x) (pull_request) Successful in 46s

yay!

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to fix this also in the modern probe, I will try to find a solution without ifdefs.. In the meanwhile we can merge this to fix the CI
/approve

Copy link
Contributor

@Molter73 Molter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@poiana
Copy link
Contributor

poiana commented Feb 22, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, Molter73

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit d8c6aac into master Feb 22, 2023
@poiana poiana deleted the fix/bpf_linux6.2 branch February 22, 2023 16:28
@FedeDP FedeDP mentioned this pull request Feb 23, 2023
3 tasks
@FedeDP
Copy link
Contributor Author

FedeDP commented Feb 23, 2023

/milestone 4.0.1+driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants