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

pthread_setname_np privilege error on Linux after a setuid() call #26

Closed
evantorrie opened this issue Mar 25, 2015 · 1 comment · Fixed by #27
Closed

pthread_setname_np privilege error on Linux after a setuid() call #26

evantorrie opened this issue Mar 25, 2015 · 1 comment · Fixed by #27
Assignees

Comments

@evantorrie
Copy link
Contributor

pthread_setname_np is implemented in glibc with two different code paths.

When called on a target thread other than the current thread, it attempts to write to /proc/self/task/<taskid>/comm. However, when a process calls setuid/seteuid, the proc entries underneath remain owned by the pre-setuid userid unless the Linux kernel tunable /proc/sys/fs/suid_dumpable is set to 1.

As a result, we see repeated failures and perror errors from this call to pthread_setname_np in our error log where we start node as root and then lower privileges by calling setuid() prior to calling require("monitr").

On the other hand, when pthread_setname_np is called by a thread on itself, it uses a different code path which makes a syscall to prctl. So suggested fix is to change the location where pthread_setname_np is called to be inside the monitr thread itself, rather than inside the v8 thread.

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 a pull request may close this issue.

1 participant