Commit graph

56804 commits

Author SHA1 Message Date
David Anderson
b78a632ab7 init: Remove special-case hacks for the super partition.
Rather than special-casing super in the uevent listener, call Realpath()
after we've generated its symlink. This allows us to generalize the
uevent listener code.

Also, rename "metadata partition" to "super partition" in a few places,
as this terminology is a bit dated.

Bug: 150315914
Test: first-stage init boots
Change-Id: I2bf3bebf3360f097582df7fba95f3c1753feb2e2
2020-03-20 19:48:46 -07:00
Treehugger Robot
3ab681c9a8 Merge "fastboot: add support for v3 boot header format" 2020-03-19 05:47:48 +00:00
Kazuhiro Inaba
f98ee05a17 Merge "healthd: Don't take device-scoped battery as the main system battery." 2020-03-19 04:40:01 +00:00
Ryan Mitchell
ed22a0aa70 Merge "Allow loading zip at an offset in fd" 2020-03-18 23:00:52 +00:00
Steve Muckle
15303f2f67 fastboot: add support for v3 boot header format
Support v3 header format when changing the command line with
fastboot boot or using flash:raw.

Bug: 151750405
Test: fastboot boot and flash:raw with updated cmdline and v3 header
Change-Id: Ibf396e2d18d8b22cad50db290f3fd4e46ff85d9b
2020-03-18 15:00:47 -07:00
Ryan Mitchell
23150e4fe4 Allow loading zip at an offset in fd
To allow the ResourcesLoader API to load part of a file as an APK
that contains resources, an additional override of OpenArchiveFd
that contains read offset and length as parameters must be created.

This functionality allows for an APK stored in a zip file to be read
without having to write the APK to disk.

Bug: 142716192
Test: atest FrameworksResourceLoaderTests
Change-Id: I772fc8b462d71de0529717c420ced552103a6e3f
Merged-In: I772fc8b462d71de0529717c420ced552103a6e3f
2020-03-18 20:46:50 +00:00
Tom Cherry
b33afa9d8d Merge "storaged: ignore SIGPIPE" 2020-03-18 18:50:57 +00:00
Treehugger Robot
cdb6003784 Merge "base: dlopen/dlsym for liblog when SDK_VER <= 29" 2020-03-18 16:05:54 +00:00
Jooyung Han
2d954136fa base: dlopen/dlsym for liblog when SDK_VER <= 29
libbase doesn't have to rely on dlopen/dlsym to use liblog's new symbols
when it is built for __ANDROID_SDK_VERSION__ > 29.

Bug: 150860940
Test: TARGET_BUILD_APPS="com.android.adbd com.android.resolv" m
      objdump -T ...shared_com.android.resolv/libbase.so | grep LIBLOG_R
        => should be none because resolv apex is targeting 29
      objdump -T ...shared_com.android.adbd/libbase.so | grep LIBLOG_R
        => should list all new symbols because adbd apex is targeting R
      objdump -T ...shared/libbase.so | grep LIBLOG_R
        => should list all new symbols

Merged-In: I7f7f16510d7637cd380fe35ea9ff3e804f38851d
Change-Id: I7f7f16510d7637cd380fe35ea9ff3e804f38851d
(cherry picked from commit 22207e6590)
2020-03-18 17:42:41 +09:00
Treehugger Robot
b962d6bee5 Merge "libziparchive: move the array of error strings into the implementation." 2020-03-17 23:25:45 +00:00
Elliott Hughes
bda268636a libziparchive: move the array of error strings into the implementation.
Test: treehugger
Change-Id: Iaffc29f77912d268c3335b74eb712a58914ce945
2020-03-17 14:10:59 -07:00
Steven Moreland
df78c43412 Merge "init: init_kill_services_test" 2020-03-17 20:30:49 +00:00
Tianjie Xu
780528e86b Merge "Move the implementation of cd entry map to a separate file" 2020-03-17 19:00:36 +00:00
Tianjie Xu
f496d286c6 Merge "Add std::map implementation for cd entry map" 2020-03-17 19:00:23 +00:00
Steven Moreland
6cce3f7f90 init: init_kill_services_test
Kill processes and make sure the phone recovers. This adds a basic level
of testing, but it could be improved by:
- trying to kill all running processes on the device
- improving metrics for 'recovery'

Bug: 148236233
Test: init_kill_services_test
Change-Id: I8aaca7bf4bb0be588decf741d1f6e1c5787cea84
2020-03-17 10:58:02 -07:00
Tom Cherry
3f3b1708d9 storaged: ignore SIGPIPE
It is possible for storaged to terminate due to SIGPIPE if its clients
have terminated.  This is not a fatal condition from storaged's
perspective, so we ignore SIGPIPE instead.

Bug: 151581751
Test: build
Change-Id: I633780ed20908be02e5e1dea9504e140932afc8c
2020-03-17 09:31:01 -07:00
Tianjie Xu
323c09c3d0 Move the implementation of cd entry map to a separate file
Move the entry map classes to a separate file to make the hierarchy
clear.

Test: unittests pass
Change-Id: Ie01d7835359daa4f59af75a0eda204c696d5658e
2020-03-16 17:43:49 -07:00
David Anderson
8a178c184f Merge "init: Fix restorecon for /metadata." 2020-03-16 23:40:16 +00:00
Tianjie Xu
0ef9783c57 Add std::map implementation for cd entry map
Add the std::map implementation to be used later in zip64 format.
Also move the entry map classes to a separate file to make the hierarchy
clear.

Test: unittests pass
Change-Id: I74d95f53207cc8ca871b955e2a15c184d5497833
2020-03-16 15:42:22 -07:00
Treehugger Robot
cb76bf0558 Merge "adbd: shrink libadbd.so, libadbd_services.so." 2020-03-16 21:05:28 +00:00
Tom Cherry
4a02b23d92 Merge "init: use a no-op signal handler instead of SIG_IGN for SIGPIPE" 2020-03-16 19:22:34 +00:00
Josh Gao
c151a1ba28 adbd: shrink libadbd.so, libadbd_services.so.
We were ending up with multiple copies of the proto runtime in the
recovery image, when we need zero.

Before:
    784K	recovery/root/system/lib64/libadbd_services.so
    832K	recovery/root/system/lib64/libadbd.so

After:
    360K	recovery/root/system/lib64/libadbd_services.so
    344K	recovery/root/system/lib64/libadbd.so

Bug: http://b/150317254
Test: treehugger
Change-Id: I39fbb3959128994f0de2ae0ea47dbc0800c516fe
2020-03-16 11:30:09 -07:00
Tom Cherry
fd470e87cc init: use a no-op signal handler instead of SIG_IGN for SIGPIPE
We want to ignore SIGPIPE within init, but if we use SIG_IGN, that
would be inherited by child processes through exec(), which we do not
want to have happen.  We instead set up a real signal handler with a
no-op handler function, that will ignore SIGPIPE within init, but will
not be inherited across exec().

This fixes c29c2baa69 ("init: Add support for native service
registration with lmkd"), when SIG_IGN was introduced.
Note that we caught this issue before shipping a release with that
change, so the major motivation here is to not cause a behavior change
in init.

Bug: 151581751
Test: children of init that don't explicitly block SIGPIPE exit when
      sent SIGPIPE
Test: children of init that do explicitly block SIGPIPE do not exit
      when sent SIGPIPE
Test: init does not exit when sent SIGPIPE
Test: init exits when sent SIGABRT
Change-Id: Ieda8555fd03836bcd672a422fe673a8369ad9beb
2020-03-16 10:31:34 -07:00
Kazuhiro Inaba
8e4d982d52 healthd: Don't take device-scoped battery as the main system battery.
Some devices expose the battery state of stylus etc in sysfs,
in addition to the whole system's main battery. Android only
recognizes the first battery enumerated here. We need to
filter out such HID-specific battery to let Android correctly
monitor the main battery status.

Bug: 136111013
Test: CtsBatterySavingTestCases on arcada
Change-Id: I4cbf6e3bf883fb3d107bedd2849d8ad525538629
2020-03-16 12:50:42 +09:00
Treehugger Robot
01c8eccca3 Merge "Restore fastboot delete-logical-partition command for VTS" 2020-03-15 22:28:34 +00:00
Tom Cherry
a0702789d5 Merge "init: handle property messages asynchronously #2" 2020-03-13 20:30:14 +00:00
Tom Cherry
c74afeaa8b Merge changes Id67203bb,I0c1dd57f
* changes:
  liblog: move LOG_ID_DEFAULT into the log_id enum
  liblog: use int32_t and uint32_t for new NDK APIs
2020-03-13 16:10:35 +00:00
Tom Cherry
cd61376986 Merge "liblog: fix header guards ordering" 2020-03-13 15:48:19 +00:00
Elliott Hughes
4fe694a9c1 Merge "adb: support wait-for- with multiple states." 2020-03-13 15:19:34 +00:00
Tom Cherry
802864c782 init: handle property messages asynchronously #2
A previous change moved property_service into its own thread, since
there was otherwise a deadlock whenever a process called by init would
try to set a property.  This new thread, however, would send a message
via a blocking socket to init for each property that it received,
since init may need to take action depending on which property it is.
Unfortunately, this means that the deadlock is still possible, the
only difference is the socket's buffer must be filled before init deadlocks.

This change, therefore, adds the following:
1) A lock for instructing init to reboot
2) A lock for waiting on properties
3) A lock for queueing new properties

A previous version of this change was reverted and added locks around
all service operations and allowed the property thread to spawn
services directly.  This was complex due to the fact that this code
was not designed to be multi-threaded.  It was reverted due to
apparent issues during reboot.  This change keeps a queue of processes
pending control messages, which it will then handle in the future.  It
is less flexible but safer.

Bug: 146877356
Bug: 148236233
Bug: 150863651
Bug: 151251827
Test: multiple reboot tests, safely restarting hwservicemanager
Change-Id: Ice773436e85d3bf636bb0a892f3f6002bdf996b6
2020-03-12 17:15:07 -07:00
Eric Biggers
e7f014da9c Merge "init.rc: disable kernel module autoloading" 2020-03-12 21:19:38 +00:00
Yifan Hong
6ae132fd10 Merge "Add OptimizeSourceCopyOperation" 2020-03-12 20:44:24 +00:00
Elliott Hughes
86f83cf41e Merge "Remove mips pixelflinger." 2020-03-12 18:43:12 +00:00
Tom Cherry
6085cd5a64 liblog: move LOG_ID_DEFAULT into the log_id enum
As requested during the API review.

Bug: 150898477
Test: liblog and libbase unit tests
Change-Id: Id67203bbfbc3e116b6b6efd40428afe48203dcfc
2020-03-12 11:14:19 -07:00
Tom Cherry
f1a975bece liblog: use int32_t and uint32_t for new NDK APIs
As requested during the API review.

Bug: 150898477
Test: liblog and libbase unit tests
Change-Id: I0c1dd57f7499e432bb881e1da1beb55f1ff7de05
2020-03-12 11:11:24 -07:00
Tom Cherry
227ac56454 liblog: fix header guards ordering
__ANDROID_API__ isn't defined on host, so this check will fail due to
-Wundef.  The || is short circuited through, so we can check for host
first and only have the right side of the || evaluated for device
builds.

Bug: 150898477
Bug: 151255209
Test: build
Change-Id: I2e0bc055ac0c7ba8262875801cdaed9cc30d2cef
2020-03-12 09:37:05 -07:00
Treehugger Robot
133df17ea1 Merge "libfs_mgr_binder: Cleanup GetGsiService()" 2020-03-12 03:37:52 +00:00
Treehugger Robot
b407502c98 Merge "Make libselinux a stub library" 2020-03-12 02:57:14 +00:00
Jiyong Park
3ffdad0cb5 Make libselinux a stub library
libselinux is currently being copied to APEXes. This is risky because
the library is not designed to be portable; part of it is tied to the
specific version of the Android that it was developed for.

This change fixes the problem by declaring that the library supports
a stub with the list of C APIs that are included in the stub. Then there
is only one copy of libselinux in /system/lib and other APEXes use the
copy by dynamically linking to it.

Also, adbd no longer statically links to it, because doing so brings
libselinux in it.

Bug: 151053366
Test: m com.android.adbd. It doesn't include libselinux in it.
Test: m com.android.adbd-deps-info. then inspect
out/soong/com.android.adbd-deps-info.txt. The dependency to libselinux
is shown as '(external)'.

Change-Id: If418cbe3abdeacb759d59052e6dca4c2067678dd
2020-03-12 00:02:18 +00:00
Treehugger Robot
2442e64416 Merge "adb: Avoid a couple std::string constructions" 2020-03-11 23:29:40 +00:00
Nikita Ioffe
34ae0c58d2 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" 2020-03-11 21:29:31 +00:00
Treehugger Robot
8aeada63f2 Merge "run ext4 tools in first_stage_ramdisk" 2020-03-11 20:04:50 +00:00
Nikita Ioffe
17824f0590 fs_mgr_get_mounted_entry_for_userdata: handle logical partitions
In case of GSI on DSU, /data is mounted on the following stack:
userdata -> userdata_gsi -> actual block device, and fstab returned from
ReadDefaultFstab() function will say that /data should be
mounted onto userdata_gsi. This configuration wasn't supported.

To support it, fs_mgr_get_mounted_entry_for_userdata now unwinds the
dm-device stack /data is mounted onto, and for each entry in fstab
resolves corresponding block device (in case of logical partitions by
asking DeviceMapper to resolve name -> path, and for other cases by
reading a symlink), and then checking whenever resolved block device
belongs to the unwinded stack.

Test: on both normal boot & DSU
Test: atest CtsUserspaceRebootHostSideTestCases
Test: atest CtsFsMgrTestCases
Bug: 148612148
Change-Id: I1bb3e64ae92d56de905b4f7f1997b7499b101b0f
Merged-In: I1bb3e64ae92d56de905b4f7f1997b7499b101b0f
(cherry picked from commit f495fe798b)
2020-03-11 19:21:37 +00:00
Yifan Hong
dee5225b6c Add OptimizeSourceCopyOperation
... so that an operation can be skipped partially. For example, if
an operation contains blocks:
    563412 -> 123456
... then optimized operation is:
    5612 -> 1256

Test: update_engine_unittests
Test: apply incremental OTA
Bug: 148623880

In an experiment, this reduces CoW size of an incremental update
package by 200MB (out of 700MB).

Change-Id: I86ca23fd589ddbc84c81318283b5f4e71782a759
2020-03-11 12:10:32 -07:00
Eric Biggers
843f46e674 init.rc: disable kernel module autoloading
There is a longstanding bug where file-based encryption causes spurious
SELinux denials of module_request because it uses the kernel's crypto
API, and the crypto API tries to autoload kernel modules.

While this sometimes indicate missing kconfig options, it can still
happen even if all needed kconfig options are enabled.  This is because
a crypto algorithm can be a composition like "hmac(sha512)", and the
crypto API will first look for the full composition before it
instantiates it using the components like "hmac" and "sha512".  But
often an implementation of the full composition doesn't exist.

However, as far as I can tell, Android doesn't actually use kernel
module autoloading at all.  First, Android never changes
/proc/sys/kernel/modprobe from the default of "/sbin/modprobe", yet this
isn't where modprobe is located on Android.  Android's SELinux policy
contains a neverallow rule that ensures that only init (not even
vendor_init) can write to this setting, so vendors can't be changing it.

Vendors could potentially be setting CONFIG_STATIC_USERMODEHELPER_PATH,
which overrides the path of all usermode helpers including modprobe.
But this is a relatively new kconfig option, available only in
android-4.14 and later.  Also, for a vendor to actually do this they'd
also need to extend the SELinux policy with a domain_auto_trans rule to
allow their usermode helper to be executed by the kernel.

Android does increasingly use kernel modules, and GKI (Generic Kernel
Image) will require them.  However, the modules are actually inserted by
userspace by 'init', not autoloaded.

It's possible to disable kernel module autoloading completely by setting
/proc/sys/kernel/modprobe to an empty string.  So, let's do that.

This prevents lots of spurious SELinux denials, and allows removing
unnecessary rules to allow or dontaudit the module_request permission.

Note: when the kernel doesn't have CONFIG_ANDROID_BINDERFS enabled, this
change exposes a kernel bug that causes a WARNING in get_fs_type().  To
avoid this WARNING, a kernel fix should be applied too -- currently
under discussion upstream
(https://lkml.kernel.org/r/20200310223731.126894-1-ebiggers@kernel.org).

Bug: 130424539
Bug: 132409186
Bug: 144399145
Bug: 146477240
Bug: 148005188
Bug: 149542343

Test: Tested on cuttlefish and coral:

    - Checked that /proc/sys/kernel/modprobe contains /sbin/modprobe
      before this change, and the empty string after.

    - Checked that if all SELinux rules for module_request are removed,
      there are SELinux denials for module_request before this change
      but none after.

    - Ran lsmod both before and after and verified that the list is the
      same, i.e. checked that this change doesn't break how Android
      actually loads kernel modules.

Change-Id: I4132fe1a491e7b789311afcf693c1f6493fb9dc5
2020-03-11 10:01:32 -07:00
Jaegeuk Kim
b9be427848 run ext4 tools in first_stage_ramdisk
Bug: 149039306
Change-Id: I646960baa3c0d5a0dedda82b1fdc3816321aaa2e
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2020-03-11 09:33:51 -07:00
Greg Kaiser
edfec96679 adb: Avoid a couple std::string constructions
With some internal API changing from "const char*" to
"const std::string&", we can change a couple calling sites to
directly pass a std::string reference, instead of getting the
c_str() version of the string.  This avoids us creating a
temporary std::string for the call.

Test: TreeHugger
Change-Id: I2fe0760ce8bf7d352010a341005356c0a801d351
2020-03-11 07:07:55 -07:00
Yo Chiang
bef044a46a libfs_mgr_binder: Cleanup GetGsiService()
GetGsiService() is defined in libgsid, let libfs_mgr_binder link to
libgsid instead of duplicating the logic.

Test: Build and boot
Change-Id: I28d0c92b432a53770a3bdc5f4c5cd91e3466151c
2020-03-11 18:35:51 +08:00
Jiyong Park
f1e27502e4 Merge "don't include liblog to APEXes" 2020-03-11 09:20:24 +00:00
Jiyong Park
95b6f45b0e don't include liblog to APEXes
liblog is a platform library that provides stable C API. There is no
need to include the library, especialy by statically linking to it, in
any APEX. It not only wastes the storage/ram, but also is incorrect
because the socket interface to logd which is implemented in liblog is
not guaranteed to be stable.

Fixing this issue by converting static_libs: ["liblog"] into
shared_libs: ["liblog"], in which case the dependency to the library
is satisfied via the stub variant of the library.

As a result, we could restrict the availablity of the library to
the platform and the runtime APEX.

Exempt-From-Owner-Approval: already approved when this was in internal
master (ag/10572699)

Bug: http://b/151051671
Bug: http://b/150827719
Test: m
Change-Id: I5aab863cb12b8767b6979255c247000a59355b0e
2020-03-11 09:20:08 +00:00