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

tetragon:api: support kprobes object #2206

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tixxdz
Copy link
Member

@tixxdz tixxdz commented Mar 10, 2024

No description provided.

This adds KernelKprobe object to trace operations on kprobe objects.

Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
@tixxdz tixxdz requested a review from a team as a code owner March 10, 2024 23:58
@tixxdz tixxdz requested a review from tpapagian March 10, 2024 23:58
@tixxdz tixxdz added the release-note/minor This PR introduces a minor user-visible change label Mar 10, 2024
Copy link

netlify bot commented Mar 10, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit f913510
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/65ee491effb7660009b1c38a
😎 Deploy Preview https://deploy-preview-2206--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tixxdz tixxdz force-pushed the pr/tixxdz/kprobe-tracing-v1 branch 2 times, most recently from b84eacc to 4f93357 Compare March 11, 2024 13:20
@tixxdz tixxdz force-pushed the pr/tixxdz/kprobe-tracing-v1 branch from 4f93357 to f34ad23 Compare March 11, 2024 13:23
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
@tixxdz tixxdz force-pushed the pr/tixxdz/kprobe-tracing-v1 branch from f34ad23 to d48081f Compare March 11, 2024 14:13
@dwindsor
Copy link
Collaborator

Is the intent of this feature to provide observability into kprobe loads by non-Tetragon users?

@tixxdz
Copy link
Member Author

tixxdz commented Mar 11, 2024

Is the intent of this feature to provide observability into kprobe loads by non-Tetragon users?

The feature is for our users! both load and unload of kprobes including bpf via kprobes.

@tixxdz
Copy link
Member Author

tixxdz commented Mar 11, 2024

Is the intent of this feature to provide observability into kprobe loads by non-Tetragon users?

ah got you: yes a catch all ;-)

Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

that's cool kprobes monitoring with kprobes

@@ -6580,3 +6581,249 @@ spec:
err = jsonchecker.JsonTestCheck(t, checker)
assert.NoError(t, err)
}

func getArmKprobeSymb(kSymbols *ksyms.Ksyms) string {
if kSymbols.IsAvailable("arm_kprobe") == true {
Copy link
Member

Choose a reason for hiding this comment

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

a nit but you don't need an extra comparison here, as with all the if and else if with bool == true.

Suggested change
if kSymbols.IsAvailable("arm_kprobe") == true {
if kSymbols.IsAvailable("arm_kprobe") {

#define KSYM_NAME_LEN 128U
#endif

struct msg_kprobe {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We also may want to capture flags here, as it contains some useful state info:

/* Kprobe status flags */
#define KPROBE_FLAG_GONE	1 /* breakpoint has already gone */
#define KPROBE_FLAG_DISABLED	2 /* probe is temporarily disabled */
#define KPROBE_FLAG_OPTIMIZED	4 /*
				   * probe is really optimized.
				   * NOTE:
				   * this flag is only for optimized_kprobe.
				   */
#define KPROBE_FLAG_FTRACE	8 /* probe is using ftrace */
#define KPROBE_FLAG_ON_FUNC_ENTRY	16 /* probe is on the function entry */

u64 addr;
u32 offset;
u32 pad;
char symbol[KSYM_NAME_LEN];
Copy link
Contributor

Choose a reason for hiding this comment

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

is it necessary to send the symbol? I'd think that the ksyms.KernelSymbols/kernelSymbols.GetFnOffset on user side that you already use should be fast enough

description: "Detects kprobes operations"
spec:
kprobes:
- call: ` + arm_kprobe + `
Copy link
Contributor

Choose a reason for hiding this comment

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

hum, so this should not work with kprobe multi, I'd think you need to add option like:

options:
- name: "disable-kprobe-multi"
  value: "1"

@olsajiri
Copy link
Contributor

not too much docs ;-) if the objective is to monitor kprobes/bpf-progs I think we should hook fprobe as well for kprobe multi probes

@kkourt kkourt added the needs-rebase This PR needs to be rebased because it has merge conflicts. label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase This PR needs to be rebased because it has merge conflicts. release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants