Closed Bug 1436882 Opened 6 years ago Closed 6 years ago

Parent process debugging broken by passing the wrong termination signal to clone()

Categories

(Core :: Security: Process Sandboxing, defect, P1)

Unspecified
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla60
Tracking Status
firefox60 --- fixed

People

(Reporter: jld, Assigned: jld)

References

Details

Attachments

(1 file)

GDB seems to not recognize that the clone() call used in bug 1401062 is creating a new process.  It attaches to the child task as if it were a thread, treats its execve() call as applying to the whole process, and generally becomes confused:

[New Thread 0x7fffcf4ff700 (LWP 17199)]
[New Thread 0x7fffe5825700 (LWP 17200)]
[New Thread 0x7fffe5825700 (LWP 17201)]
process 17146 is executing new program: /home/jld/src/obj.gecko-dev/obj-x86_64-pc-linux-gnu/dist/bin/firefox
[New LWP 17202]
[New LWP 17203]
[New LWP 17204]
[New LWP 17205]
[New LWP 17146]
[New LWP 17201]
Error while reading shared library symbols for /lib/x86_64-linux-gnu/libpthread.so.0:
Cannot find user-level thread for LWP 17200: generic error


Temporary workaround: set MOZ_ASSUME_USER_NS=0 in the environment.  (If not using Gecko Media Plugins and if the build is after bug 1430949 landed, lowering the security.sandbox.content.level pref from 4 to 3 should also work.)
This turns out to be a silly mistake on my part: I forgot to include the termination signal in the clone() flags, so it's 0.  If that field isn't equal to SIGCHLD, and the cloning process is being ptraced, then the kernel reports PTRACE_EVENT_CLONE instead of PTRACE_EVENT_FORK, and that's why GDB thinks it's a thread rather than a child process.

(The original version of those patches did this correctly, but later I switched from using the clone syscall directly to a more complicated approach using the libc clone() function and forgot that part.)
Summary: Creating child processes with clone() breaks GDB → Parent process debugging broken by passing the wrong termination signal to clone()
Comment on attachment 8949598 [details]
Bug 1436882 - Fix termination signal when clone()ing child processes.

https://reviewboard.mozilla.org/r/218964/#review224732
Attachment #8949598 - Flags: review?(gpascutto) → review+
Pushed by jedavis@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5ea26fba220d
Fix termination signal when clone()ing child processes. r=gcp
https://hg.mozilla.org/mozilla-central/rev/5ea26fba220d
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: