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

new(driver,sinsp): Add euid to execve/execveat exit events #391

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

gnosek
Copy link
Contributor

@gnosek gnosek commented Jun 10, 2022

We can't prevent losing setuid events completely and the uid
is pretty important for some execve-related rules, so explicitly
pass the uid in execve/at exit events

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-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 libsinsp

/area tests

/area proposals

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

NONE

@gnosek gnosek changed the title Add euid to execve/execveat exit events wip: Add euid to execve/execveat exit events Jun 10, 2022
@gnosek gnosek changed the title wip: Add euid to execve/execveat exit events Add euid to execve/execveat exit events Jun 20, 2022
@poiana
Copy link
Contributor

poiana commented Sep 18, 2022

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

/remove-lifecycle stale

@FedeDP
Copy link
Contributor

FedeDP commented Dec 2, 2022

/milestone 0.11.0

@poiana poiana added this to the 0.11.0 milestone Dec 2, 2022
@gnosek gnosek changed the title Add euid to execve/execveat exit events wip: Add euid to execve/execveat exit events Dec 5, 2022
@gnosek
Copy link
Contributor Author

gnosek commented Dec 5, 2022

Marking as wip since we need to handle modern_bpf as well

@gnosek gnosek force-pushed the execve-uid branch 4 times, most recently from 0fd5fe5 to 0f9a83d Compare December 7, 2022 19:14
driver/bpf/fillers.h Outdated Show resolved Hide resolved
driver/bpf/fillers.h Outdated Show resolved Hide resolved
driver/bpf/fillers.h Show resolved Hide resolved
driver/ppm_fillers.c Outdated Show resolved Hide resolved
driver/ppm_fillers.c Show resolved Hide resolved
@@ -2855,17 +2855,12 @@ FILLER(execve_family_flags, true)

/* Parameter 26: exe_file mtime (last modification time, epoch value in nanoseconds) (type: PT_ABSTIME) */
time = _READ(inode->i_mtime);
return bpf_val_to_ring_type(data, bpf_epoch_ns_from_time(time), PT_ABSTIME);
ret = bpf_val_to_ring_type(data, bpf_epoch_ns_from_time(time), PT_ABSTIME);
Copy link
Member

Choose a reason for hiding this comment

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

sorry my fault is res not ret

@gnosek
Copy link
Contributor Author

gnosek commented Feb 7, 2023

@incertum, @Andreagit97: I rebased the PR, care to take a look?

could we double-check this and cleanup if we don't support <2.6.20?

Looks like we still have <2.6.20 checks so I'd rather remove them all in a separate PR. I don't know if we actually run on <2.6.20 any more but I'd rather not break it on purpose in one place.

gnosek and others added 2 commits February 7, 2023 07:45
We can't prevent losing setuid events completely and the uid
is pretty important for some execve-related rules, so explicitly
pass the uid in execve/at exit events

Signed-off-by: Grzegorz Nosek <[email protected]>
Co-authored-by: Angelo Puglisi <[email protected]>
Co-authored-by: Andrea Terzolo <[email protected]>
@gnosek
Copy link
Contributor Author

gnosek commented Feb 7, 2023

/hold

@gnosek
Copy link
Contributor Author

gnosek commented Feb 7, 2023

Hmm just noticed that the PT_ABSTIME patch that went in in #789 was slightly different so we still have a commit here:

commit 841bd9fd4fb5850a913a38c53b5b0dd4f1e5f8e1
Author: Grzegorz Nosek <[email protected]>
Date:   Wed Dec 7 19:11:27 2022 +0100

    fix(sinsp): format PT_ABSTIME values

    Signed-off-by: Grzegorz Nosek <[email protected]>

diff --git a/userspace/libsinsp/event.cpp b/userspace/libsinsp/event.cpp
index 4dd490e92..69ed1110b 100644
--- a/userspace/libsinsp/event.cpp
+++ b/userspace/libsinsp/event.cpp
@@ -1425,7 +1425,6 @@ Json::Value sinsp_evt::get_param_as_json(uint32_t id, OUT const char** resolved_
                        break;
                }
        case PT_DYN:
-               ASSERT(false);
                snprintf(&m_paramstr_storage[0],
                         m_paramstr_storage.size(),
                         "INVALID DYNAMIC PARAMETER");

Do we want this? @Andreagit97 @incertum (probably with a better commit message if so)

@incertum
Copy link
Contributor

incertum commented Feb 7, 2023

@gnosek re above question we probably don't need this commit in this PR, ty.

@gnosek
Copy link
Contributor Author

gnosek commented Feb 7, 2023

Thanks @incertum, dropped the patch.

/unhold

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

@poiana
Copy link
Contributor

poiana commented Feb 7, 2023

LGTM label has been added.

Git tree hash: faa1e94d78b3537617e504bce3adc17083f54aa9

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

@FedeDP
Copy link
Contributor

FedeDP commented Feb 7, 2023

/hold

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 Feb 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, gnosek, hbrueckner, incertum

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,FedeDP,gnosek,incertum]

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

@Andreagit97
Copy link
Member

/unhold

@poiana poiana merged commit dae8bc2 into falcosecurity:master Feb 7, 2023
@gnosek gnosek deleted the execve-uid branch February 7, 2023 11:34
@greyhame-s greyhame-s mentioned this pull request Feb 10, 2023
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.

6 participants