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(scripts): driver loader insmod #2388

Merged
merged 2 commits into from
Jan 30, 2023
Merged

fix(scripts): driver loader insmod #2388

merged 2 commits into from
Jan 30, 2023

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Jan 30, 2023

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

What this PR does / why we need it:

Reverts 3087362; we always need to use insmod to avoid weird situations (eg: multiple drivers being installed at the same time, and modprobe choosing the oldest one).
Moreover, for package/host installations, enforce the usage of dkms, with --compile flag.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

echo "[POST-INSTALL] Call 'falco-driver-loader bpf':"
falco-driver-loader bpf
echo "[POST-INSTALL] Call 'falco-driver-loader --compile bpf':"
falco-driver-loader --compile bpf
Copy link
Contributor Author

@FedeDP FedeDP Jan 30, 2023

Choose a reason for hiding this comment

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

@leogr do we need to compile-only the bpf probe?
Perhaps we can download it too, instead.

Copy link
Contributor Author

@FedeDP FedeDP Jan 30, 2023

Choose a reason for hiding this comment

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

Or even better, we might want to add the falco-driver-loader --compile X in falco-kmod and falco-bpf.service, as PreStart?
This way, we could enforce that a driver is always properly loaded.

Copy link
Member

@leogr leogr Jan 30, 2023

Choose a reason for hiding this comment

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

Since in a local system, one is supposed to have all required dependencies installed (i.e., kernel headers), I'd not use the download approach. It could create more issues than benefits (for example, think in an air-gapped env).

For the kmod use case, assuming that dkms will automatically rebuild the module when the local kernel is upgraded, I think the post-install approach is enough. It should work in all situations.

For the ebpf case, it likely won't. Immagine the following situation:

  • the current kernel version is X
  • the user installs Falco, and the ebpf gets built for X
  • the user upgrades the kernel to Y
  • the system is rebooted
  • Falco won't work anymore because the probe was built for X

I don't have a definitive answer yet, but the best option is likely to leave the kmod at the post-install stage and only move the bpf at the PreStart stage. 🤔 (Although I don't like this kinda asymmetry).

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 30, 2023

/milestone 0.34.0

@poiana poiana added this to the 0.34.0 milestone Jan 30, 2023
LucaGuerra
LucaGuerra previously approved these changes Jan 30, 2023
Copy link
Contributor

@LucaGuerra LucaGuerra left a comment

Choose a reason for hiding this comment

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

LGTM, I didn't notice that the insmod line was still there :)

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 30, 2023

/hold

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.

SGTM, but I've got a doubt.

See my comment below.

echo "[POST-INSTALL] Call 'falco-driver-loader bpf':"
falco-driver-loader bpf
echo "[POST-INSTALL] Call 'falco-driver-loader --compile bpf':"
falco-driver-loader --compile bpf
Copy link
Member

@leogr leogr Jan 30, 2023

Choose a reason for hiding this comment

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

Since in a local system, one is supposed to have all required dependencies installed (i.e., kernel headers), I'd not use the download approach. It could create more issues than benefits (for example, think in an air-gapped env).

For the kmod use case, assuming that dkms will automatically rebuild the module when the local kernel is upgraded, I think the post-install approach is enough. It should work in all situations.

For the ebpf case, it likely won't. Immagine the following situation:

  • the current kernel version is X
  • the user installs Falco, and the ebpf gets built for X
  • the user upgrades the kernel to Y
  • the system is rebooted
  • Falco won't work anymore because the probe was built for X

I don't have a definitive answer yet, but the best option is likely to leave the kmod at the post-install stage and only move the bpf at the PreStart stage. 🤔 (Although I don't like this kinda asymmetry).

In this way, dkms will gracefully handle kernels updates.

Signed-off-by: Federico Di Pierro <[email protected]>
@@ -8,6 +8,7 @@ Wants=falcoctl-artifact-follow.service
Type=simple
User=root
Environment=FALCO_BPF_PROBE=
ExecStartPre=/usr/bin/falco-driver-loader bpf
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We chose to enable download too for ebpf probe, because it has a clang dep that might not be satisfied and we don't want to enforce it.
Moreover, given that ebpf probe is not managed by the system (dkms) it's ok to manage it ourselves.

Finally, note that if the correct ebpf probe is already in place, the falco-driver-loader script won't do anything: https://github.com/falcosecurity/falco/blob/master/scripts/falco-driver-loader#L585

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 30, 2023

/unhold

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.

/approve

@poiana
Copy link
Contributor

poiana commented Jan 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, jasondellaluce, 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:
  • OWNERS [FedeDP,jasondellaluce,leogr]

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 132484c into master Jan 30, 2023
@poiana poiana deleted the fix/driver_loader_isnmod branch January 30, 2023 10:30
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