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

feature(proctree): Introduce a process tree #3364

Merged
merged 31 commits into from Sep 18, 2023

Conversation

rafaeldtinoco
Copy link
Contributor

@rafaeldtinoco rafaeldtinoco commented Aug 5, 2023

This set of commits introduce the Process Tree feature to tracee.

1cd7123 debug(proctree): remove debug information
25c7c0e chore(time): centralize timing functions
30abbef chore(changelog): change values if given timestamp exists
16cd971 debug(proctree): split evictions from procs and threads
9482357 chore(proctree): move anon procfs functions to real ones
b89b97b chore(proctree): turn async procfs channel writes non blocking
b37197c feature(proctree): create config setting for proctree cache size
d7cf7e8 feature(proctree): enable async procfs updates to proctree
e3ae4a4 feature(proctree): add changelog support to fileinfo
ab5e285 feature(proctree): add name to processes and threads
45e337d debug(proctree): display proctree cache status in debug mode
bc5b89e chore(proctree): do not update parent and leader when they exist
4297538 chore(proctree) adjust the place for process tree initialization
f08de61 feature(proctree): read single PID from procfs
ce564bb chore(controlplane): comment how to debug proctree
4928826 chore(controlplane): rename containers file and eventID var
8f06bbe feature(proctree): start the process tree data structure
8bef843 feature(changelog): introduce the changelog package
e06e284 feature(utils/proc): add stat and status file parsing
80df989 chore(controlplane): rename local variable to ctrl
d7cb57c feature(controller): create processes lifecycle functions
f5e6b5b chore(parse): tell argument type on argument parsing errors
9aca78c chore(ebpf): move functions with inline asm
55a782e feature(controlplane): create signal events to be used by controlplane
0e2de67 feature(events): task unique identifier murmur hashing
126c929 chore(types): update to latest containing entityID

Missing features:

  • Processing Events to update Process Tree
  • Datasource for Process Tree
  • Signature example using process tree

All those being worked at: #3468

@rafaeldtinoco rafaeldtinoco changed the title Newproctreefull [DRAFT] playing around process tree Aug 5, 2023
types/trace/trace.go Outdated Show resolved Hide resolved
@NDStrahilevitz NDStrahilevitz self-requested a review August 6, 2023 06:05
Copy link
Collaborator

@NDStrahilevitz NDStrahilevitz left a comment

Choose a reason for hiding this comment

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

Nice work!
There are some key questions for the the control plane in this, hopefully i've laid out my concerns clearly enough.

pkg/ebpf/c/tracee.bpf.c Outdated Show resolved Hide resolved
pkg/ebpf/c/tracee.bpf.c Outdated Show resolved Hide resolved
pkg/ebpf/c/types.h Outdated Show resolved Hide resolved
pkg/ebpf/c/tracee.bpf.c Outdated Show resolved Hide resolved
pkg/ebpf/c/tracee.bpf.c Outdated Show resolved Hide resolved
pkg/proctree/nodes/process.go Outdated Show resolved Hide resolved
pkg/proctree/proctree.go Outdated Show resolved Hide resolved
pkg/proctree/tree/tree.go Outdated Show resolved Hide resolved
pkg/proctree/tree/tree.go Outdated Show resolved Hide resolved
types/trace/trace.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@AlonZivony AlonZivony left a comment

Choose a reason for hiding this comment

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

I haven't finished going over all of the PR, but I have the following general comments:

  1. This PR is a merge of 3 different concepts - control plane signals, user-mode process tree and procfs initialization. Each of them is independent, and I think would be better to be his unique PR (though maybe the control plane and process tree division now will be hard, so its your choice).
  2. From what I have seen (and I might be wrong) you only have threads in the tree. I think it will be hard to get interesting information about threads and processes this way. I will read it more deeply when I will review the rest of the code.
  3. I like the idea of exporting the responsibility of parsing the events from the tree. It looks much cleaner.
  4. I am a bit afraid that we use 3rd party for uesr-mode hashing but our for the eBPF hashing. We should think how to avoid the 3rd party changes creating inconsistency in the code.
  5. The whole control plane events should have much more designing, as the current design has a lot of issues that arose here.
  6. I don't think we can merge it till all the memory is capped, but I guess you didn't plan to as well :).

Nice work overall

types/trace/trace.go Outdated Show resolved Hide resolved
pkg/ebpf/c/tracee.bpf.c Outdated Show resolved Hide resolved
pkg/ebpf/controlplane/controller.go Outdated Show resolved Hide resolved
pkg/events/core.go Outdated Show resolved Hide resolved
pkg/proctree/nodes/process.go Outdated Show resolved Hide resolved
pkg/proctree/nodes/process.go Outdated Show resolved Hide resolved
pkg/proctree/nodes/process.go Outdated Show resolved Hide resolved
pkg/proctree/nodes/process.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@AlonZivony AlonZivony left a comment

Choose a reason for hiding this comment

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

Finished reviewing all the code, but might add some comments about the code as a whole in the future.

pkg/proctree/tree/tree.go Outdated Show resolved Hide resolved
pkg/proctree/tree/tree.go Outdated Show resolved Hide resolved
pkg/utils/procfs/procfs.go Outdated Show resolved Hide resolved
pkg/utils/procfs/procfs.go Outdated Show resolved Hide resolved
pkg/proctree/nodes/process.go Outdated Show resolved Hide resolved
pkg/bufferdecoder/decoder.go Outdated Show resolved Hide resolved
pkg/ebpf/c/common/buffer.h Outdated Show resolved Hide resolved
pkg/bufferdecoder/protocol.go Outdated Show resolved Hide resolved
pkg/ebpf/c/common/hash.h Outdated Show resolved Hide resolved
pkg/ebpf/c/common/task.h Outdated Show resolved Hide resolved
pkg/proctree/tree/tree.go Outdated Show resolved Hide resolved
pkg/utils/hash.go Outdated Show resolved Hide resolved
pkg/utils/procfs/procfs.go Outdated Show resolved Hide resolved
types/trace/trace.go Outdated Show resolved Hide resolved
types/trace/trace.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

@rafaeldtinoco rafaeldtinoco left a comment

Choose a reason for hiding this comment

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

Leaving comments

Copy link
Collaborator

@AlonZivony AlonZivony left a comment

Choose a reason for hiding this comment

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

Commenting in the conversations

pkg/utils/procfs/procfs.go Outdated Show resolved Hide resolved
pkg/proctree/tree/tree.go Outdated Show resolved Hide resolved
pkg/proctree/tree/tree.go Outdated Show resolved Hide resolved
pkg/proctree/proctree.go Outdated Show resolved Hide resolved
pkg/ebpf/tracee.go Outdated Show resolved Hide resolved
pkg/ebpf/events_pipeline.go Outdated Show resolved Hide resolved
pkg/ebpf/c/types.h Outdated Show resolved Hide resolved
@rafaeldtinoco rafaeldtinoco force-pushed the newproctreefull branch 2 times, most recently from 4abf20d to 2a3d852 Compare August 29, 2023 13:33
@github-actions github-actions bot removed the area/UX label Aug 29, 2023
@rafaeldtinoco rafaeldtinoco marked this pull request as ready for review August 29, 2023 17:03
- Also: avoid duplicate entries in changelog
- improve proctree boottime calculation
- use same function for tracee singleton starttime calculation
It is hard to debug the process tree. This commit removes the debug
messages used during process tree development. The reason why there is a
commit for this is because one might want to revert this commit in order
to debug a new issue found until process tree is considered stable.
... at least until it is fully implemented, tested and stable.
- add debug message when same timestamp gets 2 diff values
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.

Process Tree: Create a process tree fed by events that works as a datasource
5 participants