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: avoid segfault of eventcache is disabled #243

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

jrfastab
Copy link
Contributor

Exec sensor missed check for execcache != nil and attempts to query the
execcache even though its a nil pointer.

To fix simply check ptr for nil. Perhaps we should hide these behind a
fake interface, but not sure its worth it really.

This fixes the following,

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x15835df]

goroutine 68 [running]:
testing.tRunner.func1.2({0x170cf40, 0x27c6850})
/usr/local/go/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:1392 +0x39f
panic({0x170cf40, 0x27c6850})
/usr/local/go/src/runtime/panic.go:838 +0x207
github.com/cilium/tetragon/pkg/eventcache.(*Cache).Add(...)
/home/john/go/src/github.com/cilium/tetragon/pkg/eventcache/eventcache.go:181
github.com/cilium/tetragon/pkg/grpc/exec.(*MsgExecveEventUnix).HandleMessage(0xc000239ad0)
/home/john/go/src/github.com/cilium/tetragon/pkg/grpc/exec/exec.go:79 +0x1ff
github.com/cilium/tetragon/pkg/grpc.(*ProcessManager).Notify(0xf?, {0x1bc9640, 0xc000239ad0})
/home/john/go/src/github.com/cilium/tetragon/pkg/grpc/process_manager.go:68 +0x2c
github.com/cilium/tetragon/pkg/observer.(*Observer).observerListeners(0xc000b0a240, {0x1bc9640, 0xc000239ad0})
/home/john/go/src/github.com/cilium/tetragon/pkg/observer/observer.go:64 +0xb3

Signed-off-by: John Fastabend [email protected]

Exec sensor missed check for execcache != nil and attempts to query the
execcache even though its a nil pointer.

To fix simply check ptr for nil. Perhaps we should hide these behind a
fake interface, but not sure its worth it really.

This fixes the following,

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x15835df]

goroutine 68 [running]:
testing.tRunner.func1.2({0x170cf40, 0x27c6850})
	/usr/local/go/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1392 +0x39f
panic({0x170cf40, 0x27c6850})
	/usr/local/go/src/runtime/panic.go:838 +0x207
github.com/cilium/tetragon/pkg/eventcache.(*Cache).Add(...)
	/home/john/go/src/github.com/cilium/tetragon/pkg/eventcache/eventcache.go:181
github.com/cilium/tetragon/pkg/grpc/exec.(*MsgExecveEventUnix).HandleMessage(0xc000239ad0)
	/home/john/go/src/github.com/cilium/tetragon/pkg/grpc/exec/exec.go:79 +0x1ff
github.com/cilium/tetragon/pkg/grpc.(*ProcessManager).Notify(0xf?, {0x1bc9640, 0xc000239ad0})
	/home/john/go/src/github.com/cilium/tetragon/pkg/grpc/process_manager.go:68 +0x2c
github.com/cilium/tetragon/pkg/observer.(*Observer).observerListeners(0xc000b0a240, {0x1bc9640, 0xc000239ad0})
	/home/john/go/src/github.com/cilium/tetragon/pkg/observer/observer.go:64 +0xb3

Signed-off-by: John Fastabend <[email protected]>
@jrfastab jrfastab requested a review from a team as a code owner July 18, 2022 05:44
@jrfastab jrfastab requested a review from tixxdz July 18, 2022 05:44
@jrfastab jrfastab merged commit aa1cdb6 into main Jul 18, 2022
@jrfastab jrfastab deleted the pr/jrfastab/fixSegfault branch July 18, 2022 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant