-
Notifications
You must be signed in to change notification settings - Fork 380
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: Check the returned data length for exec arguments #211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olsajiri can we do similar bounds checking here? This could also panic if Index() returns -1 (which it can).
tetragon/pkg/sensors/exec/exec.go
Lines 113 to 116 in d6d4ade
} else { | |
n := bytes.Index(args, []byte{0x00}) | |
proc.Filename = string(args[:n]) | |
args = args[n+1:] |
And unit test would be great. |
It can actually happen that there will be no arguments or filename, in which case we need to check the data length and api.EventErrorFilename flag. Signed-off-by: Jiri Olsa <[email protected]>
this seems to happen when probe_read_str fails to read the filename, |
fwiw I managed to reproduce with:
and the change fixes the crash.. maybe we could have a way to instrument bpf program to trigger the error for some binary name and test that.. but that'd mean more changes |
👍 A simpler solution might be to add some unit tests on the go side for this. |
It can actually happen that there will be no arguments
or filename, in which case we need to check the data
length and api.EventErrorFilename flag.
Signed-off-by: Jiri Olsa [email protected]