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

new(driver/bpf): added bpf configure system similar to the kmod one. #1729

Merged
merged 3 commits into from
Mar 11, 2024

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Mar 6, 2024

What type of PR is this?

/kind bug
/kind feature

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:

This is the corrispettive of #1452 for bpf.
Moreover, it also adds a fix for rss_stat becoming an array in kernel 6.2 (this was backported in centos 5.14: https://falcosecurity.github.io/libs/matrix_X64/#centos-514-bpf-probe_build).

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

While we could somehow reuse same code used for kmod, i preferred to duplicate it a bit but at the same time making the code driver-dependent since we might have to add very specific/different test cases in the future (imagine if eg: some kernel backported BPF_FUNC_ktime_get_boot_ns or if we want to enable BPF_SUPPORTS_RAW_TRACEPOINTS by checking that the kernel has backported some features...)
Indeed the very first test case added, ie: checking for rss_stat field being an array in mm_struct kernel structure, could also be made as a simpler kmod configure module and then its define added to bpf driver too, somehow.

Does this PR introduce a user-facing change?:

NONE

Then, added fix for rss_stat becoming an array in kernel 6.2.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Copy link

github-actions bot commented Mar 6, 2024

Please double check driver/API_VERSION file. See versioning.

/hold

// struct mm_struct declaration
#include <linux/mm_types.h>

#ifdef BPF_SUPPORTS_RAW_TRACEPOINTS
Copy link
Contributor Author

@FedeDP FedeDP Mar 6, 2024

Choose a reason for hiding this comment

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

Below follows the same macro found in probe.c.

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 6, 2024

Please double check driver/API_VERSION file. See versioning.

/unhold

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 6, 2024

/hold

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 6, 2024

Kernel tests against this branch:

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-4.19 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2-5.10 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2023-6.1 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.0 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.7 🟢 🟢 🟢 🟢 🟢 🟢
centos-3.10 🟢 🟢 🟢 🟡 🟡 🟡
centos-4.18 🟢 🟢 🟢 🟢 🟢 🟢
centos-5.14 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.17 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.8 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-3.10 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-4.14 🟢 🟢 🟢 🟢 🟢 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-5.4 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-4.15 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-5.8 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-6.5 🟢 🟢 🟢 🟢 🟢 🟢

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 6, 2024

/unhold

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 6, 2024

/milestone next-driver

@poiana poiana added this to the next-driver milestone Mar 6, 2024
@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 6, 2024

/milestone 0.15.0

@poiana poiana modified the milestones: next-driver, 0.15.0 Mar 6, 2024
Now we are able to build bpf probe from installed path.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
$(info [configure-bpf] Including $(MAKEFILE_INC_FILES))
include $(MAKEFILE_INC_FILES)
endif

$(obj)/probe.o: $(src)/probe.c \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

probe.o target must be visible when our makefile is called by kernel's makefile, ie: when we fall in the else branch now.

# MIT.txt or GPL.txt for full copies of the license.
#

always-y += test.o
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this makefile we want to build a stupidly simple bpf probe.

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 8, 2024

Note: for bpf we don't need the changes from #1734.

jasondellaluce
jasondellaluce previously approved these changes Mar 11, 2024
Copy link
Contributor

@jasondellaluce jasondellaluce left a comment

Choose a reason for hiding this comment

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

Seems quite nice! Love all these improvements.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@@ -27,16 +27,6 @@ or GPL2.txt for full copies of the license.
#include "fillers.h"
#include "builtins.h"

#ifdef BPF_SUPPORTS_RAW_TRACEPOINTS
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to types.h.

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.

/approve

@poiana
Copy link
Contributor

poiana commented Mar 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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 03f027a into master Mar 11, 2024
51 checks passed
@poiana poiana deleted the new/bpf_configure_system branch March 11, 2024 09:37
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