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

Add support for PR_SET_PTRACER #59

Closed
Jake-Shadle opened this issue Oct 21, 2022 · 3 comments · Fixed by #60
Closed

Add support for PR_SET_PTRACER #59

Jake-Shadle opened this issue Oct 21, 2022 · 3 comments · Fixed by #60
Labels
bug Something isn't working enhancement New feature or request

Comments

@Jake-Shadle
Copy link
Member

Currently on Linux, after a signal has been raised, we use prctl to add PR_SET_DUMPABLE before handing off control to the user callback. This allows the current, or more importantly an external, process to use ptrace to gather information on the crashing process when eg. writing a minidump. This flow is the same as Breakpad's.

However, this method is no longer guaranteed to work as newer distro releases are increasingly defaulting to increased security through things such as yama. When ptrace_scope is set to 1, the default in some distros (eg ubuntu 22.04), this will mean that a child process of the crashing process, which is how the libraries in this project are designed to work together, won't have ptrace permissions despite being dumpable.

We need to also set PR_SET_PTRACER so that the dumping process can have the permission, despite being a child (inferior) process of the crashing, parent, process. The simplest way to fix this would just be to use PR_SET_PTRACER_ANY, but we should add an option to the API to be able to explicitly set a PID for the one process which the user wants to allow to dump their parent process as well, if the user wants to be extra cautious.

@Jake-Shadle Jake-Shadle added bug Something isn't working enhancement New feature or request labels Oct 21, 2022
@timfish
Copy link

timfish commented Oct 21, 2022

This is also reproducible on ubuntu-latest on GitHub Actions since that became 22.04 recently.

@timfish
Copy link

timfish commented Oct 21, 2022

Having just said that this issue suggests it's not live as ubuntu-latest until December 1st!

However, I reproduced it here with the version listed as 20.04.1-Ubuntu SMP Thu Sep 1 19:20:56 UTC 2022 and it was subsequently fixed by adding PR_SET_PTRACER.

Maybe GitHub already had it locked down with ptrace_scope or do any of your tests suggest otherwise?

@Jake-Shadle
Copy link
Member Author

I don't believe I've had any issues running the linux tests in this project, but who knows, could be bad tests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@timfish @Jake-Shadle and others