-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
syscall: Pdeathsig ignored when using setuid/setgid (Linux) #9686
Labels
Milestone
Comments
ajwdev
added a commit
to ajwdev/go
that referenced
this issue
Jan 25, 2015
Fix a bug on Linux where using the `Pdeathsig` along with SETUID/SETGID would cause the death signal to be ignored. This is because the Linux kernel will clear the `deathsignal` field on a task when performing a SETUID/SETGID system call. To avoid this we simply move the `Pdeathsig` logic farther down in the funcion after we have switched to our new uid/gid. Fixes golang#9686 Change-Id: Id01896ad4e979b8c448e0061f00aa8762ca0ac94
Pending CL is https://go-review.googlesource.com/#/c/3290 |
ajwdev
added a commit
to ajwdev/go
that referenced
this issue
Apr 18, 2015
Fix a bug on Linux where using the `Pdeathsig` along with SETUID/SETGID would cause the death signal to be ignored. This is because the Linux kernel will clear the `deathsignal` field on a task when performing a SETUID/SETGID system call. To avoid this we simply move the `Pdeathsig` logic farther down in the function after we have switched to our new uid/gid. Fixes golang#9686 Change-Id: Id01896ad4e979b8c448e0061f00aa8762ca0ac94
ajwdev
added a commit
to ajwdev/go
that referenced
this issue
Apr 23, 2015
Fix a bug on Linux where using the `Pdeathsig` along with SETUID/SETGID would cause the death signal to be ignored. This is because the Linux kernel will clear the `deathsignal` field on a task when performing a SETUID/SETGID system call. To avoid this we simply move the `Pdeathsig` logic farther down in the function after we have switched to our new uid/gid. Fixes golang#9686 Change-Id: Id01896ad4e979b8c448e0061f00aa8762ca0ac94
CL https://golang.org/cl/3290 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When attempting to use the
Pdeathsig
functionality on Linux, along with using setuid/setgid, the death signal appears to be ignored. However when setuid/setgid is not used, the death signal works as expected. This behavior was observed on Go version 1.4.1 with the following test code:Steps to reproduce
Without setting a uid/gid to switch to, the death signal works as expected
When switching to another uid/gid (user and group "nobody" in this case) we see that the child is not sent a sigterm.
I reproduced this bug on Fedora 20 (kernel version: 3.16.4-200.fc20.x86_64) as well as on Centos 6.6 (kernel version: 2.6.32-431.11.2.el6.x86_64).
The fix
From what I can tell by looking at the kernel source, it appears Linux resets the death signal attribute on a task when the effective uid/gid changes.
https://github.com/torvalds/linux/blob/d82012695ef29e4e1c8153ccf43098ec8e50369e/kernel/sys.c#L561
https://github.com/torvalds/linux/blob/9a3c4145af32125c5ee39c0272662b47307a8323/kernel/cred.c#L441
In
src/syscall/exec_linux.go
we set the death signal before we make any setuid/setgid system calls which means it will always be cleared in those cases. Moving thePdeathsig
code farther down in the function seems to fix the problem.I'll be submitting a CL shortly.
The text was updated successfully, but these errors were encountered: