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

linux: Allocate stack for injector's remote calls #545

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

ajwerner
Copy link
Contributor

For some target programs it's not reasonable to assume that any hijacked thread has a large stack. For example, in Go, stacks are often small and are allocated on the heap. The injector bootstrap program uses kilobytes of stack. In order to side-step this problem, this patch enables an option to allocate an auxiliary stack for the remote call to use and, for the bootstrapper and loader, uses it.

The calls to mmap and munmap don't use much stack, so they are fine.

Fixes #544

@ajwerner
Copy link
Contributor Author

@oleavr I'm sure you'll have style comments and suggestions. I'd like to learn the right way to do things so I can more effectively help myself in the future. Let me know what you think of this when you find the time. Thanks!

@ajwerner
Copy link
Contributor Author

Okay, this patch relied on #550 to rebuild the bootstrapper images. I got rid of the build flags to enable this functionality from the original draft. I think this is a reasonable default.

@ajwerner ajwerner marked this pull request as ready for review September 26, 2024 21:56
@oleavr oleavr force-pushed the add-stack branch 2 times, most recently from 1e43af9 to 5e28fbe Compare October 21, 2024 11:43
For some target programs it's not reasonable to assume that any hijacked
thread has a large stack. For example, in Go, stacks are often small and
are allocated on the heap. The injector bootstrap program uses kilobytes
of stack. In order to side-step this problem, this patch changes the
boostrapper to allocate an auxiliary stack for remote calls to use and,
for the bootstrapper and loader, uses it.

The calls to mmap and munmap don't use much stack, so they are fine.

Fixes frida#544.
@oleavr oleavr changed the title frida-helper-backend: add option to allocate stack linux: Allocate stack for injector's remote calls Oct 21, 2024
@oleavr oleavr merged commit e8ee891 into frida:main Oct 21, 2024
9 of 37 checks passed
@oleavr
Copy link
Member

oleavr commented Oct 21, 2024

Thanks! 🙌 Sorry it took me so long to get to this. Figured I'd make the final tweaks myself to not bother you with super-late feedback 😅

@ajwerner
Copy link
Contributor Author

Thank you!

@ajwerner ajwerner deleted the add-stack branch October 21, 2024 12:10
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.

provide mechanism for injector to use allocated stack
2 participants