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

wip: fix: PT_FD, PT_ERRNO, PT_PID, PT_FDLIST with int32 #526

Closed
wants to merge 6 commits into from

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Aug 2, 2022

What type of PR is this?

/kind cleanup

Any specific area of the project related to this PR?

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

/area API-version

/area build

/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-udig

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

This will probably need a maj schema bump.

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?:

cleanup: send fd, errno, pid and fdlist as int32 from drivers to userspace

FedeDP added 3 commits August 2, 2022 08:46
…LIST32 field types.

This commit addresses userspace side.

Signed-off-by: Federico Di Pierro <[email protected]>
@poiana
Copy link
Contributor

poiana commented Aug 2, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@FedeDP
Copy link
Contributor Author

FedeDP commented Aug 2, 2022

Missing:

@FedeDP
Copy link
Contributor Author

FedeDP commented Aug 2, 2022

This should fix first 2 points of #515 !

FedeDP added 3 commits August 2, 2022 10:52
…T32, PT_ERRNO32 types.

I kept backward compatibility with existing dynamic params too.

Signed-off-by: Federico Di Pierro <[email protected]>
@FedeDP FedeDP force-pushed the fix/fd_errno_pid_fdlist_int32 branch from b2c7c07 to a5ab505 Compare August 2, 2022 08:52
@Andreagit97
Copy link
Member

/retest

/* PPME_SYSCALL_READ_X */{"read", EC_IO_READ, EF_USES_FD | EF_READS_FROM_FD | EF_DROP_SIMPLE_CONS, 2, {{"res", PT_ERRNO, PF_DEC}, {"data", PT_BYTEBUF, PF_NA} } },
/* PPME_SYSCALL_WRITE_E */{"write", EC_IO_WRITE, EF_USES_FD | EF_WRITES_TO_FD | EF_DROP_SIMPLE_CONS, 2, {{"fd", PT_FD, PF_DEC}, {"size", PT_UINT32, PF_DEC} } },
/* PPME_SYSCALL_WRITE_X */{"write", EC_IO_WRITE, EF_USES_FD | EF_WRITES_TO_FD | EF_DROP_SIMPLE_CONS, 2, {{"res", PT_ERRNO, PF_DEC}, {"data", PT_BYTEBUF, PF_NA} } },
/* PPME_SYSCALL_OPEN_X */{"open", EC_FILE, EF_CREATES_FD | EF_MODIFIES_STATE, 6, {{"fd", PT_FD32, PF_DEC}, {"name", PT_FSPATH, PF_NA}, {"flags", PT_FLAGS32, PF_HEX, file_flags}, {"mode", PT_UINT32, PF_OCT}, {"dev", PT_UINT32, PF_HEX}, {"ino", PT_UINT64, PF_DEC} } },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should indeed create new events alltogether, instead of updating parameters types, to retain backward compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's going to be a lot of fun when reading captures. Parameter length checks every other line ;)

@FedeDP
Copy link
Contributor Author

FedeDP commented Sep 27, 2022

Another possible solution, discussed with @Andreagit97 , is to add a new event flag, like EF_USE_SMALL_SIZE (ok, better naming perhaps ahha).
When an event is flagged with it, libs should expect that driver pushes a 32b integers for errno, pid,... but stores them in a 64bit (to retain backward compatibility with current behavior); moreover, when reading an old scap file, the flag won't be present, so the old behavior would still be enforced and everything should work fine.

@FedeDP
Copy link
Contributor Author

FedeDP commented Oct 4, 2022

I will rebase this one (or better say rewrite from scratch basically 🤣 ) once #596 , #649 and #582 are (hopefully)merged, to avoid huge conflicts.

@LucaGuerra
Copy link
Contributor

I took another look at this, I have some remarks that could be useful when you refactor/rewrite/rebase this PR:

I'm fine with FDs but keep in mind that if we want to create versions of events with a 32-bit PID/TID (for clone, fork, execve for example) we'll have to still maintain 64 bit versions since we can now rely on them (we do in gVisor). So, you can't deprecate or mark as "old" or "backwards compatibility" the 64 bit event but they'll be two different current events which could make the whole thing a bit more complicated.

Since the events that use PIDs are not a lot and not so frequent, except maybe for switch, I would advise to change them only if there is a real big impact on performance. I understand that there is such improvement with FDs but I'm not that convinced about PIDs.

@FedeDP
Copy link
Contributor Author

FedeDP commented Dec 1, 2022

/milestone 0.11.0

@poiana poiana added this to the 0.11.0 milestone Dec 1, 2022
@poiana
Copy link
Contributor

poiana commented Mar 2, 2023

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

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 2, 2023

/remove-lifecycle stale

I keep this open for reference, but most probably the patch will need to be entirely rewritten ;)

@FedeDP
Copy link
Contributor Author

FedeDP commented Apr 5, 2023

/milestone 0.12.0

@poiana poiana modified the milestones: 0.11.0, 0.12.0 Apr 5, 2023
@leogr leogr modified the milestones: 0.12.0, 0.13.0 May 3, 2023
@leogr leogr modified the milestones: 0.13.0, 0.12.0 May 10, 2023
@Andreagit97 Andreagit97 modified the milestones: 0.12.0, libs-backlog Jun 7, 2023
@incertum
Copy link
Contributor

@FedeDP it turns out for loginuid the casting to s32 is causing trouble. Real-world production systems do have audit uids larger than that. Dilemma arises from official definitions being somehow both u32 or s32 and folks typically like -1 for invalid values.

Therefore wanted to ask you if we could revive this PR and create the new events throughout and then for the new execve* events I can push onto this branch with changes to support loginuid changes, see staging commit incertum@b171a24

we can go with u32 and re-convert -1 in userspace or we just throughout go with s64, either way fine by me as long as it fixes wrongly casted uids. We definitely need to keep -1 ...

@gnosek
Copy link
Contributor

gnosek commented Jun 28, 2023

FWIW, in the kernel uids are unsigned 32 bit (on x86-64 at least): https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/posix_types.h#L49 so using s64 is IMHO wrong precisely because it introduces a difference between (2 << 32) - 1 and -1

@incertum
Copy link
Contributor

FWIW, in the kernel uids are unsigned 32 bit (on x86-64 at least): https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/posix_types.h#L49 so using s64 is IMHO wrong precisely because it introduces a difference between (2 << 32) - 1 and -1

oh thanks @gnosek 🙏 meaning we can only go the route u32, how would you still ensure we expose -1 in userspace as we currently do?

@poiana
Copy link
Contributor

poiana commented Sep 26, 2023

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

@Andreagit97
Copy link
Member

maybe we could also close this, not sure we will tackle this in the short term

@FedeDP
Copy link
Contributor Author

FedeDP commented Sep 27, 2023

I will leave this open just to remind me that sooner or later this should be tackled :D
/remove-lifecycle stale

@incertum
Copy link
Contributor

I will leave this open just to remind me that sooner or later this should be tackled :D

@FedeDP more concrete plans? 🙃 ty!

@Andreagit97
Copy link
Member

In my opinion we can close this one 🤔

@FedeDP
Copy link
Contributor Author

FedeDP commented Nov 13, 2023

Yep this needs to be re-done from scratch.
/close

@poiana poiana closed this Nov 13, 2023
@poiana
Copy link
Contributor

poiana commented Nov 13, 2023

@FedeDP: Closed this PR.

In response to this:

Yep this needs to be re-done from scratch.
/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.

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.

7 participants