Skip to content

wip: bpf driver enhancements - #5

Closed
fntlnz wants to merge 34 commits into
masterfrom
driver/libbpf-porting
Closed

fntlnz wants to merge 34 commits into
masterfrom
driver/libbpf-porting

Conversation

@fntlnz

@fntlnz fntlnz commented Feb 17, 2021 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug
/kind feature

Any specific area of the project related to this PR?

/area driver-ebpf

What this PR does / why we need it:

One of the biggest struggle for Falco users is that they have to have kernel headers

  • libbpf cmake module
  • link userspace against libbpf
  • compile probe against libbpf
  • have a portable probe
  • fixes for incompatible registers (maybe open a different PR for this?)
  • check that this still works on older kernels 4.18, 4.19 - I already tested and it does, but want to do more extensive testing
  • BTF does not port kernel defines to vmlinux.h we need to copy and maintain in sync the ones we want for the different architectures. The ones we copied don't change very often. This is the recommended way now.
  • Make a small testing framework for the fillers based on the generated loader (now commented in makefile)
  • load the portable probe using libbpf directly (needed? feasible? worth?)
    • even if using the generated loader is not worth we probably want to consider replacing our raw usage of the bpf syscall and perf buffers and let libbpf handle that
  • Document how to use the bpf probe standalone
  • Document how to write ebpf filler tests

Signed-off-by: Lorenzo Fontana lo@linux.com

Which issue(s) this PR fixes:

Fixes #4

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

@poiana

poiana commented Feb 17, 2021

Copy link
Copy Markdown
Contributor

@fntlnz: The label(s) area/driver-ebpf cannot be applied, because the repository doesn't have them

Details

In response to this:

@poiana poiana added the kind/feature New feature or request label Feb 17, 2021
@poiana

poiana commented Feb 17, 2021

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign fntlnz after the PR has been reviewed.
You can assign the PR to them by writing /assign @fntlnz in a comment when ready.

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

Details 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 requested review from ldegio and leodido February 17, 2021 15:01
@poiana

poiana commented Feb 17, 2021

Copy link
Copy Markdown
Contributor

@fntlnz: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@fntlnz fntlnz changed the title bpf driver enhancements wip: bpf driver enhancements Feb 17, 2021
@fntlnz
fntlnz force-pushed the driver/libbpf-porting branch from 7531145 to d46161d Compare February 19, 2021 11:42
@fntlnz
fntlnz force-pushed the driver/libbpf-porting branch 2 times, most recently from cfe7b8e to 38b8812 Compare February 19, 2021 11:47
fntlnz added 10 commits March 12, 2021 11:11
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
vmlinux.h

Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
relocations for reads.

Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
We can use libbpf + BTF without necessarily using the CO-RE
definitions to read structure fields.

This is necessary so that we can still compile without kernel headers
even if when we don't compile CO-RE.

Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
fntlnz added 20 commits March 12, 2021 11:11
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
…, assertions and checks

Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Still need to make the interface cleaner for those who write the tests to
reuse some code and then write all the other tests.

Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
…he tests

Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
…ameat2 filler test

Signed-off-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
@fntlnz
fntlnz force-pushed the driver/libbpf-porting branch from aa8705d to f1a50c8 Compare March 12, 2021 10:12
@poiana

poiana commented Mar 12, 2021

Copy link
Copy Markdown
Contributor

@fntlnz: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
build-libs f1a50c8 link /test build-libs
build-libs-bundled-deps f1a50c8 link /test build-libs-bundled-deps

Full PR test history. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@poiana

poiana commented Mar 16, 2021

Copy link
Copy Markdown
Contributor

@fntlnz: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@fntlnz fntlnz mentioned this pull request Mar 22, 2021
6 tasks done
@fntlnz

fntlnz commented Mar 22, 2021

Copy link
Copy Markdown
Contributor Author

/close in favor of #22

@fntlnz fntlnz closed this Mar 22, 2021
hhoffstaette added a commit to hhoffstaette/falcosecurity-libs that referenced this pull request Aug 3, 2025
glibc-2.42 added __inet_ntop_chk fortification, which started to fail:

  *** buffer overflow detected ***: terminated
  Program received signal SIGABRT, Aborted.
  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  (gdb) bt
  #0  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  falcosecurity#1  0x00007ffff6242572 in raise () from /lib64/libc.so.6
  falcosecurity#2  0x00007ffff6229f3b in abort () from /lib64/libc.so.6
  falcosecurity#3  0x00007ffff622b148 in __libc_message_impl.cold () from /lib64/libc.so.6
  falcosecurity#4  0x00007ffff6327337 in __fortify_fail () from /lib64/libc.so.6
  falcosecurity#5  0x00007ffff6326c92 in __chk_fail () from /lib64/libc.so.6
  falcosecurity#6  0x00007ffff6327a62 in __inet_ntop_chk () from /lib64/libc.so.6
  falcosecurity#7  0x000055555569da3d in inet_ntop (__af=10, __src=0x555555ee0800, __dst=0x7fffffff4f90 "\260P\377\377\377\177", __dst_size=100) at /usr/include/bits/inet-fortified.h:36
  falcosecurity#8  ipv6tuple_to_string[abi:cxx11](ipv6tuple*, bool) (tuple=0x555555ee0800, resolve=false) at /tmp/portage/dev-debug/sysdig-0.40.1/work/libs-0.20.0/userspace/libsinsp/utils.c

Use INET6_ADDRSTRLEN as destination buffer size.

Fixes: falcosecurity#2573
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
hhoffstaette added a commit to hhoffstaette/falcosecurity-libs that referenced this pull request Aug 4, 2025
glibc-2.42 added __inet_ntop_chk fortification, which started to fail:

  *** buffer overflow detected ***: terminated
  Program received signal SIGABRT, Aborted.
  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  (gdb) bt
  #0  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  falcosecurity#1  0x00007ffff6242572 in raise () from /lib64/libc.so.6
  falcosecurity#2  0x00007ffff6229f3b in abort () from /lib64/libc.so.6
  falcosecurity#3  0x00007ffff622b148 in __libc_message_impl.cold () from /lib64/libc.so.6
  falcosecurity#4  0x00007ffff6327337 in __fortify_fail () from /lib64/libc.so.6
  falcosecurity#5  0x00007ffff6326c92 in __chk_fail () from /lib64/libc.so.6
  falcosecurity#6  0x00007ffff6327a62 in __inet_ntop_chk () from /lib64/libc.so.6
  falcosecurity#7  0x000055555569da3d in inet_ntop (__af=10, __src=0x555555ee0800, __dst=0x7fffffff4f90 "\260P\377\377\377\177", __dst_size=100) at /usr/include/bits/inet-fortified.h:36
  falcosecurity#8  ipv6tuple_to_string[abi:cxx11](ipv6tuple*, bool) (tuple=0x555555ee0800, resolve=false) at /tmp/portage/dev-debug/sysdig-0.40.1/work/libs-0.20.0/userspace/libsinsp/utils.c

Use INET6_ADDRSTRLEN as destination buffer size.

Fixes: falcosecurity#2573
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
poiana pushed a commit that referenced this pull request Aug 4, 2025
glibc-2.42 added __inet_ntop_chk fortification, which started to fail:

  *** buffer overflow detected ***: terminated
  Program received signal SIGABRT, Aborted.
  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  (gdb) bt
  #0  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  #1  0x00007ffff6242572 in raise () from /lib64/libc.so.6
  #2  0x00007ffff6229f3b in abort () from /lib64/libc.so.6
  #3  0x00007ffff622b148 in __libc_message_impl.cold () from /lib64/libc.so.6
  #4  0x00007ffff6327337 in __fortify_fail () from /lib64/libc.so.6
  #5  0x00007ffff6326c92 in __chk_fail () from /lib64/libc.so.6
  #6  0x00007ffff6327a62 in __inet_ntop_chk () from /lib64/libc.so.6
  #7  0x000055555569da3d in inet_ntop (__af=10, __src=0x555555ee0800, __dst=0x7fffffff4f90 "\260P\377\377\377\177", __dst_size=100) at /usr/include/bits/inet-fortified.h:36
  #8  ipv6tuple_to_string[abi:cxx11](ipv6tuple*, bool) (tuple=0x555555ee0800, resolve=false) at /tmp/portage/dev-debug/sysdig-0.40.1/work/libs-0.20.0/userspace/libsinsp/utils.c

Use INET6_ADDRSTRLEN as destination buffer size.

Fixes: #2573
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
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.

BPF probe compilation under Clang 10 and Clang 11

2 participants