Commit Graph

633 Commits

Author SHA1 Message Date
Mike Hommey
03921df0a2 Bug 1933372 - Add entry points for runtime initialization on iOS. r=nika
This adds two entry points: MainProcessInit and ChildProcessInit.
This mimicks what we have on Android (although the main process entry
point has a different name there, and the entry points are in mozglue
rather than libxul).

This adds enough stub from the upcoming swift side to build
independently.

Differential Revision: https://phabricator.services.mozilla.com/D230203
2024-12-03 02:10:42 +00:00
Oliver Old
054846ec0f Bug 1240005 - Users of do_CreateInstance or InitWithNativePath/InitWithPath not checking return value r=necko-reviewers,xpcom-reviewers,media-playback-reviewers,emilio,karlt,valentin
Differential Revision: https://phabricator.services.mozilla.com/D227280
2024-11-25 16:54:11 +00:00
Nika Layzell
7d9829fbec Bug 1928734 - Part 2: Centralize handling of the IPC IO thread, r=ipc-reviewers,media-playback-reviewers,karlt,jld,handyman
Previously the handling for the IO thread was split between
BrowserProcessSubThread (a replication of the background thread infrastructure
used by Chromium during the IPC import, which is only used for the IO thread in
Gecko), and IOThreadChild (a wrapper around ChildThread, which was imported
from Chromium's source).

This meant that there was little code-sharing between the parent and child
processes, and that the lifecycle of the IO thread was perhaps less clear.

This refactors the code to centralize handling of these threads, and provide a
basic common interface. At the moment, actually hooking up async IO listeners
is still done using the Chromium interfaces.

Differential Revision: https://phabricator.services.mozilla.com/D227739
2024-11-19 18:34:02 +00:00
Nika Layzell
4706965bfb Bug 1928734 - Part 1: Replace XRE_GetIOMessageLoop with XRE_GetAsyncIOEventTarget, r=ipc-reviewers,media-playback-reviewers,karlt,jld
This abstracts away specifics of the chromium message loop from callers of
XRE_GetIOMessageLoop, giving a standard nsISerialEventTarget interface instead.

This is intended to make space for non-chromium IO backends in the future, such
as the potential to use libdispatch for IO on macOS and/or iOS.

Differential Revision: https://phabricator.services.mozilla.com/D227738
2024-11-19 18:34:02 +00:00
Butkovits Atila
8d194ab684 Backed out 3 changesets (bug 1928734) for causing linting failure. CLOSED TREE
Backed out changeset 1b9e50c4c129 (bug 1928734)
Backed out changeset dd5cabd3fbc4 (bug 1928734)
Backed out changeset a9f66c1d560d (bug 1928734)
2024-11-19 01:49:22 +02:00
Nika Layzell
299a27a846 Bug 1928734 - Part 2: Centralize handling of the IPC IO thread, r=ipc-reviewers,media-playback-reviewers,karlt,jld
Previously the handling for the IO thread was split between
BrowserProcessSubThread (a replication of the background thread infrastructure
used by Chromium during the IPC import, which is only used for the IO thread in
Gecko), and IOThreadChild (a wrapper around ChildThread, which was imported
from Chromium's source).

This meant that there was little code-sharing between the parent and child
processes, and that the lifecycle of the IO thread was perhaps less clear.

This refactors the code to centralize handling of these threads, and provide a
basic common interface. At the moment, actually hooking up async IO listeners
is still done using the Chromium interfaces.

Differential Revision: https://phabricator.services.mozilla.com/D227739
2024-11-18 22:54:54 +00:00
Nika Layzell
1c0946c2de Bug 1928734 - Part 1: Replace XRE_GetIOMessageLoop with XRE_GetAsyncIOEventTarget, r=ipc-reviewers,media-playback-reviewers,karlt,jld
This abstracts away specifics of the chromium message loop from callers of
XRE_GetIOMessageLoop, giving a standard nsISerialEventTarget interface instead.

This is intended to make space for non-chromium IO backends in the future, such
as the potential to use libdispatch for IO on macOS and/or iOS.

Differential Revision: https://phabricator.services.mozilla.com/D227738
2024-11-18 22:54:53 +00:00
Nika Layzell
077db077a1 Bug 1928769 - Stop holding a mutex across gIPCLaunchThread shutdown, r=ipc-reviewers,jld
Differential Revision: https://phabricator.services.mozilla.com/D227761
2024-11-18 17:24:16 +00:00
Florian Quèze
fd32d5896d Bug 1923028 - Migrate scalars to use Glean APIs for dom.*, r=chutten.
Differential Revision: https://phabricator.services.mozilla.com/D226688
2024-10-24 10:52:57 +00:00
Emilio Cobos Álvarez
4c840d573b Bug 1925866 - NS_NewLocalFile's aFollowSymlinks arg is unused. r=xpcom-reviewers,necko-reviewers,valentin,media-playback-reviewers,win-reviewers,karlt,nika,rkraesig
Remove it and related functions, and update the callers.

Differential Revision: https://phabricator.services.mozilla.com/D226261
2024-10-22 09:38:16 +00:00
Nika Layzell
eae67d29ac Bug 1917904 - Support passing mach ports into new processes, r=ipc-reviewers,jld
This builds on the support from bug 1440207 to allow passing mach ports into
new content processes. This is done using the existing initial mach IPC already
used to transfer a mach task port to the parent process on child process
creation.

Differential Revision: https://phabricator.services.mozilla.com/D221708
2024-10-16 22:51:10 +00:00
Bob Owen
42fce430c5 Bug 1920463 p2: Remove AbstractSandboxBroker. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D223117
2024-10-16 07:49:25 +00:00
Bob Owen
9a7429a6d1 Bug 1920463 p1: Remove RemoteSandboxBroker. r=nika,geckoview-reviewers,ipc-reviewers,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D223114
2024-10-16 07:49:24 +00:00
Stanca Serban
4d5be66421 Backed out 2 changesets (bug 1920463) for causing multiple failures. CLOSED TREE
Backed out changeset e56421ffea4f (bug 1920463)
Backed out changeset 3c3f9787cfe4 (bug 1920463)
2024-10-08 15:17:36 +03:00
Bob Owen
1b5deb5d52 Bug 1920463 p2: Remove AbstractSandboxBroker. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D223117
2024-10-08 09:57:57 +00:00
Bob Owen
603c3585be Bug 1920463 p1: Remove RemoteSandboxBroker. r=nika,geckoview-reviewers,ipc-reviewers,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D223114
2024-10-08 09:57:56 +00:00
Mike Hommey
d7f9ebcda1 Bug 1922183 - Fix xpc_array_set_fd use in IosProcessLauncher::DoLaunch. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D224286
2024-10-02 19:53:25 +00:00
Nika Layzell
1aa49186e2 Bug 1440207 - Part 3j: ForkServer support for file geckoargs, r=ipc-reviewers,jld
After this change, the fork server no longer uses a Dup2Sequence to set
fixed FD offsets when starting child processes, instead using the new
geckoargs system.

Because this was pretty disruptive to thow the fork server works and was
previously integrated into LaunchApp, the forkserver code has generally been
moved out of the chromium codebase, and inlined into the ForkServer files.

As the linux chroot sandbox code needs to run the chroot server from a process
created during forking, it is now being sent down to the fork server
separately, though the child end of the pipe is still being passed using
GeckoArgs.

Finally, the primary IPC pipe used by the fork server is also changed to
be passed using geckoargs into the fork server, and the fork server
being used is made more explicit in GeckoChildProcessHost, as launching
using the fork server now requires different arguments than launching
normally (due to needing to pass down the ChildProcessArgs).

Differential Revision: https://phabricator.services.mozilla.com/D221380
2024-10-01 22:21:51 +00:00
Nika Layzell
75e9a23f10 Bug 1440207 - Part 3i: Fix iOS builds, r=ipc-reviewers,jld
The code which decodes the XPC bootstrap message hasn't landed into
mozilla-central yet, so only the serializing side in GeckoChildProcessHost is
updated here.

Differential Revision: https://phabricator.services.mozilla.com/D221379
2024-10-01 22:21:51 +00:00
Nika Layzell
0d6bd716fe Bug 1440207 - Part 3h: Android support for file geckoargs, r=geckoview-reviewers,ipc-reviewers,owlish,jld
This changes how file descriptors are passed to Android child processes to
support the new ChildProcessArgs model. Instead of explicit lists of FDs to pass
around, a single array of FDs is passed from the parent process into the child
service and then passed into GeckoArgs.

Differential Revision: https://phabricator.services.mozilla.com/D221378
2024-10-01 22:21:50 +00:00
Nika Layzell
079f6a7724 Bug 1440207 - Part 3g: Basic posix support for file geckoargs, r=ipc-reviewers,jld
This effectively mimics the old system using fixed FDs for passing the
arguments down.

An in-memory array of FDs is used to track which FD corresponds with
with file argument, which is initialized to the fixed offsets, in order
to allow platforms which cannot use fixed FDs in their child processes
to specify explicit files being passed down. This will be used in the
fork server, for Android, and for iOS.

Differential Revision: https://phabricator.services.mozilla.com/D221377
2024-10-01 22:21:50 +00:00
Nika Layzell
be6482bcdd Bug 1440207 - Part 3f: Windows support for file geckoargs, r=ipc-reviewers,mccr8
Windows is the simplest platform to support, as HANDLEs are inherited by
identity into the child process, and there's less variance between different
OSes.

This effectively re-implements the existing behaviour used for HANDLE
passing on Windows by passing the handle directly on the command line.

Differential Revision: https://phabricator.services.mozilla.com/D221376
2024-10-01 22:21:50 +00:00
Nika Layzell
127232259b Bug 1440207 - Part 3e: Pass linux sandbox fds using geckoargs, r=ipc-reviewers,jld
Previously these arguments were initialized in places which would be
inconvenient to use geckoargs with. This patch changes them to both be
initialized during SandboxLaunch::Configure in the parent process, and
then be passed down to the process launching code either within the
LaunchOptions object, or in the ChildProcessArgs object.

Unfortunately, we need to read the command line arguments within
XRE_InitChildProcess, rather than SandboxEarlyInit, as the sandbox code
is not linked directly to libxul, where the file handle GeckoArgs
methods are defined.

One of the more significant functional changes here is that when using
the fork server, the chroot pipe will be created within the parent
process, with the server end of the pipe passed over IPC to the fork
server to be used to create the chroot server. This is a bit
unnecessary, but keeps things simpler for the fork server, as geckoargs
are transferred directly from the parent process to the forked child
processes over the forkserver exec pipe.

Differential Revision: https://phabricator.services.mozilla.com/D221375
2024-10-01 22:21:49 +00:00
Nika Layzell
8f1149d269 Bug 1440207 - Part 3d: Pass the initial IPC pipe using geckoargs, r=ipc-reviewers,mccr8
The initial IPC pipe was previously the only argument passed as a chromium
command line flag. This changes it to instead be passed using geckoargs,
unifying the platforms, and removing the need for specific handling on every
platform.

Differential Revision: https://phabricator.services.mozilla.com/D221374
2024-10-01 22:21:49 +00:00
Nika Layzell
a127e6aebd Bug 1440207 - Part 3c: Pass the crashreporter pipe using geckoargs, r=gsvelto
The crash reporter pipe was previously passed as a positional argument with
custom code for each platform. On some platforms it is implemented as a file
being passed, which is now directly supported by geckoargs.

Differential Revision: https://phabricator.services.mozilla.com/D221373
2024-10-01 22:21:48 +00:00
Nika Layzell
51c14265d6 Bug 1440207 - Part 3b: Use GeckoArgs for parentPID and initialChannelID, r=ipc-reviewers,mccr8
This helps unify some logic between platforms, and removes some positional
arguments from the command line, so it ended up in this patch stack, despite
not technically being required to pass FDs directly.

Differential Revision: https://phabricator.services.mozilla.com/D221372
2024-10-01 22:21:48 +00:00
Nika Layzell
12d5dea84d Bug 1440207 - Part 3a: Migrate GeckoChildProcessHost callers to use ChildProcessArgs, r=ipc-reviewers,necko-reviewers,media-playback-reviewers,aosmond,mccr8
This patch implements the majority of the public interface for the new IPC
handle passing design.

The rough design is an expansion of `geckoargs` to allow passing
`UniqueFileHandle` arguments to child processes. This replaces the existing
extra options array to make the list of files explicit.

This currently just replaces things which were already passed this way on the
command line from outside of GeckoChildProcessHost. Note that this does not
migrate callers which were not already passing file handles using geckoargs,
and does not implement the actual OS-level support for passing arguments this
way.

Differential Revision: https://phabricator.services.mozilla.com/D221371
2024-10-01 22:21:47 +00:00
Cristian Tuns
ef799296b7 Backed out 13 changesets (bug 1440207) for causing multiple failures. CLOSED TREE
Backed out changeset c9f33dfc1cc5 (bug 1440207)
Backed out changeset 76d823a34925 (bug 1440207)
Backed out changeset 75a99142ee1c (bug 1440207)
Backed out changeset b4d283d3e8da (bug 1440207)
Backed out changeset ea81a08ce181 (bug 1440207)
Backed out changeset c581a4e8cd15 (bug 1440207)
Backed out changeset d13799a1dc26 (bug 1440207)
Backed out changeset 6d715586c911 (bug 1440207)
Backed out changeset 30ff6a4db1d0 (bug 1440207)
Backed out changeset 2da0bbfdfee5 (bug 1440207)
Backed out changeset f3445c3fdd5e (bug 1440207)
Backed out changeset 07fbed499fe4 (bug 1440207)
Backed out changeset 1c2ac609c466 (bug 1440207)
2024-09-24 19:10:35 -04:00
Nika Layzell
ae8dbaf43b Bug 1440207 - Part 3j: ForkServer support for file geckoargs, r=ipc-reviewers,jld
After this change, the fork server no longer uses a Dup2Sequence to set
fixed FD offsets when starting child processes, instead using the new
geckoargs system.

Because this was pretty disruptive to thow the fork server works and was
previously integrated into LaunchApp, the forkserver code has generally been
moved out of the chromium codebase, and inlined into the ForkServer files.

As the linux chroot sandbox code needs to run the chroot server from a process
created during forking, it is now being sent down to the fork server
separately, though the child end of the pipe is still being passed using
GeckoArgs.

Finally, the primary IPC pipe used by the fork server is also changed to
be passed using geckoargs into the fork server, and the fork server
being used is made more explicit in GeckoChildProcessHost, as launching
using the fork server now requires different arguments than launching
normally (due to needing to pass down the ChildProcessArgs).

Differential Revision: https://phabricator.services.mozilla.com/D221380
2024-09-24 19:28:13 +00:00
Nika Layzell
2583ee109c Bug 1440207 - Part 3i: Fix iOS builds, r=ipc-reviewers,jld
The code which decodes the XPC bootstrap message hasn't landed into
mozilla-central yet, so only the serializing side in GeckoChildProcessHost is
updated here.

Differential Revision: https://phabricator.services.mozilla.com/D221379
2024-09-24 19:28:12 +00:00
Nika Layzell
ff041d1e4a Bug 1440207 - Part 3h: Android support for file geckoargs, r=geckoview-reviewers,ipc-reviewers,owlish,jld
This changes how file descriptors are passed to Android child processes to
support the new ChildProcessArgs model. Instead of explicit lists of FDs to pass
around, a single array of FDs is passed from the parent process into the child
service and then passed into GeckoArgs.

Differential Revision: https://phabricator.services.mozilla.com/D221378
2024-09-24 19:28:12 +00:00
Nika Layzell
c47df5966b Bug 1440207 - Part 3g: Basic posix support for file geckoargs, r=ipc-reviewers,jld
This effectively mimics the old system using fixed FDs for passing the
arguments down.

An in-memory array of FDs is used to track which FD corresponds with
with file argument, which is initialized to the fixed offsets, in order
to allow platforms which cannot use fixed FDs in their child processes
to specify explicit files being passed down. This will be used in the
fork server, for Android, and for iOS.

Differential Revision: https://phabricator.services.mozilla.com/D221377
2024-09-24 19:28:12 +00:00
Nika Layzell
e00574547c Bug 1440207 - Part 3f: Windows support for file geckoargs, r=ipc-reviewers,mccr8
Windows is the simplest platform to support, as HANDLEs are inherited by
identity into the child process, and there's less variance between different
OSes.

This effectively re-implements the existing behaviour used for HANDLE
passing on Windows by passing the handle directly on the command line.

Differential Revision: https://phabricator.services.mozilla.com/D221376
2024-09-24 19:28:11 +00:00
Nika Layzell
9b048b7d9f Bug 1440207 - Part 3e: Pass linux sandbox fds using geckoargs, r=ipc-reviewers,jld
Previously these arguments were initialized in places which would be
inconvenient to use geckoargs with. This patch changes them to both be
initialized during SandboxLaunch::Configure in the parent process, and
then be passed down to the process launching code either within the
LaunchOptions object, or in the ChildProcessArgs object.

Unfortunately, we need to read the command line arguments within
XRE_InitChildProcess, rather than SandboxEarlyInit, as the sandbox code
is not linked directly to libxul, where the file handle GeckoArgs
methods are defined.

One of the more significant functional changes here is that when using
the fork server, the chroot pipe will be created within the parent
process, with the server end of the pipe passed over IPC to the fork
server to be used to create the chroot server. This is a bit
unnecessary, but keeps things simpler for the fork server, as geckoargs
are transferred directly from the parent process to the forked child
processes over the forkserver exec pipe.

Differential Revision: https://phabricator.services.mozilla.com/D221375
2024-09-24 19:28:11 +00:00
Nika Layzell
a569104ae8 Bug 1440207 - Part 3d: Pass the initial IPC pipe using geckoargs, r=ipc-reviewers,mccr8
The initial IPC pipe was previously the only argument passed as a chromium
command line flag. This changes it to instead be passed using geckoargs,
unifying the platforms, and removing the need for specific handling on every
platform.

Differential Revision: https://phabricator.services.mozilla.com/D221374
2024-09-24 19:28:10 +00:00
Nika Layzell
97bdfb352a Bug 1440207 - Part 3c: Pass the crashreporter pipe using geckoargs, r=gsvelto
The crash reporter pipe was previously passed as a positional argument with
custom code for each platform. On some platforms it is implemented as a file
being passed, which is now directly supported by geckoargs.

Differential Revision: https://phabricator.services.mozilla.com/D221373
2024-09-24 19:28:10 +00:00
Nika Layzell
e442796846 Bug 1440207 - Part 3b: Use GeckoArgs for parentPID and initialChannelID, r=ipc-reviewers,mccr8
This helps unify some logic between platforms, and removes some positional
arguments from the command line, so it ended up in this patch stack, despite
not technically being required to pass FDs directly.

Differential Revision: https://phabricator.services.mozilla.com/D221372
2024-09-24 19:28:10 +00:00
Nika Layzell
62686c41b3 Bug 1440207 - Part 3a: Migrate GeckoChildProcessHost callers to use ChildProcessArgs, r=ipc-reviewers,necko-reviewers,media-playback-reviewers,aosmond,mccr8
This patch implements the majority of the public interface for the new IPC
handle passing design.

The rough design is an expansion of `geckoargs` to allow passing
`UniqueFileHandle` arguments to child processes. This replaces the existing
extra options array to make the list of files explicit.

This currently just replaces things which were already passed this way on the
command line from outside of GeckoChildProcessHost. Note that this does not
migrate callers which were not already passing file handles using geckoargs,
and does not implement the actual OS-level support for passing arguments this
way.

Differential Revision: https://phabricator.services.mozilla.com/D221371
2024-09-24 19:28:09 +00:00
Alexandre Lissy
052d005802 Bug 1506198 - Remove content temp dir r=gcp
Differential Revision: https://phabricator.services.mozilla.com/D220369
2024-09-11 07:37:27 +00:00
Norisz Fay
b531d96b7d Backed out changeset b38b6b47c602 (bug 1506198) for causing bustage on SandboxBroker.cpp CLOSED TREE 2024-09-11 10:21:38 +03:00
Alexandre Lissy
64b77d1d24 Bug 1506198 - Remove content temp dir r=gcp
Differential Revision: https://phabricator.services.mozilla.com/D220369
2024-09-11 06:07:42 +00:00
Nika Layzell
b0d1f2c5e9 Bug 1908725 - Part 1: Introduce GeckoChildID, r=glandium,ipc-reviewers,mccr8
The new GeckoChildID type introduced in this patch is inspired by the existing
ContentParentID type used by ContentParent, but is currently distinct. It is
supported by all process types at the GeckoChildProcessHost level and can be
read for the current process from anywhere.

As this type is similar in many ways to the process type, and should be
available as early as possible within child processes, this was added alongside
the GeckoProcessType value within mozglue to make that easier to do.

The type was chosen to be an int32_t to make it feel similar to a PID, which we
currently use for process identity comparisons across the codebase. The
intention is for GeckoChildID to be preferred for these within-gecko checks, as
these IDs will not be re-used and can be known earlier during child process
creation.

Differential Revision: https://phabricator.services.mozilla.com/D217117
2024-08-07 20:39:39 +00:00
Alex Franchuk
5a5e8a0b1c Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D217487
2024-08-06 18:16:08 +00:00
Noemi Erli
4a933a7f06 Backed out changeset e5864b976c3b (bug 1454819) for causing build bustages in SharedMemory.cpp CLOSED TREE 2024-08-05 18:08:32 +03:00
Alex Franchuk
e7d059af48 Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D217487
2024-08-05 13:01:33 +00:00
Ray Kraesig
1c651c42e7 Bug 1895375 - [1/4] Adjust types associated with ipc::LaunchError r=ipc-reviewers,win-reviewers,gstoll,nika
As the intended use for LaunchError::mFunction is telemetry, avoid the
possibility of accidental exfiltration of PII by requiring that
LaunchError be constructed from `StaticString`.

Additionally, remove the Windows-specific constructor overloads in favor
of an explicit factory function, and explicitly document that `mError`
is a generic bag of bits rather than any kind of strict error type.

No functional changes.

Differential Revision: https://phabricator.services.mozilla.com/D209712
2024-05-30 17:52:07 +00:00
Yannis Juglaret
e001e26561 Backed out changeset 98eadcb92105 (Bug 1878993) for causing bug 1892612. r=#win-reviewers CLOSED TREE
Differential Revision: https://phabricator.services.mozilla.com/D208112
2024-04-22 09:39:15 +00:00
Nika Layzell
c9d41b213b Bug 1881636 - Part 3: Implement IosProcessLauncher::DoLaunch. r=glandium,ipc-reviewers,jld
This uses BrowserEngineKit's ExtensionKit-based processes to start content
processes on iOS. These processes are started with an initial xpc connection,
which is then used to communicate a command line, initial file descriptors
and environment variables before invoking content_process_main.

The XPC connection is not used further after the bootstrap message, which seems
to roughly match how WebKit uses these APIs.

Differential Revision: https://phabricator.services.mozilla.com/D202525
2024-03-26 22:56:27 +00:00
Mike Hommey
e3d3d75205 Bug 1881636 - Part 2 - Expose SetClientChannelFd, SetPrefsFd and SetPrefMapFd on iOS. r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D205270
2024-03-26 22:56:26 +00:00
Cosmin Sabou
c7315fd2da Backed out 2 changesets (bug 1886607) for causing build bustages on ChromeUtils.
Backed out changeset 2fa193524f2c (bug 1886607)
Backed out changeset f77ff6043d75 (bug 1886607)
2024-03-22 00:28:44 +02:00