ModemIsolationResearch » History » Version 43

Denis 'GNUtoo' Carikli, 10/20/2019 07:55 PM

1 18 Denis 'GNUtoo' Carikli
h1. Modem shared memory
2 1 Denis 'GNUtoo' Carikli
3 17 Denis 'GNUtoo' Carikli
This section documents in more details the architecture of system on a chip and devices that have shared memory between the modem and the processor running Android. Since the modem runs (only) proprietary software, devices that doesn't have any mechanism that prevent the modem from taking control of the processor running Android are a grave concern for users freedom ans security.
4 4 Denis 'GNUtoo' Carikli
5 17 Denis 'GNUtoo' Carikli
This section focuses on that issue. Some Qualcomm System On a Chip that are affected by this issue also have other issues that aren't mentioned here but in [[Qualcomm_SOCs|the Qualcomm System On a Chip page]].
6 4 Denis 'GNUtoo' Carikli
7 5 Denis 'GNUtoo' Carikli
Documenting the issue more in depth might allow us to understand if some devices with shared memory between the modem and the processor running Android might be able to be used safely.
9 15 Denis 'GNUtoo' Carikli
h2. Requirements
11 16 Denis 'GNUtoo' Carikli
Having the modem and the processor running Android in separate chip, connected through a bus (like USB) that doesn't allow the modem to access the Android processor's memory offers pretty good guarantee that the modem cannot take the control of the processor running Android at a hardware level. 
When the modem and the Android processor are in the same chip or when they use shared memory to communicate, and that memory is also used by the processor operating system, such guarantees are gone.
13 15 Denis 'GNUtoo' Carikli
14 16 Denis 'GNUtoo' Carikli
Several hardware mechanism that can bring them back exist:
15 15 Denis 'GNUtoo' Carikli
* Some smartphones manufacturer could connect the modem to the processor running Android with separate dedicated memory that is not used for things other than enabling them to communicate.
* IOMMUs are hardware dedicated to prevent peripherals (like a modem) from taking control of the processor (that is here running Android). To have enough guarantee, such hardware should have good technical documentation and the code using it should have good peer review (It should be good enough if it is in upstream Linux).
18 6 Denis 'GNUtoo' Carikli
h2. System on a chip
This lists system on a chip that also Include a modem and have shared memory between the modem and the processor running Android, and the way the modem and the processor running Android are isolated or not.
21 1 Denis 'GNUtoo' Carikli
22 13 Denis 'GNUtoo' Carikli
|_. Vendor |_. System on a chip |_. Isolation |_. Market share |_. References |
23 2 Denis 'GNUtoo' Carikli
| Qualcomm | Mobile Station Modem (MSM) Snapdragon 7x30 | Bad:
24 3 Denis 'GNUtoo' Carikli
* The modem is in charge of loading the bootloader of the processor running Android. Because of that it can temper with that bootloader and take control of the processor running Android.
* The modem can access the memory of the processor running Android, and can take control of it through that way.
* The modem has access to the storage of the processor running Android, so it can take control of it through that.
27 13 Denis 'GNUtoo' Carikli
| ? | "boot process": |
28 14 Denis 'GNUtoo' Carikli
| Qualcomm | Snapdragon S4 | Unknown:
* The modem is booted by the processor running Android (which in turn is booted by a separate boot processor called RPM)
* There is not enough public documentation to understand if there is enough isolation between the modem and the processor running android.
 | ? |
32 10 Denis 'GNUtoo' Carikli
*"Boot process":
33 13 Denis 'GNUtoo' Carikli
*"The Security of chip fabric page of rpw-pacsec2013-hexagon.pdf": |
34 7 Denis 'GNUtoo' Carikli
h2. Devices
This lists devices that have the modem and the processor running Android in separate chips and use shared memory between them, along with the way the processor running Android is isolated from the modem, or not.
39 9 Denis 'GNUtoo' Carikli
|_. Vendor |_. Device |_. Isolation |_. References |
40 7 Denis 'GNUtoo' Carikli
| Samsung | Nexus S | ? | ? |
| Samsung | Galaxy S | ? | ? |
42 19 Denis 'GNUtoo' Carikli
h1. Isolated modems
h2. Supported devices
47 23 Denis 'GNUtoo' Carikli
|_. Vendor |_. Device |_. Link |_. Isolation |_. References |
48 39 Denis 'GNUtoo' Carikli
|/8. Samsung | Galaxy Nexus (I9250) |/3. MIPI |/3. * With MIPI it's most probably not possible for the peripheral to access the host RAM | * "board-tuna.c:":
49 22 Denis 'GNUtoo' Carikli
        if (TUNA_TYPE_MAGURO == omap4_tuna_get_type())
52 1 Denis 'GNUtoo' Carikli
53 22 Denis 'GNUtoo' Carikli
54 23 Denis 'GNUtoo' Carikli
55 1 Denis 'GNUtoo' Carikli
* "modem_link_device_mipi.c": |
56 39 Denis 'GNUtoo' Carikli
| Galaxy Tab 2 7.0 (P31xx) |/2. * "espresso_defconfig:": CONFIG_LINK_DEVICE_MIPI=y |
| Galaxy Tab 2 10.1 (P51xx) |
58 37 Denis 'GNUtoo' Carikli
| Galaxy S 3 (I9300) |/5. HSIC |/5. * HSIC is a subset of the USB protocol  => the peripheral has no access to the host RAM
59 36 Denis 'GNUtoo' Carikli
* The device cannot change USB IDs "without the host powering up and down the bus":
60 37 Denis 'GNUtoo' Carikli
|/5. * "lineageos_i9300_defconfig:": CONFIG_MODEM_M0
* "lineageos_i7000_defconfig:": CONFIG_LINK_DEVICE_HSIC=y
62 35 Denis 'GNUtoo' Carikli
* "lineageos_i7100_defconfig:": CONFIG_MODEM_M0
63 1 Denis 'GNUtoo' Carikli
* "lineageos_i5100_defconfig:": CONFIG_MODEM_M0
64 33 Denis 'GNUtoo' Carikli
* "lineageos_i9100_defconfig:": CONFIG_LINK_DEVICE_HSIC=y
65 36 Denis 'GNUtoo' Carikli
* "board-m0-modems.c": |
66 37 Denis 'GNUtoo' Carikli
| Galaxy Note (N7000) |
| Galaxy Note 2 (N7100) |
68 34 Denis 'GNUtoo' Carikli
| Galaxy Note 8.0 (N51xx) |
| Galaxy S 2 (I9100) |
70 40 Denis 'GNUtoo' Carikli
h2. Powering off the modem
73 42 Denis 'GNUtoo' Carikli
h3. Android airplane mode interface
74 40 Denis 'GNUtoo' Carikli
The "RIL_REQUEST_RADIO_POWER command": is used by the airplane mode.
77 42 Denis 'GNUtoo' Carikli
h3. current libsamsung-ril and libsamsung-ipc implementation
78 1 Denis 'GNUtoo' Carikli
"In libsamsung-ril, RIL_REQUEST_RADIO_POWER": is implemneted in the "ril_request_radio_power": function which doesn't turn off the modem but asks it not to transmit by asking it to go in low power mode. This looks very similar to the AT command AT+CFUN.
80 42 Denis 'GNUtoo' Carikli
h3. Better implementation
The airplane mode could be implemented in another way where the modem is powered off. The advantage of using the airplane mode for that is that it's already implemented in the Android GUI.
We would also need to explain users that we implemented it this way, but that other Android distributions might have different implementations as their goal might differ. Doing again a full modem bootstrap will take longer than just asking the modem to go out of low power mode.
86 43 Denis 'GNUtoo' Carikli
To do that we would need to understand what exactly the kernel modem power off interface do in hardware, and look at the kernel APIs that could be used to do that.
On Replicant 9, at the time of writing a GPIO interface (/sys/devices/platform/xmm6262/modem_power) is available for that, but we would need to look deeper into it to understand what it does exactly at the hardware level. That interface may change when the modem drivers are modified, for instance during the work to mainline them.
On Samsung kernel, the interface is different but probably expose the same hardware controls but in a different way.
At this point, libsamsung-ipc will need to be modified to use such interfaces instead.
Libsamsung-ipc and libsamsung-ril might also need to be modified to take into account the fact that the modem needs to be re-bootstraped again.