Commit graph

56844 commits

Author SHA1 Message Date
Automerger Merge Worker
c5aca531a5 Merge "init: Fix restorecon for /metadata." am: 8a178c184f
Change-Id: I69af5d614fb92522c301249289ac60867df8370a
2020-03-17 00:00:59 +00:00
David Anderson
8a178c184f Merge "init: Fix restorecon for /metadata." 2020-03-16 23:40:16 +00:00
Automerger Merge Worker
e7d5ae30c6 Merge "adbd: shrink libadbd.so, libadbd_services.so." am: cb76bf0558
Change-Id: I4546c84bfcff6a43ba5f94558d69aeea084003d3
2020-03-16 21:25:10 +00:00
Treehugger Robot
cb76bf0558 Merge "adbd: shrink libadbd.so, libadbd_services.so." 2020-03-16 21:05:28 +00:00
Automerger Merge Worker
e7033d9c6d Merge "init: use a no-op signal handler instead of SIG_IGN for SIGPIPE" am: 4a02b23d92
Change-Id: I6850984f0796c371e70c5c0fad1570bf7522dc1f
2020-03-16 19:37:32 +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
Automerger Merge Worker
cabb934d41 Merge "Restore fastboot delete-logical-partition command for VTS" am: 01c8eccca3
Change-Id: I6667ecf7dafc16f800ca5d5bbb0908ec024a040c
2020-03-15 22:44:06 +00:00
Treehugger Robot
01c8eccca3 Merge "Restore fastboot delete-logical-partition command for VTS" 2020-03-15 22:28:34 +00:00
Automerger Merge Worker
38d2c7709a Merge "init: handle property messages asynchronously #2" am: a0702789d5
Change-Id: I9b9a21d5eb365fb7383cb45354d63f43d5d0fe31
2020-03-13 20:48:12 +00:00
Tom Cherry
a0702789d5 Merge "init: handle property messages asynchronously #2" 2020-03-13 20:30:14 +00:00
Automerger Merge Worker
b9b4a4489d Merge changes Id67203bb,I0c1dd57f am: c74afeaa8b
Change-Id: Ia0599ca98ff5e7914e1ccad0a148e6bc2628b8e0
2020-03-13 16:27:57 +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
Automerger Merge Worker
8493f16832 Merge "liblog: fix header guards ordering" am: cd61376986
Change-Id: I060d05016fe048c7f643f30f62f476ac190dd846
2020-03-13 16:03:13 +00:00
Tom Cherry
cd61376986 Merge "liblog: fix header guards ordering" 2020-03-13 15:48:19 +00:00
Automerger Merge Worker
a13edaac4e Merge "adb: support wait-for- with multiple states." am: 4fe694a9c1
Change-Id: Icd22ce47af70439a3ab3d28006e8a777585937ed
2020-03-13 15:30:59 +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
Automerger Merge Worker
0cef47636d Merge "init.rc: disable kernel module autoloading" am: e7f014da9c
Change-Id: I2b83cdd3d121a3633a26157a4087f9a56f195121
2020-03-12 21:39:22 +00:00
Eric Biggers
e7f014da9c Merge "init.rc: disable kernel module autoloading" 2020-03-12 21:19:38 +00:00
Automerger Merge Worker
a5876cd674 Merge "Add OptimizeSourceCopyOperation" am: 6ae132fd10
Change-Id: Ib571e6e82731ad7cf9a4c8cedf3329470ed12853
2020-03-12 21:04:40 +00:00
Yifan Hong
6ae132fd10 Merge "Add OptimizeSourceCopyOperation" 2020-03-12 20:44:24 +00:00
Automerger Merge Worker
e7524d43a5 Merge "Remove mips pixelflinger." am: 86f83cf41e
Change-Id: Ie848b0f6edff90f1f393e255efe93c78c9636a0d
2020-03-12 18:58:21 +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
Automerger Merge Worker
30f22b376f Merge "libfs_mgr_binder: Cleanup GetGsiService()" am: 133df17ea1
Change-Id: Ibb4c01a854c8c762e93188be7ff7d66d7894e1e9
2020-03-12 03:56:21 +00:00
Treehugger Robot
133df17ea1 Merge "libfs_mgr_binder: Cleanup GetGsiService()" 2020-03-12 03:37:52 +00:00
Automerger Merge Worker
9281e97450 Merge "Make libselinux a stub library" am: b407502c98
Change-Id: I7145d1c9cfc35b40bdeb4dfa402cc953e4cd1985
2020-03-12 03:09:59 +00:00
Treehugger Robot
b407502c98 Merge "Make libselinux a stub library" 2020-03-12 02:57:14 +00:00
Automerger Merge Worker
c2d303231d Merge "adb: Avoid a couple std::string constructions" am: 2442e64416
Change-Id: I6e89af8ee9133c03978f3fa543c0b777a5080402
2020-03-12 00:25:53 +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
Automerger Merge Worker
203a724070 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" am: 34ae0c58d2
Change-Id: I37ddf7e2da1291bc9f042f675bb19e480ec1020a
2020-03-11 21:53:28 +00:00
Nikita Ioffe
34ae0c58d2 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" 2020-03-11 21:29:31 +00:00
Automerger Merge Worker
441f9aa043 Merge "run ext4 tools in first_stage_ramdisk" am: 8aeada63f2
Change-Id: Ice6ac1eeab966e4162fa3efbfcc47d757b1b3817
2020-03-11 20:29:16 +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
Automerger Merge Worker
872aeede04 Merge "don't include liblog to APEXes" am: f1e27502e4
Change-Id: Ic29e1b7672cd4a33de5c0f925c1c353206679771
2020-03-11 09:41:24 +00: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
Automerger Merge Worker
350aa9e6cf Merge changes from topic "liblog" am: ac72606f98
Change-Id: I9dfd4685f04fffaad79908d20d7e8104bc104011
2020-03-11 08:16:48 +00:00
Automerger Merge Worker
04e8075418 libbase uses liblog symbols via dlsym when it is built for APEX am: 2c608b32db
Change-Id: I6763e2b02e367006e7791c0b4cb326fc3c64243f
2020-03-11 08:16:46 +00:00