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

API versioning for user/kernel boundary #39

Merged
merged 2 commits into from
Feb 2, 2022

Conversation

gnosek
Copy link
Contributor

@gnosek gnosek commented May 7, 2021

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area build

/area driver-kmod

/area driver-ebpf

/area libscap

/area libsinsp

/area tests

What this PR does / why we need it:

This PR implements the API versioning proposal.

It basically:

  • adds an API version number (encoded in a 64-bit int) included in the userspace component and both kmod and eBPF probes
  • replaces the eBPF probe_version equality check with a semver(like) check on the contents of the probe_api_version section; this allows us to reuse eBPF probes across consumer/libs versions as long as they support the same API
  • adds a version check to the kmod open path in scap_open_live_int(); there was no such check before
  • adds driver/README.API_VERSION documenting the API versioning rules

It also takes care to reject probes predating API versioning.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

The kernel module version (as seen in e.g. `modinfo`) no longer defaults to FALCOSECURITY_LIBS_VERSION (which is generally a commit id) but to the API version (1.0.0 as of now)

action required: ensure any infrastructure for building probes uses the API version as the identifier, not the consumer version

action not required but recommended: don't override PROBE_NAME or PROBE_VERSION when building falco-libs. Your kernel module will now be named `scap.ko` with version 1.0.0 and can be shared with all other falco-libs consumers using the same kernel.

@gnosek gnosek requested review from leodido, ldegio, fntlnz and leogr May 7, 2021 17:14
@poiana
Copy link
Contributor

poiana commented May 7, 2021

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@poiana
Copy link
Contributor

poiana commented Aug 8, 2021

Issues go stale after 90d of inactivity.

Mark the issue as fresh with /remove-lifecycle stale.

Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle stale

@poiana
Copy link
Contributor

poiana commented Sep 8, 2021

Stale issues rot after 30d of inactivity.

Mark the issue as fresh with /remove-lifecycle rotten.

Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle rotten

@poiana
Copy link
Contributor

poiana commented Oct 30, 2021

Rotten issues close after 30d of inactivity.

Reopen the issue with /reopen.

Mark the issue as fresh with /remove-lifecycle rotten.

Provide feedback via https://github.com/falcosecurity/community.
/close

@poiana poiana closed this Oct 30, 2021
@poiana
Copy link
Contributor

poiana commented Oct 30, 2021

@poiana: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue with /reopen.

Mark the issue as fresh with /remove-lifecycle rotten.

Provide feedback via https://github.com/falcosecurity/community.
/close

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.

@leogr
Copy link
Member

leogr commented Oct 30, 2021

/reopen
/remove-lifecycle rotten

@poiana poiana reopened this Oct 30, 2021
@poiana
Copy link
Contributor

poiana commented Oct 30, 2021

@leogr: Reopened this PR.

In response to this:

/reopen
/remove-lifecycle rotten

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.

userspace/libscap/scap.c Show resolved Hide resolved
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.

Just some thoughts about naming (see my comments below).

I also have the same question @FedeDP wrote in this comment 👇
#39 (review)

Otherwise, SGTM 👏

userspace/libscap/scap.c Show resolved Hide resolved
userspace/libscap/scap.c Show resolved Hide resolved
userspace/libscap/scap.c Show resolved Hide resolved
@gnosek gnosek force-pushed the api-semver branch 2 times, most recently from 4f903f7 to 22e9d39 Compare February 2, 2022 13:37
@gnosek
Copy link
Contributor Author

gnosek commented Feb 2, 2022

@leogr, honestly I'd rather not introduce the new naming here, even in new APIs. I'm all for a subsequent PR that renames everything at once that we merge soon after (nobody should start depending on the *probe* functions/methods in the meantime and we won't end up with a halfway-done rename)

I'm open to discussion if you have strong opinions about it though

@leogr
Copy link
Member

leogr commented Feb 2, 2022

@leogr, honestly I'd rather not introduce the new naming here, even in new APIs. I'm all for a subsequent PR that renames everything at once that we merge soon after (nobody should start depending on the *probe* functions/methods in the meantime and we won't end up with a halfway-done rename)

I'm open to discussion if you have strong opinions about it though

👍 agreed. If you want, I can make the PR for the renaming once this gets merged.

@gnosek gnosek force-pushed the api-semver branch 2 times, most recently from 2ef3ea4 to 8d70834 Compare February 2, 2022 14:10
FedeDP
FedeDP previously approved these changes Feb 2, 2022
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.

LGTM!
/approve

@poiana poiana added the lgtm label Feb 2, 2022
@poiana
Copy link
Contributor

poiana commented Feb 2, 2022

LGTM label has been added.

Git tree hash: 34e54e57f0ecd42927fea2ff9a641ca9e37deb21

This allows reusing eBPF probes across different consumers
(and consumer versions) as long as the API is compatible.

It also adds validation of API versions in the non-eBPF
kernel probes, which was a long-standing omission. Since
the actual interface evolved slowly, it generally worked fine,
but in some rare cases it could easily end up with a kernel
panic.

Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
If fcntl(F_SETFD, FD_CLOEXEC) failed in scap_open_live_int,
we returned from the function with the fd still open
(scap_close only closes the fds which have a mmapped buffer
attached).

Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
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

This feature is a huge step forward for this project.
@gnosek huge thank you! 🙏

@poiana poiana added the lgtm label Feb 2, 2022
@poiana
Copy link
Contributor

poiana commented Feb 2, 2022

LGTM label has been added.

Git tree hash: 45a54ab12ef309a57c2e89db359be5e2fead9168

@poiana
Copy link
Contributor

poiana commented Feb 2, 2022

[APPROVALNOTIFIER] This PR is APPROVED

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

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