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

add kprobe read/write e2e test #3374

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

Conversation

sat0ken
Copy link

@sat0ken sat0ken commented Feb 7, 2025

Fixes #230

Description

I wrote test code use e2e test framework about kprobe/kretprobe test (read/write a file).

@sat0ken sat0ken requested a review from a team as a code owner February 7, 2025 12:06
@sat0ken sat0ken requested a review from olsajiri February 7, 2025 12:06
@olsajiri
Copy link
Contributor

olsajiri commented Feb 7, 2025

cc @will-isovalent @kkourt

@kkourt kkourt self-requested a review February 7, 2025 16:43
Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Please find some comments below.

On a more generic note, I'm ambivalent if adding this test covers some gap in our testing. On the one hand, we do not have kprobe e2e tests, but on the other hand, kprobes (and tracepoints) are extensively tested in unit tests, which are, generally speaking, faster and more reliable. I would like to hear @will-isovalent and other folks' opinions on this.

// Copyright Authors of Tetragon

// This package contains a simple test skeleton that can be copied, pasted, and modified
// to create new Tetragon e2e tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is probably from the skeleton test, so maybe it's worth removing it.

Copy link
Author

Choose a reason for hiding this comment

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

fixed this

2d78430

- index: 0
type: "int"
- index: 1
type: "char_buf"
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading the buffer from the user-space buffer is generally an unsafe pattern. There is no issue for the test, but I don't know if adding this anti-pattern to our code is a good idea.

We also don't seem to validate the buffer so maybe it would maybe sense to remove this argument?

Copy link
Author

Choose a reason for hiding this comment

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

I removed args.

6c1044d

type: "int"
- index: 1
type: "char_buf"
sizeArgIndex: 3
Copy link
Contributor

Choose a reason for hiding this comment

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

similar here.

Copy link
Author

Choose a reason for hiding this comment

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

I removed args.

6c1044d

followForks: true
isNamespacePID: true
values:
- 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the matchPIDs filter needed?

Copy link
Author

Choose a reason for hiding this comment

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

I pasted from example write.yaml.
I removed it.

6c1044d

}
if ev.GetFunctionName() == "__x64_sys_read" && ev.GetProcess().GetBinary() == "cat" {
k.matches++
}
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing to note is that the cat or echo implementations might change to use other system calls.

Copy link
Author

Choose a reason for hiding this comment

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

cat and echo moved to variables.

3de0f92

}

func (k *kprobeCheker) FinalCheck(logger *logrus.Logger) error {
if k.matches > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we check == 2 or at least >= 2 here?

Copy link
Author

Choose a reason for hiding this comment

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

fixed this

9dadd59

@kkourt kkourt added the release-note/ci This PR makes changes to the CI. label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/ci This PR makes changes to the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests/e2e: write some end-to-end tests with the new e2e-framework
3 participants