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

Also copy ruleset when copying falco source #2271

Merged
merged 1 commit into from
Dec 1, 2022
Merged

Conversation

mstemm
Copy link
Contributor

@mstemm mstemm commented Oct 24, 2022

In the copy constructor and assignment operator for falco_source, also copy the ruleset along with factories/name.

Signed-off-by: Mark Stemm [email protected]

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

/kind release

If contributing rules or changes to rules, please make sure to also uncomment one of the following line:

/kind rule-update

/kind rule-create

Any specific area of the project related to this PR?

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

/area build

/area engine

/area rules

/area tests

/area proposals

/area CI

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Ensure that a ruleset object is copied properly in falco_engine::add_source().

In the copy constructor and assignment operator for falco_source, also
copy the ruleset along with factories/name.

Signed-off-by: Mark Stemm <[email protected]>
@mstemm
Copy link
Contributor Author

mstemm commented Oct 24, 2022

@jasondellaluce -- I noticed a crash in falco_engine::complete_rule_loading (https://github.com/falcosecurity/falco/blob/master/userspace/engine/falco_engine.cpp#L544) when loading rules files and tracked it down to this bug.

I'm confused on how rules loading would work without this fix though. Seems like the (NULL) ruleset would be dereferenced all the time, wouldn't it?

@mstemm
Copy link
Contributor Author

mstemm commented Oct 24, 2022

I understand why falco itself is okay, the ruleset for the source is created from the factory in load_rules(): https://github.com/falcosecurity/falco/blob/master/userspace/engine/falco_engine.cpp#L194. A ruleset for the source is also created in add_source: https://github.com/falcosecurity/falco/blob/master/userspace/engine/falco_engine.cpp#L406, but that one is not copied properly.

I think this crash can only occur if you call complete_rule_loading without ever calling load_rules(). So not a real problem, but would still be a good corner case to fix.

@jasondellaluce
Copy link
Contributor

/milestone 0.34.0

@poiana poiana added this to the 0.34.0 milestone Nov 4, 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.

/approve

@poiana
Copy link
Contributor

poiana commented Dec 1, 2022

LGTM label has been added.

Git tree hash: 16b859fa2bf399788877da8c0dd76bf15d349eec

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 Dec 1, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, jasondellaluce, 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 [FedeDP,jasondellaluce,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 356a4a0 into master Dec 1, 2022
@poiana poiana deleted the fix-falco-source-copy branch December 1, 2022 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants