Commit graph

56780 commits

Author SHA1 Message Date
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
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
Jiyong Park
ac72606f98 Merge changes from topic "liblog"
* changes:
  Whole static link libasync_safe to libbacktrace.a
  libbase uses liblog symbols via dlsym when it is built for APEX
2020-03-11 07:55:40 +00:00
Jiyong Park
cc26bbd232 Whole static link libasync_safe to libbacktrace.a
When libbacktrace.a is statically lined to somewhere, that library had
to add libasync_safe.a to static_libs because libbacktrace.a has
references to libasync_safe.a. But libbacktace depending on
libasync_safe is an implementation detail of libbacktrace, and therefore
its client shouldn't be affected by it.

Fixing this by doing the whole static link to libasync_safe to
libbacktrace.a so that the former is included in libbacktrace.a

Exempt-From-Owner-Approval: cherry-pick rvc-dev

Bug: 149569129
Test: m
Merged-In: If7366a240bc945dda9944fe7c111e10d328165bb
(cherry picked from commit 7c8e2b247d)
Change-Id: If7366a240bc945dda9944fe7c111e10d328165bb
2020-03-11 07:55:23 +00:00
Jiyong Park
2c608b32db libbase uses liblog symbols via dlsym when it is built for APEX
libbase is a popular library that is used by many APEXes either directly
or transitively. It is being used by several Mainline modules that were
launched with Q, in which case everything in the APEX - including
libbase - shouldn't use new APIs that are added post Q, i.e. R.

libbase however is using a few new R symbols from liblog, and this is
preventing those Q-launching Mainline modules that are built in R source
tree from being installed to Q devices.

Fortunately, the dependencies to the new R symbols are guarded with a
flag; when the existence of the symbols are not guaranteed, it uses
dlsym. This change fixes the aforementioned problem by turning on the
flag also when libbase is built for an APEX.

Exempt-From-Owner-Approval: cherry-pick rvc-dev

Bug: 149569129
Test: TARGET_BUILD_APPS=com.android.media
vendor/google/build/build_mainline_modules.sh
adb install --staged out/dist/mainline_modules_arm64/com.android.media.apex
adb reboot
The APEX is installed and mediaextractor process doesn't crash

Merged-In: I44b5ec028850613cb45fc3e792f43cd8e87cfd00
(cherry picked from commit 5280b5c03e)
Change-Id: I44b5ec028850613cb45fc3e792f43cd8e87cfd00
2020-03-11 07:53:23 +00:00
yongcheol.lee
019f731097 Restore fastboot delete-logical-partition command for VTS
1. delete-logical-partition was deleted
	- After merge "Don't require bootloader fastboot for VTS compliance." commit, delete-logical-partition sequence was deleted in LogicalPartitionCompliance test. "create-logical-partition failed" is occurred when run vts fastbootverification module. So restore this sequence.

Signed-off-by: Yongcheol LEE <yongcheol09.lee@lge.com>

Test: VTS
Test: run vts -m VtsFastbootVerification

Change-Id: I00366b281eafa5677b0941419a86f2702fb3484b
2020-03-11 13:05:07 +09:00
Elliott Hughes
a52b458dd4 adb: support wait-for- with multiple states.
Test: manual, adb wait-for-device-recovery
Change-Id: I92034c477d28f847e24ec72bbb87b252fba875e1
2020-03-10 17:01:34 -07:00
Tianjie Xu
73ae00bbde Merge "Create an interface for the cd entry hash table" 2020-03-10 23:51:18 +00:00
Josh Gao
a964a96ae7 Merge "base: tag unique_fd::reset as reinitializing for clang-tidy." 2020-03-10 22:32:41 +00:00
Tom Cherry
eb20ff0be0 Merge changes Ib8a4835c,I2e11b782
* changes:
  Revert "init: handle property service callbacks asynchronously"
  Revert "Stop & Resume property service when switching to bootstrap namespace"
2020-03-10 20:44:55 +00:00
Tom Cherry
832f9f1dbd Revert "init: handle property service callbacks asynchronously"
This is apparently causing problems with reboot.

This reverts commit 7205c62933.

Bug: 150863651
Test: build
Change-Id: Ib8a4835cdc8358a54c7acdebc5c95038963a0419
2020-03-10 11:53:11 -07:00
Tianjie Xu
28f8eaeffb Create an interface for the cd entry hash table
The current implementation of the hashtable uses less memory than
a std::map. As most of the zip files we encountered don't use the zip64
extension, we should keep the current implementation. And the interface
adds the flexibility for us to switch to std::map for zip64 format.

Bug: 150900468
Test: unit tests pass
Change-Id: Ifd008785c9ff416a27049f9e0c54d9eef985bd85
2020-03-10 11:51:53 -07:00
Tom Cherry
459ca0be74 Revert "Stop & Resume property service when switching to bootstrap namespace"
Dependent change was reverted.

This reverts commit 352ae2d225.

Bug: 150863651
Test: build
Change-Id: I2e11b782fcd2b7baded133a841fdcf519f702b84
2020-03-10 11:48:24 -07:00
Tianjie Xu
0ac447ab95 Merge "adbd: make libadbd_services cc_library again." 2020-03-10 18:43:30 +00:00
Yifan Hong
86008cccb3 Merge changes from topic "no_snapshot_callstack"
* changes:
  Revert "libsnapshot::RemoveAllUpdateState log stack"
  Revert "libsnapshot callstack files readable by dumpstate"
  libsnapshot: delete InitiateMergeAndWait.
2020-03-10 17:08:54 +00:00
Tom Cherry
cc032194b3 Merge "liblog: add API level guard to NDK log.h header" 2020-03-10 16:00:44 +00:00
Tom Cherry
59e93a55fc liblog: add API level guard to NDK log.h header
Bug: 119867234
Test: build
Change-Id: I6fdd7c070af06f04314b9bf7bbfede2a106e0d7c
2020-03-10 08:50:46 -07:00
Howard Chen
14326821f0 Merge "Convert gsid to use the dynamic AIDL service infrastructure" 2020-03-10 09:49:01 +00:00
Treehugger Robot
2401f5f2cc Merge "Set apex_available property" 2020-03-10 07:30:36 +00:00
Treehugger Robot
ecfdda2c14 Merge "Convert vts configs to Android.bp" 2020-03-10 05:00:33 +00:00
Josh Gao
2263bcb4d0 Merge "adb: defer acknowledgement of pushed files until the end." 2020-03-10 01:55:51 +00:00
Chih-hung Hsieh
262b58cd07 Merge "Fix bugprone-string-integer-assignment warnings" 2020-03-10 00:07:58 +00:00
David Anderson
66147bad94 Merge "libdm: Fix WaitForFile early-returning on failed accesses." 2020-03-10 00:06:09 +00:00
Yifan Hong
78671597ca Revert "libsnapshot::RemoveAllUpdateState log stack"
Revert submission snapshotctl_callstack

Reason for revert: Callstack should not be logged
Reverted Changes:
Ib80c74a9a:Temporarily add libutilscallstack dependency
I2dfb6b7f1:libsnapshot::RemoveAllUpdateState log stack

Test: none
Bug: 148818798

Change-Id: I34683e93f10971629737f6fe648b25c6066c702f
2020-03-09 16:14:30 -07:00
Yifan Hong
4a64da427e Revert "libsnapshot callstack files readable by dumpstate"
This reverts commit faa49d1d00.

Reason for revert: Callstack should not be logged.

Test: none
Bug: 148818798

Change-Id: Ie5506ae0c7408e255a464b2f403d0a47d272229e
2020-03-09 16:14:30 -07:00