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: fix crash in kprobe validation #1551

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/btf/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ func typesCompatible(specTy string, kernelTy string) bool {

func validateSycall(kspec *v1alpha1.KProbeSpec, name string) error {
if kspec.Return {
if kspec.ReturnArg == nil {
return fmt.Errorf("missing information for syscall %s: returnArg is missing", name)
}
if !typesCompatible(kspec.ReturnArg.Type, "long") {
return fmt.Errorf("unexpected syscall spec return type: %s", kspec.ReturnArg.Type)
}
Expand Down
19 changes: 19 additions & 0 deletions pkg/sensors/tracing/kprobe_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,22 @@ spec:
assert.Error(t, err)

}

func TestKprobeValidationMissingReturnArg(t *testing.T) {

// missing returnArg while having return: true

crd := `
apiVersion: cilium.io/v1alpha1
metadata:
name: "missing-returnarg"
spec:
kprobes:
- call: "sys_openat"
return: true
syscall: true
`

err := checkCrd(t, crd)
assert.Error(t, err)
}