Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /main /. /docs /linux /sandbox_ipc.md
blob: 66246ead3f1fc330b7c39342072ed30b8d91c56a [file] [log] [blame] [view]
andybonsad92aa32015-08-31 02:27:44[diff] [blame]1# Linux Sandbox IPC
andybons3322f762015-08-24 21:37:09[diff] [blame]2
andybonsad92aa32015-08-31 02:27:44[diff] [blame]3TheSandbox IPC systemis separatefrom the'main' IPC system.The sandbox IPC
4is a lower level system which dealswith caseswhere we need to route requests
5from the bottom of the call stack upinto the browser.
andybons3322f762015-08-24 21:37:09[diff] [blame]6
Dominik Röttschesac240042018-07-06 09:52:40[diff] [blame]7The motivating example used to beSkia, which uses fontconfig to load
8fonts.Howvever, the OOP IPCforFontConfig was moved tousingFontServiceand
9the`components/services/font/public/cpp/font_loader.h`interface.
10
11These days, only theout-of-process localtime implementationas wellas
12an OOP callfor making a shared memory segment areusing theSandbox IPC
13file-descriptor based system.See`sandbox/linux/services/libc_interceptor.cc`.
andybons3322f762015-08-24 21:37:09[diff] [blame]14
andybonsad92aa32015-08-31 02:27:44[diff] [blame]15Thus we define a small IPC system which doesn't depend on anything but `base`
16and which can make synchronous requests to the browser process.
andybons3322f762015-08-24 21:37:09[diff] [blame]17
Tom Anderson93e49e492019-12-23 19:55:37[diff] [blame]18The [zygote](zygote.md) starts with a `UNIX DGRAM` socket installed in a
andybonsad92aa32015-08-31 02:27:44[diff] [blame]19well known file descriptor slot (currently 4). Requests can be written to this
20socket which are then processed on a special "sandbox IPC" process. Requests
21have a magic `int` at the beginning giving the type of the request.
andybons3322f762015-08-24 21:37:09[diff] [blame]22
andybonsad92aa32015-08-31 02:27:44[diff] [blame]23All renderers share the same socket, so replies are delivered via a reply
24channel which is passed as part of the request. So the flow looks like:
25
261. The renderer creates a `UNIX DGRAM` socketpair.
271. The renderer writes a request to file descriptor 4 with an `SCM_RIGHTS`
28 control message containing one end of the fresh socket pair.
291. The renderer blocks reading from the other end of the fresh socketpair.
301. A special "sandbox IPC" process receives the request, processes it and
31 writes the reply to the end of the socketpair contained in the request.
321. The renderer wakes up and continues.
33
34The browser side of the processing occurs in
35`chrome/browser/renderer_host/render_sandbox_host_linux.cc`. The renderer ends
36could occur anywhere, but the browser side has to know about all the possible
37requests so that should be a good starting point.
andybons3322f762015-08-24 21:37:09[diff] [blame]38
39Here is a (possibly incomplete) list of endpoints in the renderer:
40
Dominik Röttschesac240042018-07-06 09:52:40[diff] [blame]41### localtime
andybons3322f762015-08-24 21:37:09[diff] [blame]42
Dominik Röttschesac240042018-07-06 09:52:40[diff] [blame]43`content/browser/sandbox_ipc_linux.h` defines HandleLocalTime which is
44implemented in `sandbox/linux/services/libc_interceptor.cc`.
andybons3322f762015-08-24 21:37:09[diff] [blame]45
Dominik Röttschesac240042018-07-06 09:52:40[diff] [blame]46### Creating a shared memory segment
andybons3322f762015-08-24 21:37:09[diff] [blame]47
Dominik Röttschesac240042018-07-06 09:52:40[diff] [blame]48`content/browser/sandbox_ipc_linux.h` defines HandleMakeSharedMemorySegment
49which is implemented in `content/browser/sandbox_ipc_linux.cc`.

[8]ページ先頭

©2009-2025 Movatter.jp