Closed Bug 1400051 Opened 7 years ago Closed 6 years ago

Remove use of base::SetAllFDsToCloseOnExec from process_util_bsd.cc

Categories

(Core :: IPC, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: jld, Assigned: jld)

References

Details

Attachments

(1 file, 1 obsolete file)

This is one half of bug 1400042: process_util_bsd.cc is using base::SetAllFDsToCloseOnExec and potentially leaking concurrently created fds into child processes because it's using posix_spawn, which can't atomically close unwanted fds.  (Apple has a nonstandard extension, the flag POSIX_SPAWN_CLOEXEC_DEFAULT, which does this, but it doesn't seem to be present on other imeplementations.)

As far as I'm aware, *BSD could just use fork/exec the same way as on Linux.  In particular, once I've removed the leftover B2G ChildPrivileges stuff in bug 1316153, process_util_linux.cc could be copied more or less verbatim.
See Also: → 1400061
Priority: -- → P3
I have a patch for this….
Assignee: nobody → jld
I've been delaying this because I want to fix the known bug in the “Linux” implementation before saying that it's a good idea to switch the BSDs to it.

(On the other hand, the current BSD implementation is also incorrect in edge cases — see bug 1456919.)
Depends on: 1456911
Comment on attachment 8992055 [details]
Bug 1400051 - IPC: use process_util_linux on BSD and remove process_util_bsd.

r?glandium because this is almost entirely a build change.

f? what I hope is a reasonable set of BSD representatives because I don't want to just barge in and change their stuff without warning.

I've tested locally on FreeBSD 11, and ktraced to make sure that CloseSuperfluousFds is doing something reasonable.
Attachment #8992055 - Flags: feedback?(martin)
Attachment #8992055 - Flags: feedback?(landry)
Attachment #8992055 - Flags: feedback?(jbeich)
Comment on attachment 8992055 [details]
Bug 1400051 - IPC: use process_util_linux on BSD and remove process_util_bsd.

https://reviewboard.mozilla.org/r/256976/#review264298
Attachment #8992055 - Flags: review?(mh+mozilla) → review+
Comment on attachment 8992055 [details]
Bug 1400051 - IPC: use process_util_linux on BSD and remove process_util_bsd.

m-c builds fine with this diff, and nightly starts with 3 content processes. I've been able to browse a bit with it so i guess e10s works fine, but i dunno what codepaths are precisely affected by the change.
Attachment #8992055 - Flags: feedback?(landry) → feedback+
Comment on attachment 8992055 [details]
Bug 1400051 - IPC: use process_util_linux on BSD and remove process_util_bsd.

Tested (mozilla-central changeset b5152aa87782 snapshot) on FreeBSD 10.4 i386 and 11.1 amd64. Both plugin (Adobe Flash) and content processes appear to work fine.

Not possible to test on DragonFly as mozilla-central requires Rust 1.27.0 but only 1.25.0 is packaged at the moment.
https://github.com/DragonFlyBSD/DeltaPorts/tree/master/ports/lang/rust/
http://muscles.dragonflybsd.org/synth/logs/lang___rust.log
Attachment #8992055 - Flags: feedback?(jbeich) → feedback+
Comment on attachment 8992055 [details]
Bug 1400051 - IPC: use process_util_linux on BSD and remove process_util_bsd.

Also tested on FreeBSD 12.0 amd64 both default and --enable-debug build. Content processes work fine. I didn't try Flash plugin this time.
See Also: → 1231123
Rebased to deal with added comment in process_util_linux; carrying over r+.

Two BSDs confirming this works is probably enough; I'll land it now.
Attachment #8992055 - Attachment is obsolete: true
Attachment #8992055 - Flags: feedback?(martin)
Attachment #9010825 - Flags: review+
Pushed by jedavis@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3d337c5ca457
IPC: use process_util_linux on BSD and remove process_util_bsd. r=glandium
https://hg.mozilla.org/mozilla-central/rev/3d337c5ca457
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: