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/ebpf): fixed eBPF issues on clang5 #109

Merged
merged 3 commits into from
Oct 29, 2021

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Oct 27, 2021

Signed-off-by: Federico Di Pierro nierro92@gmail.com

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area driver-ebpf

What this PR does / why we need it:

It fixes some incompatibilities between eBPF probe and clang5.
Clang5 is provided with falco-builder docker image, thus it is important to support it; see see falcosecurity/falco#1761.
Tested on kernel 4.19.0 and clang 5.0.1, and kernel 5.14.14 and clang 12.0.1.
As the PR actually just adds some checks, i think we can skip the full test matrix.

All the following changes are mandatory:

  • bound check state->n_drops_X counters
  • moved off_bounded declaration near its usage in bpf_parse_readv_writev_bufs()
  • force-disable switch jump table

The latter one was the most tricky: it seems like we already disable jump table in our makefile with the -fno-jump-tables flag.
But it seems like clang-5 with -O2 optimization flags, still somewhat makes use of them.
Thus, use a "smart" trick to disable them in any case.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(driver/ebpf): fix ebpf probe on clang5.

* bound check state->n_drops_X counters
* moved off_bounded declaration near its usage in bpf_parse_readv_writev_bufs()
* force-disable switch jump table

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

poiana commented Oct 27, 2021

Hi @FedeDP. Thanks for your PR.

I'm waiting for a falcosecurity member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@FedeDP
Copy link
Contributor Author

FedeDP commented Oct 28, 2021

It seems like we still got some issues on falco-builder env: falcosecurity/falco#1761 (comment)

Let's keep this open in wip mode to track all the required fixes.

@FedeDP FedeDP changed the title fix(driver/ebpf): fixed eBPF issues on clang5 wip: fix(driver/ebpf): fixed eBPF issues on clang5 Oct 28, 2021
@FedeDP FedeDP changed the title wip: fix(driver/ebpf): fixed eBPF issues on clang5 fix(driver/ebpf): fixed eBPF issues on clang5 Oct 28, 2021
@FedeDP
Copy link
Contributor Author

FedeDP commented Oct 28, 2021

It was an user mistake, the patch is working fine!

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

leogr commented Oct 28, 2021

/ok-to-test

@FedeDP
Copy link
Contributor Author

FedeDP commented Oct 28, 2021

More tests:

  • clang 14.0.0 on linux 4.19.0
  • clang 12.0.1 on linux 4.19.0
  • clang 7.0.1 on linux 4.19.0
  • clang 10.0.0 on linux 5.11.0
    I think this is safe to go.

…, not kmod: kmod allows jump table usage.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@poiana poiana added size/M and removed size/S labels Oct 28, 2021
@poiana
Copy link
Contributor

poiana commented Oct 28, 2021

LGTM label has been added.

Git tree hash: 17c470fe23f300758c47c86d8cbd7cdcb8919a2c

Copy link
Member

@leogr leogr 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 Oct 29, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, leogr

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

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