Commit graph

43382 commits

Author SHA1 Message Date
Jiyong Park
80aa44704c Add support for updatable services
A service with 'updatable' option can be overriden by the same service
definition in APEXes.

/system/etc/init/foo.rc:

service foo /system/bin/foo
    updatable

/apex/myapex/etc/init.rc:

service foo /apex/myapex/bin/foo
    override

Overriding a non-updatable (i.e. without updatable option) service
from APEXes is prohibited.

When an updatable service is started before APEXes are all activated,
the execution is delayed until when the APEXes are all activated.

Bug: 117403679
Test: m apex.test; adb push <built_apex> /data/apex; adb reboot
adb shell, then lsof -p $(pidof surfaceflinger) shows that
the process is executing
/apex/com.android.example.apex@1/bin/surfaceflinger instead of
/system/bin/surfaceflinger

Change-Id: I8a57b8e7f6da81b4d2843e261a9a935dd279067c
2018-11-13 08:59:14 +09:00
Josh Gao
68b5d0c3e3 adb: flush stderr after logging on Windows.
Test: set ADB_TRACE=1 & adb.exe server nodaemon
Change-Id: Ibb109618be7eaae49461a306e34ff79451ec330e
2018-11-12 14:08:40 -08:00
Josh Gao
cd85556151 adb: libusb: don't set interface alternate setting.
Match behavior with the legacy implementation.

Test: ADB_TRACE=1 adb server nodaemon
Change-Id: If1451871f252ef4499b3bb887e947169f8d2432f
2018-11-12 14:08:40 -08:00
Mark Salyzyn
3c426b65f6 init: error log on by-name identical replacement
The following message creates unnecessary alarm:

init: Partition system_a already existed in the by-name symlink map \
 with a value of \
 /dev/block/platform/soc/1d84000.ufshc/by-name/system_a, new value \
 /dev/block/platform/soc/1d84000.ufshc/by-name/system_a will be \
 ignored.

and in the code is cited as an ERROR.  The message admittedly does
point out an inefficiency by reporting multiple updates.

Test: compile
Change-Id: I388a76fa078cf9de5840930247f732d16ccb0719
2018-11-12 20:27:09 +00:00
Treehugger Robot
42b38900d7 Merge "fastboot: pin USB interface versions on darwin." 2018-11-12 20:23:26 +00:00
Jintao_Zhu
5f93072db3 logd: fix memory leak due to slow reader
Kernel panic - not syncing: Out of memory occurred once after 8 hours
automatic test which cases are about Summary:logd memory leak UTResult
: 1/1

IssueID: 93440

Rootcause: the method "LogTimeEntry::FilterSecondPass"(called inside
"LogBuffer::flushTo") does not check the condition flag
"LogTimeEntry::mRelease" which will be set to true when "logd" begins
to kick off a client when it finding the client is slow-est.
Therefore the client cannot be kicked off and hence the log-element
list becomes longer and longer if the slowest client reading more
slower than the writer writing.

Change-Id: I91a44a393e63b3122c15ce269ee195e0eb4339e8
Solution: add the check.
Test: logd kills slow reader
2018-11-12 10:24:15 -08:00
Tom Cherry
13856a05e7 Merge "Reland: "init: chroot from recovery to /first_stage_ramdisk"" 2018-11-12 16:38:59 +00:00
Nick Kralevich
adfe8c4545 Merge "Set bin directories to 0751" 2018-11-12 05:06:50 +00:00
Treehugger Robot
a4e4e39421 Merge "init parses *.rc files from APEXes" 2018-11-12 02:53:41 +00:00
Eran Messeri
be0ab0a6e0 fastboot: pin USB interface versions on darwin.
Similar to the change to adb in Id26760bc62c89a1f7ef67511b21f9d9252ab69f3,
pin the interface version to IOUSBFamily 5.0.0.

Bug: 119264733
Test: Manual
Change-Id: Ied9164532c0ba6f20415dafecb0c774578aa5c57
2018-11-11 18:14:58 -08:00
Nick Kralevich
f4fc922f0b Set bin directories to 0751
Currently, /system/bin, /system/xbin, /product/bin, and /vendor/bin
are 0755, which allows any process to iterate through those
directories and list out the contents. For the vast majority of
processes, this is unnecessary. They only need to know whether a
particular binary exists or doesn't exist, but they don't need to
know the other binaries within those directories.

Allowing this is particularly problematic for SELinux. In particular,
some third party Android applications try to examine every file in
the bin directories, generating SELinux audit noise along the
way. This audit noise makes it harder to see real bugs, and falsely
implies an architectural dependency between the application and random
files in directories like /system/bin.

This change removes the ability to list the contents of the various bin
directories, preventing random probing by such apps. The ability to
execute files, or to probe a specific file by name, remain unchanged.

Addresses SELinux denials similar to the following:
  avc: denied { getattr } for comm="Thread-11" path="/system/bin/atrace" dev="dm-0" ino=189 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:atrace_exec:s0 tclass=file permissive=0 app=uk.co.santander.santanderUK
  avc: denied { getattr } for comm="Binder:26637_2" path="/system/bin/atrace" dev="dm-0" ino=168 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:atrace_exec:s0 tclass=file permissive=0 app=com.tencent.mm
  avc: denied { getattr } for comm="Thread-12" path="/system/bin/apexd" dev="dm-0" ino=451 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:apexd_exec:s0 tclass=file permissive=1 app=com.grppl.android.shell.CMBlloydsTSB73

Shell access to these directories continues to be allowed, to allow for
host-side CTS tests.

Also adjust the indentation of some clang directives, to make the
presubmit hooks happy.

Test: Device boots and no apparent problems.
Change-Id: Ibe75682fac1983d39f3f479a5850ab5a96f6627d
2018-11-11 11:29:10 -08:00
Treehugger Robot
b6ae0e4fc3 Merge "liblp: Add a helper method for upgrading metadata on retrofit devices." 2018-11-10 22:28:41 +00:00
David Anderson
140d053c02 liblp: Add a helper method for upgrading metadata on retrofit devices.
This adds a new MetadataBuilder constructor, NewForUpdate, that can be
used by update_engine to simplify upgrading metadata. It is safe to call
whether or not the device is a retrofit. If the metadata has block
devices assigned to a specific slot, and that slot matches the slot
suffix, it will ensure that an equivalent entry exists for the alternate
slot.

Thus, if the source slot is _a and the target slot is _b, and the
metadata has "system_a" as a block device but not "system_b", this will
automatically add "system_b" as a block device.

Bug: 116802789
Test: liblp_test gtest
Change-Id: Ie89d4dbf4c708b5705e658220227ebf33fcb1930
2018-11-09 16:03:40 -08:00
Tom Cherry
866c08c0ac Reland: "init: chroot from recovery to /first_stage_ramdisk"
When using the recovery image as a trampoline to boot the system,
first chroot from the recovery image to /first_stage_ramdisk, to
minimize differences between these two boot paths.

Primary motivation is due to the fact that the basename of each mount
point is used by device-manager to name its nodes, and the previous
code that created used /system_recovery_mount as the mount point for
system.img broke AVB.  Instead of hacking around that issue, this
change unified mounting for the recovery trampoline and true first
stage ramdisk paths.

Change when relanding: the original change skipped the move mount from
/first_stage_ramdisk to / and only did a chroot instead.  This was a
mistake that resulted in the subsequent move mount of /system to / to
mount over the '/' directory instead of moving that mount.  This
change uses a bind mount of /first_stage_ramdisk to itself instead of
skipping the first move mount.

Bug: 114062208
Test: AVB works with blueline_mainline
Change-Id: I65207edfe98531892da2eafcbff19b438c9c64fe
2018-11-09 14:58:46 -08:00
Jiyong Park
c240440eec init parses *.rc files from APEXes
Init now parses *.rc files from the APEXs when the apexd notifies the
mount event via apexd.status sysprop.

Bug: 117403679
Test: m apex.test; adb root; adb push <builtfile> /data/apex; adb reboot
adb root; adb shell setprop ctl.start apex.test; dmesg shows that init
tries to start the service which doesn't exist.

[   47.979657] init: Could not ctl.start for 'apex.test': Cannot find '/apex/com.android.example.apex/bin/test': No such file or directory

Change-Id: I3f12355346eeb212eca4de85b6b73257283fa054
2018-11-10 04:18:09 +09:00
Tom Cherry
223114008c Merge "Revert "init: chroot from recovery to /first_stage_ramdisk"" 2018-11-09 18:51:14 +00:00
Tom Cherry
e087a6a3bb Revert "init: chroot from recovery to /first_stage_ramdisk"
This reverts commit 56999b41af.

Reason for revert: Something is broken here; we're not switching to /system properly.

Change-Id: I777fedcfb545c11275c9cc12f99b99a2423959a0
2018-11-09 18:47:26 +00:00
Josh Gao
6a08b2c255 Merge "adb: pin USB interface versions on darwin." 2018-11-09 18:45:52 +00:00
Tom Cherry
1bc8dcd92f fs_mgr: remove same partition check for vbmeta
With chained vbmeta and especially its use with dynamic partitions,
this check is no longer always true.  A concrete example is the
chained vbmeta_system partition that contains the metadata for /system
and /product_services for mainline devices.

Test: blueline_mainline boots with AVB enabled
Change-Id: Ib4115831bb3bb49bf6d2a908df59ba32f8405de7
2018-11-09 10:13:13 -08:00
Tom Cherry
64ae77e526 Merge "init: chroot from recovery to /first_stage_ramdisk" 2018-11-09 17:01:41 +00:00
Treehugger Robot
55e4577e90 Merge "liblp: Fix io_tests." 2018-11-09 05:33:10 +00:00
David Anderson
3d08636934 liblp: Fix io_tests.
These broke after recent changes to use IPartitionOpener in more places.
The io_tests must now give block device info to TestPartitionOpener.

Bug: N/A
Test: liblp_test gtest
Change-Id: I0a6505c7223e74507dc13184069fdc34bb6b81e4
2018-11-08 19:04:05 -08:00
David Anderson
3f814c8370 Merge "liblp: Split super.img for retrofit devices." 2018-11-09 01:26:17 +00:00
Josh Gao
b35ee22887 adb: pin USB interface versions on darwin.
It's possible to build against an SDK that's newer than the OS that
we're actually running via Xcode update, and Apple increments the
unversioned IOKit interface IDs to the newest version on every release,
which leads to mysterious failures to acquire an interface.

Pin the interface versions to IOUSBFamily 5.0.0, which shipped on OS X
10.7.3.

Bug: http://b/119264733
Test: ./test_device.py
Change-Id: Id26760bc62c89a1f7ef67511b21f9d9252ab69f3
2018-11-08 16:49:46 -08:00
Tom Cherry
56999b41af init: chroot from recovery to /first_stage_ramdisk
When using the recovery image as a trampoline to boot the system,
first chroot from the recovery image to /first_stage_ramdisk, to
minimize differences between these two boot paths.

Primary motivation is due to the fact that the basename of each mount
point is used by device-manager to name its nodes, and the previous
code that created used /system_recovery_mount as the mount point for
system.img broke AVB.  Instead of hacking around that issue, this
change unified mounting for the recovery trampoline and true first
stage ramdisk paths.

Bug: 114062208
Test: AVB works with blueline_mainline
Change-Id: Iffb154962b6e160150917e068f1e7d0bf7cb84e7
2018-11-08 15:47:36 -08:00
David Anderson
7165154334 liblp: Split super.img for retrofit devices.
On retrofit devices, we need images that can be flashed in the
bootloader for the component "super"partitions. This change rewrites
SparseBuilder so that it generates one sparse image per block device,
and now handles partitions that span across multiple block devices.

A new API function has been added to write the set of sparse images to
an output folder.

Bug: 118887112
Test: manual test, flash split images
Change-Id: Iff56efdcb7bdfd5bc8dd7ff44e8234e091ac2346
2018-11-08 14:19:42 -08:00
David Anderson
9e04f62895 Merge "liblp: Allow automatic slot suffixing of partition names." 2018-11-08 22:13:51 +00:00
Josh Gao
9c27dde899 Merge "adb: switch version back to 40." 2018-11-08 21:31:54 +00:00
Chih-hung Hsieh
141fcfb5c5 Merge "Revert "Use ld when lld fails"" 2018-11-08 20:27:58 +00:00
Yabin Cui
318591509f Merge "run-as: add ":fromRunAs" selector in seinfo." 2018-11-08 17:55:30 +00:00
David Anderson
76cde4173a liblp: Allow automatic slot suffixing of partition names.
On retrofit devices, an OTA package or super_empty.img won't know which
slot it applies to. This is not an issue on devices shipping with
dynamic partitions, since they ship on the "a" slot.

To work around this, partitions and block devices can be flagged as
"auto-slot-suffixed". This indicates that ReadMetadata should
automatically append a slot suffix before returning the metadata. This
flag is added by MetadataBuilder when requested, and will be enabled via
lpmake separately.

After ReadMetadata has applied slot suffixes, it takes care to remove
the slot-suffix flag. This prevents the suffix from being applied twice,
if for example the metadata is then imported into a MetadataBuilder.

Bug: 116802789
Test: liblp_test gtest
      retrofit device boots

Change-Id: Ic7de06d31253a8d5b8d15c0d936175ca2939f857
2018-11-08 09:51:03 -08:00
Chih-hung Hsieh
060056d4f2 Revert "Use ld when lld fails"
This reverts commit 29e54f8e75.

Bug: 78118944
Reason for revert: This now passed TH boot tests.

Change-Id: I5bcff44a96ade6354b1f3247ebe1f47f3898de96
2018-11-07 23:54:10 +00:00
Treehugger Robot
71c29a9ce0 Merge "fs_mgr: overlayfs earlier kernels do not need override_creds=off" 2018-11-07 20:51:07 +00:00
Janis Danisevskis
ea893985be Multi-threaded Keystore
Reflect that IKeystoreInterface was moved to keystore namespace.

Bug: 111443219
Change-Id: Idfc4d584686aa50853ef6f6effcdd670d7e818a5
2018-11-07 11:39:23 -08:00
Mark Salyzyn
6a11694c1b fs_mgr: overlayfs earlier kernels do not need override_creds=off
Kernels at or older than 4.6, the overlayfs drivers do not need,
or support, override_creds=off.  Drop using the mount option.

Commit 3fe6e52f062643676eb4518d68cee3bc1272091b introduced the
need for override_creds=off, and none of the kernels that contain
this patch without the patch that introduces override_creds can
be used with Android.

Test: compile
Bug: 118882257
Bug: 109821005
Change-Id: I832c8ca3fce0269bdef4ce988541adb7ba9662ed
2018-11-07 11:05:18 -08:00
Treehugger Robot
76b420f38d Merge "Fix bootchart" 2018-11-07 07:36:35 +00:00
Treehugger Robot
94514b75e7 Merge "[GPU Service] Add independent AID for gpu service." 2018-11-07 00:53:01 +00:00
Yabin Cui
97e3bb3a94 run-as: add ":fromRunAs" selector in seinfo.
It notifies libselinux that the setcontext request is from run-as.
And libselinux will set current process to runas_app domain, which
can execute app data files.

Bug: 118737210
Test: run CtsSimpleperfTestCases.
Change-Id: Ib94087f910786dd5d2a2b2e3b1bf76dfa7131ced
2018-11-06 15:31:59 -08:00
David Anderson
a97d6e36d5 Merge "fastboot: Query the name of the super partition." 2018-11-06 22:59:17 +00:00
Treehugger Robot
7d87981f79 Merge "adb: overlayfs failed to remount /system" 2018-11-06 22:49:45 +00:00
Treehugger Robot
d016c75104 Merge "fastboot: Fix flashing both slots with dynamic partitions." 2018-11-06 22:48:45 +00:00
Treehugger Robot
a50225ae36 Merge "run-as: Use 2-space clang-format." 2018-11-06 21:01:49 +00:00
Peiyong Lin
126c19b6ec [GPU Service] Add independent AID for gpu service.
BUG: 118347356
Test: Build, flash and boot, `adb shell cmd gpuservice vkjson` to verify

Change-Id: Ic8c4154668d09b3dbfedf4a7c0dc376a01a9bde6
2018-11-06 12:52:01 -08:00
Treehugger Robot
612c2854ad Merge "fs_mgr: enable DT fstab based on its status node appropriately" 2018-11-06 20:30:44 +00:00
David Anderson
88fd7e60d0 Merge "liblp: Fix flashing metadata to multiple block devices." 2018-11-06 19:45:26 +00:00
David Anderson
90fe0a43ab fastboot: Query the name of the super partition.
This patch adds a new variable, "super-partition-name", to query the
name of the super partition (with a slot suffix if it has one). The
fastboot flashing tool has been updated to query this variable.

Since the super partition name can no longer be determined without
fastbootd, the presence of super_empty.img is used to test for
dynamic partition support rather than the presence of a super partition.

Bug: 116802789
Test: fastboot flashall on retrofit device
Change-Id: If830768eba6de7f31ac3183c64167fae973c77a4
2018-11-06 11:43:04 -08:00
David Anderson
96a9fd4063 fastboot: Fix flashing both slots with dynamic partitions.
When updating the super partition, attempt to preserve partitions from
the other slot. If any partition can't be preserved, fail and require a
wipe (-w) to proceed. This allows two bootable builds to be flashed to
both slots.

The preserve operation can fail if the metadata is not compatible with
the old partition layout. For example, if the partition references a
group that no longer exists, or a group changed its capacity, or the
metadata's block device list or list contents changed.

Bug: N/A
Test: liblp_test gtest
      fastboot flashall --skip-secondary

Change-Id: I53fdd29bc1f0ef132005a93d3cf1cdcd7f2fc05f
2018-11-06 11:43:03 -08:00
Yabin Cui
bcbffddb10 run-as: Use 2-space clang-format.
Bug: none
Test: none.
Change-Id: I8fc2f9a534675347bae5af0ce12b0bf3d7c32d55
2018-11-06 11:18:44 -08:00
Tom Cherry
1eb04561c1 fs_mgr: enable DT fstab based on its status node appropriately
Follow the typical device tree guidelines that a node is only enabled
if it does not have a 'status' property or if it does have a 'status'
property with a value of 'ok' or 'okay'.

Bug: 117933812
Test: status='disabled' DT fstab is not present when reading fstab
Change-Id: Icb4cbe654757658460aabfdb952d71fb8354e09e
2018-11-06 10:44:51 -08:00
David Anderson
fa36e318cf Merge "init: Regenerate uevents for dependent super partition devices." 2018-11-06 17:52:17 +00:00