-
Notifications
You must be signed in to change notification settings - Fork 323
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 missing parent issue in clone events #1708
Conversation
Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
c56bdf4
to
6cfc1b3
Compare
6cfc1b3
to
41ca507
Compare
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
cc6f6c5
to
f38b799
Compare
Clone events are handled in event_wake_up_new_task program. In the case of __event_find_parent failure, we do not send an event to the user. On the other hand, execve_map_get has already added a new entry in execve_map. This causes an inconsistency between execve_map and the user space process cache that may lead for events to go through the eventcache and waing of a process that never arrives. To solve this, we try to find our parent in the beginning of the program. If we fail to do so, we simply stop the execution of this program (and do not add any entries in the execve_map). This commit also does some refactoring to cleanup the code. Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
In Tetragon we do not report process_exec and process_exit events for kernel threads. When searching for the parent of a kernel thread, we failed to do so and we simply ignore that. This patch optimizes that path as we abort early by checking the task_struct's flags. Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
f38b799
to
05d0638
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* cannot find it's parent in the execve_map. | ||
*/ | ||
parent = __event_find_parent(task); | ||
if (!parent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have a counter for this! I'm curious if it will ever happen, when the second patch is also applied.
That being said, since we are not sending an event if we don't find the parent, there is no point in adding an entry to the map. So this patch makes sense to me as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have in mind to add a counter for that (and other cases in exec/exit events) to check if this happens in a follow-up PR.
Clone events are handled in the
event_wake_up_new_task
program. In the case of__event_find_parent
failure, we do not send an event to the user. On the other hand,execve_map_get
has already added a new entry inexecve_map
. This causes an inconsistency betweenexecve_map
and the user space process cache that may lead events to go through the event cache and wait for a process that never arrives.To solve this, we try to find our parent at the beginning of the program. If we fail to do so, we simply stop the execution of this program (and do not add any entries in the
execve_map
). This commit also does some refactoring to clean up the code.The last commit checks for kernel threads during clone events and avoid searching for parent early during the process.