-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
kprobe+eBPF tracing as an event source #5218
Comments
- Platform dependent `perf_event_open` and `bpf` syscalls definitions - `isSupportedBySystem` function definition to determine if current system supports required eBPF features Issue: osquery#5218
Summary: eBPF system call osquery wrapper with Expected as a return value and function to check if functionality is supported by current kernel. Blueprint: [osquery#5218](osquery#5218) Reviewed By: mkareta Differential Revision: D13607442 fbshipit-source-id: 33103c704f760e569f21a6b322d7358d61cfbd55
Summary: C++ wrapper to load and keep track of eBPF program in order to close if afterwards. Blueprint: [osquery#5218](osquery#5218) Reviewed By: guliashvili Differential Revision: D13609628 fbshipit-source-id: 59a7ac3669018087cf15029ddb43a0786f75fc51
Summary: To make the process of interacting with eBPF map structure more clear Blueprint: [osquery#5218](osquery#5218) Reviewed By: guliashvili Differential Revision: D13608479 fbshipit-source-id: d31d2c4e277ea9f37b41246a1a5176c98098957d
) Summary: Pull Request resolved: osquery#5354 eBPF system call osquery wrapper with Expected as a return value and function to check if functionality is supported by current kernel. Blueprint: [osquery#5218](osquery#5218) Reviewed By: mkareta Differential Revision: D13607442 fbshipit-source-id: 270a2f7c51c2cb8d6c3ecc6fd070b4a173093656
Summary: Pull Request resolved: osquery#5355 C++ wrapper to load and keep track of eBPF program in order to close if afterwards. Blueprint: [osquery#5218](osquery#5218) Reviewed By: guliashvili Differential Revision: D13609628 fbshipit-source-id: 536d908da8f9a55961aee4e04864d2c1da704f3d
Summary: Pull Request resolved: osquery#5356 To make the process of interacting with eBPF map structure more clear Blueprint: [osquery#5218](osquery#5218) Reviewed By: guliashvili Differential Revision: D13608479 fbshipit-source-id: 03a1d5b0fd8f254ddd4cd0644e4672d4e53cc309
Implementation details of eBPF based event collection from linux kernelThe good new is the osquery lockdown is almost over, therefore I resume work on the new event source for the osquery on Linux. This is short term plan to have it done. Feel free to comment it or ask a questions. And also to comment coming PRs about topic. Definitions:
On Linux since v4 we have direct access to the class of native tracing events in order to collect them in userspace. There is a set of Linux tracing event (see To parse event and retrieve some context like PID, UID of the process caused the event eBPF program can be attached to the event by Linux performance monitoring mechanism ( For now, the main goal is to track syscalls from the kernel. We gonna start with This event is gonna be yet another event producer in new event framework from @fmanco. |
Summary: Pull Request resolved: #5354 eBPF system call osquery wrapper with Expected as a return value and function to check if functionality is supported by current kernel. Blueprint: [#5218](#5218) Reviewed By: mkareta Differential Revision: D13607442 fbshipit-source-id: 58be84a86aba3fe5e33ca5ab15418976fd36107c
Summary: Handler to enable event with certain type, get an id of the event and make sure it will be disables afterwards. Part of a linux `syscalls` tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: mkareta Differential Revision: D13621388 fbshipit-source-id: c22c67e29a0edb2ba368e68ce3c41488835fc97f
Summary: Pull Request resolved: #5370 Handler to enable event with certain type, get an id of the event and make sure it will be disables afterwards. Part of a linux `syscalls` tracing system, blueprint: [#5218](#5218) Reviewed By: mkareta Differential Revision: D13621388 fbshipit-source-id: 8adfbe3cc1d87f70538851c5036eae51c93bede8
Summary: Part of a linux `syscalls` tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: mkareta Differential Revision: D13622579 fbshipit-source-id: 43e6f3c9b6e43882d817799b6a43390d10862e83
…vent Summary: Part of a linux `syscalls` tracing system, blueprint: [osquery#5218](osquery#5218) Differential Revision: D13622999 fbshipit-source-id: 8bb9d11dce9bbd71100a8a4f15797d7a69957c71
…vent Summary: Part of a linux `syscalls` tracing system, blueprint: [osquery#5218](osquery#5218) Differential Revision: D13622999 fbshipit-source-id: 1e673cd7bafcd7d77b1bfe35866c05a379f4d5b0
Summary: Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Differential Revision: D13654124 fbshipit-source-id: c1f2b9fe6059f1bcb7f6d48b89e162974460a3ea
Summary: Pull Request resolved: osquery#5356 To make the process of interacting with eBPF map structure more clear Blueprint: [osquery#5218](osquery#5218) Reviewed By: guliashvili Differential Revision: D13608479 fbshipit-source-id: cffe76883c280a947da12641b7db6824a571ab1e
Summary: Pull Request resolved: osquery#5355 C++ wrapper to load and keep track of eBPF program in order to close if afterwards. Blueprint: [osquery#5218](osquery#5218) Reviewed By: guliashvili Differential Revision: D13609628 fbshipit-source-id: dd4ecb547a37c7d83753249e156b0d2c56194ec0
Summary: Pull Request resolved: osquery#5370 Handler to enable event with certain type, get an id of the event and make sure it will be disables afterwards. Part of a linux `syscalls` tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: mkareta Differential Revision: D13621388 fbshipit-source-id: 8adfbe3cc1d87f70538851c5036eae51c93bede8
Summary: Pull Request resolved: osquery#5374 Part of a linux `syscalls` tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: mkareta Differential Revision: D13622579 fbshipit-source-id: d88b49d785e532b0dbcc42d9245bfee2a9209145
…vent (osquery#5384) Summary: Pull Request resolved: osquery#5384 Part of a linux `syscalls` tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: guliashvili Differential Revision: D13622999 fbshipit-source-id: 905bbb3a3763fdd6fbe2ba5211f091184275f246
Summary: Pull Request resolved: osquery#5386 Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13654124 fbshipit-source-id: 8db63e584bd772132c1ba1c80853c60613e8036a
Summary: Pull Request resolved: osquery#5403 Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13690684 fbshipit-source-id: 039fc89929de49fcc7bd2287a98ffc68450fcada
Summary: Pull Request resolved: osquery#5403 Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13690684 fbshipit-source-id: 039fc89929de49fcc7bd2287a98ffc68450fcada
Summary: Pull Request resolved: osquery#5403 Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13690684 fbshipit-source-id: 039fc89929de49fcc7bd2287a98ffc68450fcada
Summary: Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13669863 fbshipit-source-id: ca07e625d3a5a64effb227dcdf583aad7b98560f
Summary: Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Differential Revision: D13669863 fbshipit-source-id: e6b400c258616edf8da725cf5c398556af660810
Summary: To able to invert type from enter to exit and determine if type is exit or enter. Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13761673 fbshipit-source-id: 88920888dc2fb7cf050b1141480752aded692676
…5416) Summary: Pull Request resolved: #5416 To able to invert type from enter to exit and determine if type is exit or enter. Part of a linux tracing system, blueprint: [#5218](#5218) Reviewed By: SAlexandru Differential Revision: D13761673 fbshipit-source-id: 2bf668219fd996d9d5b67e0e1ccf5c1161a41481
Summary: Hash multimap based joiner with ability to perform clean up old unpaired events from time to time. Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13761675 fbshipit-source-id: 8be920f2059ead508c5530a4f427db130b7e826c
Summary: Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13787759 fbshipit-source-id: 726075e04474b4148c0292d6e9e8f10cf60b9214
Summary: Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Differential Revision: D13787759 fbshipit-source-id: 2758f4fb385d65c2d85d8bae96b0e69531b620ae
Summary: Pull Request resolved: #5417 Hash multimap based joiner with ability to perform clean up old unpaired events from time to time. Part of a linux tracing system, blueprint: [#5218](#5218) Reviewed By: SAlexandru Differential Revision: D13761675 fbshipit-source-id: f4b17cbeed495b2a9e6616a005f001963849875e
…class Summary: This is a final diff to be able to track syscalls by using eBPF + kernel events. Basically that one and previous are about to join high level initialisation routine in one place. Part of a linux tracing system, blueprint: [osquery#5218](osquery#5218) Reviewed By: SAlexandru Differential Revision: D13801093 fbshipit-source-id: d9f09aabe0055aa43c44fb57ad9cd9b3952da4f8
…class (#5428) Summary: Pull Request resolved: #5428 This is a final diff to be able to track syscalls by using eBPF + kernel events. Basically that one and previous are about to join high level initialisation routine in one place. Part of a linux tracing system, blueprint: [#5218](#5218) Reviewed By: SAlexandru Differential Revision: D13801093 fbshipit-source-id: db8503b0d42127281a975ff517600872e9ed4302
Related: #6571 |
Closing because we have retired this approach in Remove unused/experimental ebpf code in favor of the ebpfpub library approach and Alessandro's BPF-based socket and process events tables (#6571) that were released in 4.6.0. |
Blueprint
To extend the type of information receiving from systems I'd like to propose the new way to get information about system events on Linux.
Existing mechanism
osquery
already has event collection system for linux based on Linux Auditing System. It provides a lot of extremely useful information. Howeverauditd
has some well known limits by design.Restrictions of
auditd
The main constraint is a notable performance penalty. Audit information is received from the system via unix socket in text form. Which means kernel waste CPU resources to create those strings and filter them.
osquery
in it's turn has to parse them. Sounds ridiculous but in the scale of system events it has a big performance issue on high load systems.Suggested solution
The possible substitution could be to use
kprobes
/kretprobes
witheBPF
to fetch intended data in kernel mode. Withkprobe
we could watch and trace almost anysyscall
with arguments, return values and some contexts like PID and TID of the caller.Performance hit
I did the rough test to compare the system performance hit of considerable mechanisms: current osquery system event collection mechanism (aka
auditd
),kprobe
watching everyopen
syscall in the system. Both systems can trace the system callopen
, so I did a small binary which is open and close a file many times. Run it withauditd
and withkprobe
, also run it without anything to compare (etalon run).kprobe
auditd
Performance hit for
kprobe
is notable lower than forauditd
, thereby usingkprobe
can probably help us to reduce performance hit of system event recording mechanism.Implementation plan
eBPF
structures such as maps, progs, output points based on perf eventskprobe
managing code to connect it to eBPF programexecve
The text was updated successfully, but these errors were encountered: