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/modern_bpf): Add ppc64le support for modern-bpf #1475

Merged
merged 11 commits into from
Nov 15, 2023

Conversation

mdafsanhossain
Copy link
Contributor

@mdafsanhossain mdafsanhossain commented Nov 7, 2023

What type of PR is this?
/kind feature

Any specific area of the project related to this PR?

/area driver-modern-bpf
/area libscap-engine-modern-bpf
/area libscap

What this PR does / why we need it:
This PR adds PPC64LE specific changes to allow compiling of modern-bpf on PowerPC architecture. This is to add modern-bpf support for Stackrox on ppc64le.

Output of make ProbeSkeleton and make scap are attached below.

scap-build.log
probeskeleton.log

Note: syscall_compat_* headers were generated using ./build/syscalls-bumper -repo-root /root/libs -overwrite

Does this PR introduce a user-facing change?:

new(modern-bpf): support ppc64le architecture.

@poiana
Copy link
Contributor

poiana commented Nov 7, 2023

Welcome @mdafsanhossain! It looks like this is your first PR to falcosecurity/libs 🎉

@poiana poiana added the size/XXL label Nov 7, 2023
@FedeDP
Copy link
Contributor

FedeDP commented Nov 7, 2023

Hi! Thanks for this PR! Is there any plan to support ppc64le also for old bpf probe (and eventually kmod too)?
Btw:

Note: syscall_compat_* headers were generated using ./build/syscalls-bumper -repo-root /root/libs -overwrite

syscalls-bumper does not support ppc64le though; was its support added locally? Can you open a PR over there too?
I noticed that:

  • the report.md changes look weird (it seems like riscv64 arch was dropped?)
  • some syscalls were removed from syscall_compat_* and that is weird too

@Andreagit97 Andreagit97 added this to the TBD milestone Nov 7, 2023
@mdafsanhossain
Copy link
Contributor Author

mdafsanhossain commented Nov 8, 2023

Hi! Thanks for this PR! Is there any plan to support ppc64le also for old bpf probe (and eventually kmod too)? Btw:

Note: syscall_compat_* headers were generated using ./build/syscalls-bumper -repo-root /root/libs -overwrite

syscalls-bumper does not support ppc64le though; was its support added locally? Can you open a PR over there too? I noticed that:

  • the report.md changes look weird (it seems like riscv64 arch was dropped?)
  • some syscalls were removed from syscall_compat_* and that is weird too

Yes I added the support locally and built it.

diff --git a/main.go b/main.go
index ae9eae9..d085ea1 100644
--- a/main.go
+++ b/main.go
@@ -119,10 +119,10 @@ func initOpts() {
 // key should be consistent with the one used by https://github.com/hrw/syscalls-table/tree/master/tables.
 // Value should be the suffix used by libs/driver/syscall_compat_* headers.
 var supportedArchs = map[string]string{
-       "x86_64":  "x86_64",
-       "arm64":   "aarch64",
-       "s390x":   "s390x",
-       "riscv64": "riscv64",
+       "x86_64":    "x86_64",
+       "arm64":     "aarch64",
+       "s390x":     "s390x",
+       "powerpc64": "ppc64le",
 }

I removed riscv64 from the list. I will revert the last commit and regenerate it with riscv64 included.
Do you know why some of the syscalls are being removed?
And, are the above changes sufficient to generate correctly?

@FedeDP
Copy link
Contributor

FedeDP commented Nov 8, 2023

I removed riscv64 from the list. I will revert the last commit and regenerate it with riscv64 included.

Thanks!

And, are the above changes sufficient to generate correctly?

Yes, they are!

Do you know why some of the syscalls are being removed?

Just double checked! Yep because they were cleaned up by the project that syscalls-bumper uses under the hood: hrw/syscalls-table@079ef06, hrw/syscalls-table@94b4691, hrw/syscalls-table@046c3b5

@FedeDP
Copy link
Contributor

FedeDP commented Nov 8, 2023

Also, you now need a rebase since a PR with automatic bump of syscall-bumper was merged ;)

@FedeDP
Copy link
Contributor

FedeDP commented Nov 8, 2023

Also, once this is fully in place, mind to also update README adding the new supported arch for modern bpf probe as EXPERIMENTAL?

@mdafsanhossain
Copy link
Contributor Author

Also, you now need a rebase since a PR with automatic bump of syscall-bumper was merged ;)

Thanks. I will do that, clean it up and after that update the README too.

SYSCALL = 0,
//SYSCALL definition is skipped on powerpc since SYSCALL is already defined in vmlinux.h
#ifndef __TARGET_ARCH_powerpc
SYSCALL = 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we just need to avoid name collision, by prefixing these ones with eg: MODERN_BPF_.
@Andreagit97 thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FedeDP Do you mean something like this? MODERN_BPF_SYSCALL=0? I am not sure if I am understanding this correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

enum intrumentation_type
{
               MODERN_BPF_SYSCALL = 0,
               MODERN_BPF_TRACEPOINT = 1,
}

and then rename their usages whereveer sampling_logic is called.

Copy link
Member

Choose a reason for hiding this comment

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

yes I agree, probably we can rename them in INSTR_TYPE_SYSCALL and INSTR_TYPE_TRACEPOINT

Copy link
Member

Choose a reason for hiding this comment

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

uhm I didn't see new messages, if we all agree it's also okay to go with

enum intrumentation_type
{
               MODERN_BPF_SYSCALL = 0,
               MODERN_BPF_TRACEPOINT = 1,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense now. Thanks :)

@FedeDP
Copy link
Contributor

FedeDP commented Nov 8, 2023

/milestone next-driver

@poiana poiana modified the milestones: TBD, next-driver Nov 8, 2023
@mdafsanhossain
Copy link
Contributor Author

@FedeDP Is it fine that the syscalls are being removed?

@FedeDP
Copy link
Contributor

FedeDP commented Nov 8, 2023

Is it fine that the syscalls are being removed?

It is ;)
This LGTM except for the comment on driver/modern_bpf/helpers/interfaces/attached_programs.h.

Were you able to run drivers_test tests on a real ppc64le machine?

@mdafsanhossain
Copy link
Contributor Author

Is it fine that the syscalls are being removed?

It is ;) This LGTM except for the comment on driver/modern_bpf/helpers/interfaces/attached_programs.h.

Were you able to run drivers_test tests on a real ppc64le machine?

I am running it now.
Do you have a better way to resolve the conflict on driver/modern_bpf/helpers/interfaces/attached_programs.h.?

Copy link
Member

Choose a reason for hiding this comment

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

we bumped this because new PPM_CODES could be sent from the drivers

@mdafsanhossain
Copy link
Contributor Author

Is it fine that the syscalls are being removed?

It is ;) This LGTM except for the comment on driver/modern_bpf/helpers/interfaces/attached_programs.h.

Were you able to run drivers_test tests on a real ppc64le machine?

@FedeDP I am running into an issue while trying to run the drivers_test

-----------------------------------------------------
- Setup phase
-----------------------------------------------------

* Configure modern BPF probe tests!
* Using buffer dim: 8388608
Unable to open the engine: the specified per-CPU ring buffer dimension (0) is not allowed! Please use a power of 2 and a multiple of the actual page_size (65536)!

Steps to reproduce:

cmake -DUSE_BUNDLED_DEPS=On -DBUILD_LIBSCAP_MODERN_BPF=On -DENABLE_DRIVERS_TESTS=On -DBUILD_LIBSCAP_GVISOR=Off -DCREATE_TEST_TARGETS=On ..
make drivers_test
sudo ./test/drivers/drivers_test -m

Btw there are 2 small bugs in these files which prevents drivers_test compilation.

@FedeDP
Copy link
Contributor

FedeDP commented Nov 8, 2023

Btw there are 2 small bugs in these files which prevents drivers_test compilation.

Wow! Can you fix them? We only run drivers tests on x86_64 and aarch64 that haven't got __NR_send nor __NR_socketcall defined and nobody ever caught those issues :)
Btw the errno one is pretty weird, errno should be declared.

@Andreagit97
Copy link
Member

-----------------------------------------------------
- Setup phase
-----------------------------------------------------

* Configure modern BPF probe tests!
* Using buffer dim: 8388608
Unable to open the engine: the specified per-CPU ring buffer dimension (0) is not allowed! Please use a power of 2 and a multiple of the actual page_size (65536)!

This error is weird, the buffer dim is correct in this line

* Using buffer dim: 8388608

but in the below line is 0

Unable to open the engine: the specified per-CPU ring buffer dimension (0) is not allowed! 

It seems like someone on powerpc clears this buffer_bytes_dim 🤔

Steps to reproduce:

Just tried on my machine and it works, moreover these tests run in CI so they are working it seems something specific to powerpc

@mdafsanhossain
Copy link
Contributor Author

-----------------------------------------------------
- Setup phase
-----------------------------------------------------

* Configure modern BPF probe tests!
* Using buffer dim: 8388608
Unable to open the engine: the specified per-CPU ring buffer dimension (0) is not allowed! Please use a power of 2 and a multiple of the actual page_size (65536)!

This error is weird, the buffer dim is correct in this line

* Using buffer dim: 8388608

but in the below line is 0

Unable to open the engine: the specified per-CPU ring buffer dimension (0) is not allowed! 

It seems like someone on powerpc clears this buffer_bytes_dim 🤔

Steps to reproduce:

Just tried on my machine and it works, moreover these tests run in CI so they are working it seems something specific to powerpc

I wonder what is resetting buffer_bytes_dim to 0. I will try to debug it but I don't have much idea on it.

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.

For me it's great, thank you
/approve

@poiana
Copy link
Contributor

poiana commented Nov 15, 2023

LGTM label has been added.

Git tree hash: c2202ba3d7f45e72b107e5b3f050343da3b4f6a8

@FedeDP
Copy link
Contributor

FedeDP commented Nov 15, 2023

@mdafsanhossain can you also open the PR on syscalls-bumper please? :)

Copy link
Contributor

@FedeDP FedeDP 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 Nov 15, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@mdafsanhossain
Copy link
Contributor Author

@mdafsanhossain can you also open the PR on syscalls-bumper please? :)

Will do

@FedeDP
Copy link
Contributor

FedeDP commented Nov 15, 2023

/unhold

@poiana poiana merged commit 7092b1e into falcosecurity:master Nov 15, 2023
30 of 31 checks passed
@mdafsanhossain mdafsanhossain deleted the ppc64le-modern-bpf branch November 16, 2023 06:50
@hbrueckner
Copy link
Contributor

too late.... however, this looks very nice! Thanks a lot!
/approve

@FedeDP
Copy link
Contributor

FedeDP commented Nov 16, 2023

Ops sorry @hbrueckner , i completely forgot... my fault 😭 sorry again!

@Andreagit97 Andreagit97 changed the title new(modern_bpf): Add ppc64le support for modern-bpf new(driver/modern_bpf): Add ppc64le support for modern-bpf Jan 8, 2024
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.

5 participants