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

Fix an infinite exec bug #595

Merged

Conversation

directionless
Copy link
Contributor

@directionless directionless commented Apr 2, 2020

The FindNewestSelf function calls FindNewest. Which, in turns, calls checkExecutable. Which launchers the binary. Which goes back to the beginning. This bug only manifests for launcher, but not for the osquery side. This isn't a fatal error, as there's a 5s timeout on it. But it is slow.

Add an option to skip the final check, solving this. And add comments.

Convert the finalizers over to using FindNewestSelf. First, because that's what it's there for. Second, because os.Executable() is more correct than os.Args[0]

The FindNewestSelf function calls FindNewest. Which, in turns, calls `checkExecutable`. Which launchers the binary. Which goes back to the beginning. This bug only manifests for `launcher`, but not for the `osquery` side. This isn't a fatal error, as there's a 5s timeout on it. But it is slow.

Add an option to skip the final check, solving this. And add comments.
@directionless directionless changed the title Fix an infinit exec bug Fix an infinite exec bug Apr 2, 2020
Copy link
Contributor

@blaedj blaedj left a comment

Choose a reason for hiding this comment

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

couple spelling nits, but I think this looks good.

This is probably just my lack of understanding, but I'm trying to figure out why we don't need to use this option in other calls to findNewest, e.g. updater-finalizer.go:29, since that passes os.Args[0] as the binary path - wouldn't that also be the path to the currently running binary?

cmd/launcher/main.go Outdated Show resolved Hide resolved
cmd/launcher/main.go Outdated Show resolved Hide resolved
Co-Authored-By: blaedj <blaedj@users.noreply.github.com>
@directionless
Copy link
Contributor Author

I'm trying to figure out why we don't need to use this option in other calls to findNewest, e.g. updater-finalizer.go:29

Good catch, I think that needs this option as well. Though I wonder why it's not using FindNewestSelf instead. I mean, I wrote the code...

directionless and others added 2 commits April 2, 2020 13:59
Co-Authored-By: blaedj <blaedj@users.noreply.github.com>
@directionless directionless merged commit ceb15c3 into kolide:master Apr 2, 2020
@directionless directionless deleted the seph/check-exec-recursion branch April 2, 2020 18:57
@directionless directionless mentioned this pull request Apr 13, 2020
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.

2 participants