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

Add fcntl enter arguments to exit event #1304

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

mstemm
Copy link
Contributor

@mstemm mstemm commented Aug 22, 2023

For some filters on fcntl events, it's useful to have access to both the provided fd and cmd, which are parameters in the enter event, as well as the return value (e.g. the new fd, which is in the exit event).

So add the enter event fields to the exit event. This matches the pattern we already use for lots of other events. Fcntl is a pretty old event, so we weren't following that pattern then.

It's safe to add new fields to events to preserve backwards compatibility, but it's not safe to modify or reduce fields, so keep the parameters in the enter event.

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 API-version

/area build

/area CI

/area driver-kmod

/area driver-bpf

/area driver-modern-bpf

/area libscap-engine-bpf

/area libscap-engine-gvisor

/area libscap-engine-kmod

/area libscap-engine-modern-bpf

/area libscap-engine-nodriver

/area libscap-engine-noop

/area libscap-engine-source-plugin

/area libscap-engine-savefile

/area libscap-engine-udig

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

/version driver-API-version-major

/version driver-API-version-minor

/version driver-API-version-patch

/version driver-SCHEMA-version-major

/version driver-SCHEMA-version-minor

/version driver-SCHEMA-version-patch

What this PR does / why we need it:

Add fcntl arguments to the exit event so the arguments and return values can be compared at the same time.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Add fcntl arguments to the exit event so the arguments and return values can be compared at the same time.

@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Please double check driver/API_VERSION file. See versioning.

/hold

@mstemm
Copy link
Contributor Author

mstemm commented Aug 22, 2023

I'm not that familiar with the modern bpf driver, do I need to make changes to an additional location or does the modern bpf driver use the fillers in driver/bpf ?

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.

@mstemm thank you for this! The modern probe uses its dedicated fillers so you need to change also them, moreover, we have added tests on all fillers so now the tests on fcntl exit events are falling because the expect 1 parameter instead of 3.

  • you can find the modern bpf filler for fcntl here: driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/fcntl.bpf.c
  • you can find tests for fcntl here: test/drivers/test_suites/syscall_exit_suite/fcntl_x.cpp

Moreover, this PR could be a good example to see where to touch: https://github.com/falcosecurity/libs/pull/1270/files

driver/bpf/fillers.h Show resolved Hide resolved
@mstemm mstemm force-pushed the make-fcntl-args-available-in-exit-event branch 3 times, most recently from 6e587f3 to 75d15c2 Compare August 22, 2023 18:39
For some filters on fcntl events, it's useful to have access to both
the provided fd and cmd, which are parameters in the enter event, as
well as the return value (e.g. the new fd, which is in the exit
event).

So add the enter event fields to the exit event. This matches the
pattern we already use for lots of other events. Fcntl is a pretty old
event, so we weren't following that pattern then.

It's safe to add new fields to events to preserve backwards
compatibility, but it's not safe to modify or reduce fields, so keep
the parameters in the enter event.

Also bump the schema minor version, as this adds fields to an existing
event.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
@mstemm mstemm force-pushed the make-fcntl-args-available-in-exit-event branch from 75d15c2 to 063db0a Compare August 22, 2023 19:11
@mstemm
Copy link
Contributor Author

mstemm commented Aug 22, 2023

Ok, all the tests are passing now. PTAL again!

@leogr
Copy link
Member

leogr commented Aug 23, 2023

/milestone 0.13.0

@poiana poiana added this to the 0.13.0 milestone Aug 23, 2023
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 Aug 23, 2023

LGTM label has been added.

Git tree hash: a9c4e74eb586732b819d75963b8a8049531cdfcb

Copy link
Contributor

@incertum incertum left a comment

Choose a reason for hiding this comment

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

/approve

/unhold

@poiana
Copy link
Contributor

poiana commented Aug 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, incertum, mstemm

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 [Andreagit97,incertum,mstemm]

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 16d26ff into master Aug 25, 2023
30 checks passed
@poiana poiana deleted the make-fcntl-args-available-in-exit-event branch August 25, 2023 03: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.

5 participants