Skip to content

Commit ad9bb1e

Browse files
committed
Bug 1867360 - Require toplevel protocols to specify which processes they expect to be bound in, r=decoder,ipc-reviewers,necko-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,aosmond,rkraesig,mccr8,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D195485
1 parent b5c2ad7 commit ad9bb1e

File tree

198 files changed

+350
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+350
-55
lines changed

dom/file/ipc/PRemoteLazyInputStream.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ include IPCStream;
66

77
namespace mozilla {
88

9+
[ChildProc=any]
910
protocol PRemoteLazyInputStream
1011
{
1112
parent:

dom/fs/shared/PFileSystemAccessHandleControl.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using struct mozilla::void_t from "mozilla/ipc/IPCCore.h";
77
namespace mozilla {
88
namespace dom {
99

10+
[ChildProc=anydom]
1011
async protocol PFileSystemAccessHandleControl
1112
{
1213
parent:

dom/fs/shared/PFileSystemManager.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ union FileSystemMoveEntryResponse
247247

248248
} // namespace fs
249249

250+
[ChildProc=anydom]
250251
async protocol PFileSystemManager
251252
{
252253
manages PFileSystemAccessHandle;

dom/ipc/PContent.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ union PClipboardReadRequestOrError {
480480
* and a content process. There is exactly one PContentParent/PContentChild pair
481481
* for each content process.
482482
*/
483-
[NestedUpTo=inside_cpow, NeedsOtherPid]
483+
[NestedUpTo=inside_cpow, NeedsOtherPid, ChildProc=Content]
484484
sync protocol PContent
485485
{
486486
manages PBrowser;

dom/ipc/PInProcess.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace dom {
2121
* `mozilla::dom::InProcess{Parent, Child}::Singleton()` should be used to get
2222
* an instance of this actor.
2323
*/
24+
[ChildProc=Parent]
2425
async protocol PInProcess
2526
{
2627
manages PExtensions;

dom/ipc/PJSOracle.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace mozilla {
99
namespace dom {
1010

1111
// PJSOracle is a top-level actor which manages PJSValidator
12+
[ChildProc=Utility]
1213
async protocol PJSOracle {
1314
manages PJSValidator;
1415

dom/ipc/PProcessHangMonitor.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct SlowScriptData
2323
double duration;
2424
};
2525

26-
[ChildImpl=virtual, ParentImpl=virtual]
26+
[ChildImpl=virtual, ParentImpl=virtual, ChildProc=Content]
2727
protocol PProcessHangMonitor
2828
{
2929
parent:

dom/media/gmp/PGMP.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using mozilla::dom::NativeThreadId from "mozilla/dom/NativeThreadId.h";
2424
namespace mozilla {
2525
namespace gmp {
2626

27-
[NeedsOtherPid, NestedUpTo=inside_sync, ChildImpl="GMPChild", ParentImpl="GMPParent"]
27+
[NeedsOtherPid, NestedUpTo=inside_sync, ChildImpl="GMPChild", ParentImpl="GMPParent", ChildProc=GMPlugin]
2828
sync protocol PGMP
2929
{
3030
manages PGMPTimer;

dom/media/gmp/PGMPContent.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include "GMPContentChild.h";
1616
namespace mozilla {
1717
namespace gmp {
1818

19-
[NeedsOtherPid, ChildImpl="GMPContentChild", ParentImpl=virtual]
19+
[NeedsOtherPid, ChildImpl="GMPContentChild", ParentImpl=virtual, ParentProc=anydom, ChildProc=GMPlugin]
2020
sync protocol PGMPContent
2121
{
2222
manages PGMPVideoDecoder;

dom/media/gmp/PGMPService.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct GMPLaunchResult {
2323
nsCString errorDescription;
2424
};
2525

26-
[NeedsOtherPid, ChildImpl=virtual, ParentImpl=virtual]
26+
[NeedsOtherPid, ChildImpl=virtual, ParentImpl=virtual, ChildProc=Content]
2727
async protocol PGMPService
2828
{
2929
parent:

dom/media/ipc/PRDD.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace mozilla {
4141
// (RemoteDataDecoder) process. There is one instance of this protocol,
4242
// with the RDDParent living on the main thread of the RDD process and
4343
// the RDDChild living on the main thread of the UI process.
44-
[NeedsOtherPid]
44+
[NeedsOtherPid, ParentProc=RDD, ChildProc=Parent]
4545
protocol PRDD
4646
{
4747
parent:

dom/media/ipc/PRemoteDecoderManager.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ union RemoteDecoderInfoIPDL
3838
VideoDecoderInfoIPDL;
3939
};
4040

41-
[NeedsOtherPid]
41+
[NeedsOtherPid, ParentProc=any, ChildProc=anydom]
4242
sync protocol PRemoteDecoderManager
4343
{
4444
manages PRemoteDecoder;

dom/media/webrtc/PMediaTransport.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ using mozilla::net::NrIceStunAddrArray from "mozilla/net/PStunAddrsParams.h";
2828
namespace mozilla {
2929
namespace dom {
3030

31+
[ParentProc=Socket, ChildProc=Content]
3132
async protocol PMediaTransport {
3233
#ifdef MOZ_WEBRTC
3334
parent:

dom/midi/PMIDIManager.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include MIDITypes;
77
namespace mozilla {
88
namespace dom {
99

10+
[ChildProc=anydom]
1011
async protocol PMIDIManager
1112
{
1213
parent:

dom/midi/PMIDIPort.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include MIDITypes;
99
namespace mozilla {
1010
namespace dom {
1111

12+
[ChildProc=anydom]
1213
async protocol PMIDIPort
1314
{
1415
parent:

dom/quota/PRemoteQuotaObject.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace mozilla {
66
namespace dom {
77
namespace quota {
88

9+
[ChildProc=anydom]
910
sync protocol PRemoteQuotaObject
1011
{
1112
parent:

dom/quota/test/gtest/PQuotaTest.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace mozilla {
66
namespace dom {
77
namespace quota {
88

9+
[ParentProc=any, ChildProc=any]
910
sync protocol PQuotaTest {
1011
parent:
1112
sync Try_Success_CustomErr_QmIpcFail()

dom/system/windows/PWindowsUtils.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace mozilla {
1010
namespace dom {
1111

1212
// Manager of utility actors that run in the windows utility process.
13+
[ChildProc=Utility]
1314
protocol PWindowsUtils {
1415
manages PWindowsLocation;
1516

dom/webtransport/shared/PWebTransport.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ union StreamResetOrStopSendingError {
4545
StopSendingError;
4646
};
4747

48+
[ChildProc=anydom]
4849
async protocol PWebTransport
4950
{
5051
parent:

gfx/ipc/PCanvasManager.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace gfx {
2222
* compositor process. This protocol should be used to create accelerated
2323
* canvas instances.
2424
*/
25-
[NeedsOtherPid]
25+
[NeedsOtherPid, ParentProc=compositor, ChildProc=anydom]
2626
sync protocol PCanvasManager
2727
{
2828
manages PCanvas;

gfx/ipc/PGPU.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct LayerTreeIdMapping {
5353
// This protocol allows the UI process to talk to the GPU process. There is one
5454
// instance of this protocol, with the GPUParent living on the main thread of
5555
// the GPU process and the GPUChild living on the main thread of the UI process.
56-
[NeedsOtherPid]
56+
[NeedsOtherPid, ParentProc=GPU, ChildProc=Parent]
5757
sync protocol PGPU
5858
{
5959
parent:

gfx/ipc/PVsyncBridge.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace gfx {
1616
// dedicated thread in the UI process to the compositor thread in the
1717
// compositor process. The child side exists in the UI process, and the
1818
// parent side in the GPU process.
19-
[NeedsOtherPid]
19+
[NeedsOtherPid, ParentProc=GPU, ChildProc=Parent]
2020
sync protocol PVsyncBridge
2121
{
2222
parent:

gfx/layers/ipc/PAPZInputBridge.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace layers {
3333
* The parent side lives on the main thread in the GPU process. If there is no
3434
* GPU process, then this protocol is not instantiated.
3535
*/
36+
[ParentProc=GPU, ChildProc=Parent]
3637
sync protocol PAPZInputBridge
3738
{
3839
parent:

gfx/layers/ipc/PCompositorManager.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ union CompositorBridgeOptions {
5959
* compositor thread for compositor data that is only shared once, rather than
6060
* per PCompositorBridge instance.
6161
*/
62-
[NeedsOtherPid]
62+
[NeedsOtherPid, ParentProc=compositor, ChildProc=anydom]
6363
sync protocol PCompositorManager
6464
{
6565
manages PCompositorBridge;

gfx/layers/ipc/PImageBridge.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace layers {
2626
* frames directly to the compositor thread/process without relying on the main thread
2727
* which might be too busy dealing with content script.
2828
*/
29-
[NeedsOtherPid]
29+
[NeedsOtherPid, ParentProc=compositor, ChildProc=anydom]
3030
sync protocol PImageBridge
3131
{
3232
manages PTexture;

gfx/layers/ipc/PUiCompositorController.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace layers {
2020
* compositor from the UI thread. Primarily used on Android to coordinate registering and
2121
* releasing the surface with the compositor.
2222
*/
23-
[NeedsOtherPid]
23+
[NeedsOtherPid, ParentProc=compositor, ChildProc=Parent]
2424
sync protocol PUiCompositorController
2525
{
2626

gfx/layers/ipc/PVideoBridge.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace layers {
2121
* The PVideoBridge protocol is used to share textures from the video decoders
2222
* to the compositor.
2323
*/
24-
[NeedsOtherPid]
24+
[NeedsOtherPid, ParentProc=compositor, ChildProc=any]
2525
sync protocol PVideoBridge
2626
{
2727
manages PTexture;

gfx/vr/ipc/PVR.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ include protocol PVRGPU;
1818
namespace mozilla {
1919
namespace gfx {
2020

21-
[NeedsOtherPid, ChildImpl="VRChild", ParentImpl="VRParent"]
21+
[NeedsOtherPid, ChildImpl="VRChild", ParentImpl="VRParent", ParentProc=VR, ChildProc=Parent]
2222
async protocol PVR
2323
{
2424
parent:

gfx/vr/ipc/PVRGPU.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace gfx {
1111

1212
// The parent process is the VR process.
1313
// The child process is the GPU process.
14-
[NeedsOtherPid, ChildImpl="VRGPUChild", ParentImpl="VRGPUParent"]
14+
[NeedsOtherPid, ChildImpl="VRGPUChild", ParentImpl="VRGPUParent", ParentProc=VR, ChildProc=GPU]
1515
async protocol PVRGPU
1616
{
1717
parent:

gfx/vr/ipc/PVRManager.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace gfx {
3434
* enumeration and sensor state between the compositor thread and
3535
* content threads/processes.
3636
*/
37-
[NeedsOtherPid, ChildImpl="VRManagerChild", ParentImpl="VRManagerParent"]
37+
[NeedsOtherPid, ChildImpl="VRManagerChild", ParentImpl="VRManagerParent", ParentProc=compositor, ChildProc=anydom]
3838
sync protocol PVRManager
3939
{
4040
manages PVRLayer;

ipc/docs/ipdl.rst

+62
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ one in ``PMyManager.ipdl``:
351351

352352
.. code-block:: cpp
353353
354+
[ChildProc=Content]
354355
sync protocol PMyManager {
355356
manages PMyManaged;
356357
@@ -406,6 +407,12 @@ They will be discussed further in `Nested messages`_.
406407
response.
407408
============================== ================================================
408409

410+
In addition, top-level protocols are annotated with which processes each side
411+
should be bound into using the ``[ParentProc=*]`` and ``[ChildProc=*]``
412+
attributes. The ``[ParentProc]`` attribute is optional, and defaults to the
413+
``Parent`` process. The ``[ChildProc]`` attribute is required. See `Process
414+
Type Attributes`_ for possible values.
415+
409416
The ``manages`` clause tells IPDL that ``PMyManager`` manages the
410417
``PMyManaged`` actor that was previously ``include`` d. As with any managed
411418
protocol, it must also be the case that ``PMyManaged.ipdl`` includes
@@ -730,7 +737,62 @@ for use in IPDL files:
730737
``Recv`` methods should be used instead of direct
731738
function calls. *New uses of this attribute are
732739
discouraged.*
740+
``[ChildProc=...]`` Indicates which process the child side of the actor
741+
is expected to be bound in. This will be release
742+
asserted when creating the actor. Required for
743+
top-level actors. See `Process Type Attributes`_
744+
for possible values.
745+
``[ParentProc=...]`` Indicates which process the parent side of the
746+
actor is expected to be bound in. This will be
747+
release asserted when creating the actor.
748+
Defaults to ``Parent`` for top-level actors. See
749+
`Process Type Attributes`_ for possible values.
750+
============================= =================================================
751+
752+
.. _Process Type Attributes:
753+
754+
Process Type Attributes
755+
^^^^^^^^^^^^^^^^^^^^^^^
756+
757+
The following are valid values for the ``[ChildProc=...]`` and
758+
``[ParentProc=...]`` attributes on protocols, each corresponding to a specific
759+
process type:
760+
733761
============================= =================================================
762+
``Parent`` The primary "parent" or "main" process
763+
``Content`` A content process, such as those used to host web
764+
pages, workers, and extensions
765+
``IPDLUnitTest`` Test-only process used in IPDL gtests
766+
``GMPlugin`` Gecko Media Plugin (GMP) process
767+
``GPU`` GPU process
768+
``VR`` VR process
769+
``RDD`` Remote Data Decoder (RDD) process
770+
``Socket`` Socket/Networking process
771+
``RemoteSandboxBroker`` Remote Sandbox Broker process
772+
``ForkServer`` Fork Server process
773+
``Utility`` Utility process
774+
============================= =================================================
775+
776+
The attributes also support some wildcard values, which can be used when an
777+
actor can be bound in multiple processes. If you are adding an actor which
778+
needs a new wildcard value, please reach out to the IPC team, and we can add one
779+
for your use-case. They are as follows:
780+
781+
============================= =================================================
782+
``any`` Any process. If a more specific value is
783+
applicable, it should be preferred where possible.
784+
``anychild`` Any process other than ``Parent``. Often used for
785+
utility actors which are bound on a per-process
786+
basis, such as profiling.
787+
``compositor`` Either the ``GPU`` or ``Parent`` process. Often
788+
used for actors bound to the compositor thread.
789+
``anydom`` Either the ``Parent`` or a ``Content`` process.
790+
Often used for actors used to implement DOM APIs.
791+
============================= =================================================
792+
793+
Note that these assertions do not provide security guarantees, and are primarily
794+
intended for use when auditing and as documentation for how actors are being
795+
used.
734796

735797

736798
The C++ Interface

ipc/glue/PBackground.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ using mozilla::camera::CamerasAccessStatus from "mozilla/media/CamerasTypes.h";
8080
namespace mozilla {
8181
namespace ipc {
8282

83-
[NeedsOtherPid, ChildImpl=virtual, ParentImpl=virtual]
83+
[NeedsOtherPid, ChildImpl=virtual, ParentImpl=virtual, ChildProc=anydom]
8484
sync protocol PBackground
8585
{
8686
manages PBackgroundIDBFactory;

ipc/glue/PBackgroundStarter.ipdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include protocol PBackground;
77
namespace mozilla {
88
namespace ipc {
99

10-
[NeedsOtherPid]
10+
[NeedsOtherPid, ChildProc=anydom]
1111
async protocol PBackgroundStarter
1212
{
1313
parent:

ipc/glue/PUtilityAudioDecoder.ipdl

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace ipc {
2121

2222
// This protocol allows to run media audio decoding infrastructure on top
2323
// of the Utility process
24+
[ParentProc=Utility, ChildProc=Parent]
2425
protocol PUtilityAudioDecoder
2526
{
2627
parent:

ipc/glue/PUtilityProcess.ipdl

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ namespace ipc {
4545
// one instance of this protocol, with the UtilityProcessParent living on the main thread
4646
// of the main process and the UtilityProcessChild living on the main thread of the Utility
4747
// process.
48-
[NeedsOtherPid] protocol PUtilityProcess
48+
[NeedsOtherPid, ChildProc=Utility]
49+
protocol PUtilityProcess
4950
{
5051
parent:
5152
async InitCrashReporter(NativeThreadId threadId);

ipc/glue/ProtocolUtils.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,13 @@ class IProtocol : public HasResultCodes {
309309

310310
// Called when IPC has acquired its first reference to the actor. This method
311311
// may take references which will later be freed by `ActorDealloc`.
312-
virtual void ActorAlloc() {}
312+
virtual void ActorAlloc() = 0;
313313

314314
// Called when IPC has released its final reference to the actor. It will call
315315
// the dealloc method, causing the actor to be actually freed.
316316
//
317317
// The actor has been freed after this method returns.
318-
virtual void ActorDealloc() {
319-
if (Manager()) {
320-
Manager()->DeallocManagee(mProtocolId, this);
321-
}
322-
}
318+
virtual void ActorDealloc() = 0;
323319

324320
static const int32_t kNullActorId = 0;
325321
static const int32_t kFreedActorId = 1;

0 commit comments

Comments
 (0)