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

tetra: avoid panic in the decoder #2116

Merged
merged 1 commit into from
Feb 19, 2024
Merged

Conversation

kkourt
Copy link
Contributor

@kkourt kkourt commented Feb 16, 2024

We seem to be accessing Args[1] without a proper check. Add the check to avoid the panic.

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/cilium/tetragon/pkg/encoder.(*CompactEncoder).EventToString(0xc0001e0ec0, 0xc000894240)
/home/kkourt/src/tetragon/pkg/encoder/encoder.go:413 +0x4438
github.com/cilium/tetragon/pkg/encoder.(*CompactEncoder).Encode(0xc0001e0ec0, {0x1c83480?, 0xc000894240})
/home/kkourt/src/tetragon/pkg/encoder/encoder.go:110 +0x9f
github.com/cilium/tetragon/cmd/tetra/getevents.getEvents({0x204cd20, 0xc000388840}, {0x205ba68, 0xc0007aec00})
/home/kkourt/src/tetragon/cmd/tetra/getevents/getevents.go:150 +0x4dd
github.com/cilium/tetragon/cmd/tetra/common.CliRunErr(0x1e4b3c8, 0x1e4b3c0)
/home/kkourt/src/tetragon/cmd/tetra/common/client.go:95 +0x68a
github.com/cilium/tetragon/cmd/tetra/common.CliRun(...)
/home/kkourt/src/tetragon/cmd/tetra/common/client.go:99
github.com/cilium/tetragon/cmd/tetra/getevents.New.func2(0xc0002e6a00?, {0x1d275fd?, 0x4?, 0x1d27601?})
/home/kkourt/src/tetragon/cmd/tetra/getevents/getevents.go:195 +0x108
github.com/spf13/cobra.(*Command).execute(0xc000193b08, {0xc0001e03a0, 0x2, 0x2})
/home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xc000193808)
/home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:1039
main.main()
/home/kkourt/src/tetragon/cmd/tetra/main.go:21 +0x18

We seem to be accessing Args[1] without a proper check. Add the check to
avoid the panic.

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/cilium/tetragon/pkg/encoder.(*CompactEncoder).EventToString(0xc0001e0ec0, 0xc000894240)
        /home/kkourt/src/tetragon/pkg/encoder/encoder.go:413 +0x4438
github.com/cilium/tetragon/pkg/encoder.(*CompactEncoder).Encode(0xc0001e0ec0, {0x1c83480?, 0xc000894240})
        /home/kkourt/src/tetragon/pkg/encoder/encoder.go:110 +0x9f
github.com/cilium/tetragon/cmd/tetra/getevents.getEvents({0x204cd20, 0xc000388840}, {0x205ba68, 0xc0007aec00})
        /home/kkourt/src/tetragon/cmd/tetra/getevents/getevents.go:150 +0x4dd
github.com/cilium/tetragon/cmd/tetra/common.CliRunErr(0x1e4b3c8, 0x1e4b3c0)
        /home/kkourt/src/tetragon/cmd/tetra/common/client.go:95 +0x68a
github.com/cilium/tetragon/cmd/tetra/common.CliRun(...)
        /home/kkourt/src/tetragon/cmd/tetra/common/client.go:99
github.com/cilium/tetragon/cmd/tetra/getevents.New.func2(0xc0002e6a00?, {0x1d275fd?, 0x4?, 0x1d27601?})
        /home/kkourt/src/tetragon/cmd/tetra/getevents/getevents.go:195 +0x108
github.com/spf13/cobra.(*Command).execute(0xc000193b08, {0xc0001e03a0, 0x2, 0x2})
        /home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xc000193808)
        /home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        /home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:1039
main.main()
        /home/kkourt/src/tetragon/cmd/tetra/main.go:21 +0x18

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
@kkourt kkourt requested a review from tpapagian February 16, 2024 13:11
@kkourt kkourt requested a review from a team as a code owner February 16, 2024 13:11
Copy link

netlify bot commented Feb 16, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit a1e37fd
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/65cf5f008e96bd0008d5dfcc
😎 Deploy Preview https://deploy-preview-2116--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.

Copy link
Member

@tpapagian tpapagian left a comment

Choose a reason for hiding this comment

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

LGTM!

@kkourt kkourt merged commit eaa5947 into main Feb 19, 2024
34 of 36 checks passed
@kkourt kkourt deleted the pr/kkourt/fim-decoder-fix-panic branch February 19, 2024 10:13
@kkourt kkourt added the release-note/bug This PR fixes an issue in a previous release of Tetragon. label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/bug This PR fixes an issue in a previous release of Tetragon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants