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(libsinsp,test): remove undefined behavior in test event generation #969

Merged
merged 2 commits into from
Mar 13, 2023

Conversation

LucaGuerra
Copy link
Contributor

@LucaGuerra LucaGuerra commented Mar 13, 2023

What type of PR is this?

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

/kind bug

Any specific area of the project related to this PR?

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

/area libsinsp
/area tests

Does this PR require a change in the driver versions?

No.

What this PR does / why we need it:

This PR fixes a fun bug in the libsinsp test suite that is simply an instance of this: https://stackoverflow.com/questions/727663/why-does-this-variadic-function-fail-on-4th-parameter-on-windows-x64 .

Essentially, passing an integer literal to a variadic function and expecting a 64 bit value is undefined behavior, as the integer literal is type int and not the correct 64 bit size. We caught this on ARM64 after the 8th parameter due to that specific implementation and parameter passing via registers/stack but could happen anywhere.

The fix is simply to either cast the integer or pass a variable, which is what happens in this PR. When I felt it right I added some descriptive variable names so tests can still be easy to read.

We will need another similar PR everywhere we call the event encoding function (I believe in the gVisor implementation).

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Merging this PR unblocks this: #962 .

Does this PR introduce a user-facing change?:

NONE

@LucaGuerra
Copy link
Contributor Author

/milestone 0.11.0

@poiana poiana added this to the 0.11.0 milestone Mar 13, 2023
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.

Thanks @LucaGuerra also for sharing your debugging journey 😎

/approve

@poiana
Copy link
Contributor

poiana commented Mar 13, 2023

LGTM label has been added.

Git tree hash: 8ffeba4dbdce13525512670d90b2de4d56476d85

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 Mar 13, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, incertum, LucaGuerra

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,LucaGuerra,incertum]

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 88b94d8 into falcosecurity:master Mar 13, 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

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