Commit graph

59576 commits

Author SHA1 Message Date
Nikita Ioffe
bcf476dece Merge "Fix potential use-after-free bug in reboot" into rvc-dev am: 03ad58468b am: 93065fbab6
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/13144438

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I895a5a170c60da26aacdbf869ea14b6d6db4dd67
2020-12-09 00:23:38 +00:00
Nikita Ioffe
93065fbab6 Merge "Fix potential use-after-free bug in reboot" into rvc-dev am: 03ad58468b
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/13144438

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iec73de951c44463d72f9af3b236644c04c6de689
2020-12-09 00:06:38 +00:00
Nikita Ioffe
03ad58468b Merge "Fix potential use-after-free bug in reboot" into rvc-dev 2020-12-08 23:42:42 +00:00
TreeHugger Robot
71945f284d Merge "storaged: protect global proto_loaded" into rvc-qpr-dev 2020-12-06 03:26:13 +00:00
Mark Salyzyn
c3f62e1b73 storaged: protect global proto_loaded am: 32b5003cf6 am: 4d4322a32e
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/13113781

Change-Id: I5d4f9ca34ca0e5b3078c9cc46babbf1d5dbee6cd
2020-12-06 01:37:57 +00:00
Mark Salyzyn
4d4322a32e storaged: protect global proto_loaded am: 32b5003cf6
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/13113781

Change-Id: Ib7144fecb934f8fe87d964c387320003db111b03
2020-12-06 01:21:15 +00:00
Nikita Ioffe
71bd926bf0 Fix potential use-after-free bug in reboot
Instead of operating on raw pointers, init now uses name of the
services as it's primary identifier. Only place that still uses
vector<Service*> is StopServices.

In addition, ServiceList::services() function is removed, which should
help avoiding similar bugs in the future.

Bug: 170315126
Bug: 174335499
Test: adb reboot
Test: atest CtsInitTestCases
Change-Id: I73ecd7a8c58c2ec3732934c595b7f7db814b7034
Merged-In: I73ecd7a8c58c2ec3732934c595b7f7db814b7034
(cherry picked from commit bbba64826fdfb7be1f04b7bbb125fbe6d25e5028)
2020-12-01 22:54:05 +00:00
Mark Salyzyn
d179cbcdc2 storaged: protect global proto_loaded
proto_loaded is not thread safe, so we must protect it with
a mutex proto_lock.

Signed-off-by: hanhongli@360.cn
Signed-off-by: gongguang@360.cn
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 170732441
Test: compile
Change-Id: I93416598b6047e890c66b922b360093aa42db8c5
2020-11-23 21:46:54 +00:00
Mark Salyzyn
32b5003cf6 storaged: protect global proto_loaded
proto_loaded is not thread safe, so we must protect it with
a mutex proto_lock.

Signed-off-by: hanhongli@360.cn
Signed-off-by: gongguang@360.cn
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 170732441
Test: compile
Change-Id: I93416598b6047e890c66b922b360093aa42db8c5
2020-11-23 21:44:29 +00:00
TreeHugger Robot
f11b01fc87 Merge "adbd: Fix check against valid payload size" into rvc-qpr-dev 2020-10-02 02:10:49 +00:00
TreeHugger Robot
46ef208603 Merge "fastboot: add new oem command for post wipe userdata" into rvc-qpr-dev 2020-09-25 16:09:36 +00:00
josephjang
ad90b45558 fastboot: add new oem command for post wipe userdata
When user input fastboot erase userdata, need a follow
up oem command to wipe other user data in device.
We support this new postwipedata command in
"fastboot erase userdata" only.

Bug: 150929955
Change-Id: I9b6a5a4aaed31d1168e633418b189f9bb6d34d01
Ignore-AOSP-First: I9b6a5a4aaed31d1168e633418b189f9bb6d34d01
2020-09-25 08:22:19 +00:00
Mayank Rana
f7451e6782 adbd: Fix check against valid payload size
block->payload and its size are not valid when it is used to check
against bytes_left due to std::move() performed on its just prior
to the check. Hence check will always fail to detect the case where
received data is more than expected. To detect this condition and
allow error handling with std::move(), remove extra payload variable
and directly use block->payload.

Bug: http://b/168917244
Change-Id: I992bbba9d9a9861a195834f69d62e69b90658210
(cherry picked from commit 71a33cfa67)
2020-09-18 12:27:14 -07:00
Martijn Coenen
c3f71bc459 Allow shell to write to /sdcard/Android/data and /sdcard/Android/obb.
On devices without sdcardfs, these are only writable by the owning UID,
and/or the ext_data_rw/ext_obb_rw groups respectively.

Bug: 161134565
Bug: 162810387
Test: try to write to /sdcard/Android/data/ from shell uid
Change-Id: I19a9980bcff7b6fd0554dd2a4c8d59abe6ad540b
(cherry picked from commit 4da604ba4e)
2020-09-18 12:25:06 -07:00
Elliott Hughes
f719e75c7e FileMap::create: remove duplicate addition. am: 54794ac613 am: 2912d9c190 am: 98e213207f am: a6d7150812 am: 8a192ea12a am: 3c751b9f66 am: 5281bee360 am: 840961613a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: I262d74e520918866927311bd7d5262320792ccb3
2020-08-29 00:49:41 +00:00
Elliott Hughes
840961613a FileMap::create: remove duplicate addition. am: 54794ac613 am: 2912d9c190 am: 98e213207f am: a6d7150812 am: 8a192ea12a am: 3c751b9f66 am: 5281bee360
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: Iafb2500a484b934a1ba188b790671f7247bc6cab
2020-08-29 00:36:42 +00:00
Elliott Hughes
5281bee360 FileMap::create: remove duplicate addition. am: 54794ac613 am: 2912d9c190 am: 98e213207f am: a6d7150812 am: 8a192ea12a am: 3c751b9f66
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: I470769ef78fdfda93b8eee4e8b68065487c2aca1
2020-08-29 00:28:38 +00:00
Elliott Hughes
3c751b9f66 FileMap::create: remove duplicate addition. am: 54794ac613 am: 2912d9c190 am: 98e213207f am: a6d7150812 am: 8a192ea12a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: Iddc2342abba73f6a5bf15adf5ae2993a55cac444
2020-08-28 23:39:24 +00:00
Elliott Hughes
8a192ea12a FileMap::create: remove duplicate addition. am: 54794ac613 am: 2912d9c190 am: 98e213207f am: a6d7150812
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: I786693d6ba95669444f329a2f17c287d8fbc524e
2020-08-28 23:24:01 +00:00
Elliott Hughes
a6d7150812 FileMap::create: remove duplicate addition. am: 54794ac613 am: 2912d9c190 am: 98e213207f
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: I8aeee458349a540c6a75fce57fd4a1d8b5b75eb3
2020-08-28 23:11:38 +00:00
Elliott Hughes
98e213207f FileMap::create: remove duplicate addition. am: 54794ac613 am: 2912d9c190
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: I416cdeb24824e7da9f437f61530e1861c9ea446c
2020-08-28 22:58:07 +00:00
Elliott Hughes
2912d9c190 FileMap::create: remove duplicate addition. am: 54794ac613
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: Id0ff977722c484055c7a55397752ecda6f61a91f
2020-08-28 22:43:23 +00:00
TreeHugger Robot
42af3fa606 Merge "Assume UNSUPPORTED if the battery capacity level sysfs node does not exist." into rvc-qpr-dev 2020-08-28 19:12:50 +00:00
sirius.wang
682cf72e5b fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol. am: 767fe1515a am: 9c2f03b906 am: 224d06fa1a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12448097

Change-Id: I808ca7d9897603cc4a067aa6966ee76f48144161
2020-08-28 16:53:34 +00:00
sirius.wang
224d06fa1a fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol. am: 767fe1515a am: 9c2f03b906
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12448097

Change-Id: I82069a7f289a340351280bb18cd5af8ffa6f01b1
2020-08-28 16:28:24 +00:00
sirius.wang
9c2f03b906 fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol. am: 767fe1515a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12448097

Change-Id: I4e1233336d3de093d31aecfd377451114461de46
2020-08-28 16:20:40 +00:00
Stephane Lee
4deef11990 Assume UNSUPPORTED if the battery capacity level sysfs node does
not exist.

Bug: 163382088
Test: Ensure that, if the ./capacity_level does not exist,
  that the device will shut down at 0 % SOC in an Health 2.1
  implementation
Change-Id: I00822b4bfba5d823c1a30163ea6824e59d3aae32
Merged-In: I00822b4bfba5d823c1a30163ea6824e59d3aae32
2020-08-27 22:42:25 -07:00
Marco Ballesio
109a140f6c init.rc: remove initializations to cg2_bpf path
https://r.android.com/c/1324649/5 moves the cgroup folder to its sysfs
path. Directory access rights are defined by kernel code and sepolicy,
so remove the initialization lines from init.rc.

Test: manually booted the device and verified access rights for
/sys/fs/cgroup
Bug: 154548692

Change-Id: I67284dc651ed529cae69e413b66c6e1292a2d970
Merged-In: I67284dc651ed529cae69e413b66c6e1292a2d970
2020-08-27 08:34:39 -07:00
Marco Ballesio
6b67edb3fb libprocessgroup: json prototype for cgroups v2
cgroups v2 support introduces new fields in the json format. Adapt the
proto file accordingly

Bug: 154548692
Test: atest libprocessgroup_proto_test --
Change-Id: I40f8757a8f4e6a0b839caa7faa976dfebf3aac98
Merged-In: I40f8757a8f4e6a0b839caa7faa976dfebf3aac98
2020-08-27 08:34:39 -07:00
Marco Ballesio
510f89ec0e libprocessgroup: switch freezer to cgroup v2
remove cgroup v1 freezer entries from init.rc, add a new cgroup v2
controller and modify plists to properly interact with it.

Bug: 154548692
Test: manually verified the the cgroup v1 freezer controller isn't
created and a new controller for cgroup v2 is created under the correct
sysfs directory.

Change-Id: I1b811300ade486f88fdbd157255a7f37750cc54d
Merged-In: I1b811300ade486f88fdbd157255a7f37750cc54d
2020-08-27 08:34:39 -07:00
sirius.wang
767fe1515a fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol.
The fastbootd over ethernet was implemented with IPv6 link-local
address. An IPv6 address may include many ':'. It will break this fuzzy
test. This new solution uses "tcp:" prefix to identify the fastboot
protocol, like the host fastboot command.

BUG: 157887327
Test: fuzzy_fastboot --serial=tcp:fe80::230:1bff:feba:8128%wlan0 \
      --gtest_filter=*Logical*
Bug: http://b/166279510

Change-Id: I8fe7e6e3ade94a26e05a31ac20ed9ab3839dd342
Merged-In: I971fd9e25741e18bf7f5907d562556b09db1d624
2020-08-25 17:33:17 +00:00
Elliott Hughes
54794ac613 FileMap::create: remove duplicate addition.
The previous change was intended to detect the overflow, but
accidentally retained the existing addition, so we'd abort before
getting to the explicit check.

Also reformat slightly to better match the current code in qt-dev and
beyond, to reduce merge conflicts.

Bug: 156997193
Test: treehugger
Change-Id: I73a3a4e75f0aad00888e8f2b49a07b7e8b4eda05
Merged-In: I73a3a4e75f0aad00888e8f2b49a07b7e8b4eda05
2020-08-19 18:40:10 +00:00
Marco Ballesio
e689b935d1 libprocessgroup: support for cgroup v2 hierarchy
for a first implementation the cgroup v2 freezer controller will be used in a
way similar to cgroup v1, that is a single child group will hold all frozen
processes. Some adjustments are needed for the new structure.

- Add support for cgroup v2 syntax under procfs.
- Separate creation of a directory with ownership/mode changes to allow changes
    after mounting the cgroup kernfs root.
- Allow the creation of sub-groups under a cgroup v2 hierarchy.

Bug: 154548692
Test: manually verified that a proper cgroup v2 hierarchy is created and
accessible

Change-Id: I9af59e8214acaead3f520a94c95e75394c0df948
Merged-In: I9af59e8214acaead3f520a94c95e75394c0df948
2020-08-14 16:52:38 -07:00
Yifan Hong
341ac543ac libsnapshot_test: skip global setup on non-VAB devices. am: b085db746a am: 632b1ab4ba am: 7cb8fd1b65
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12329326

Change-Id: I28a870ff608da5a46aed89f4192e5d5195794ad0
2020-08-10 19:52:16 +00:00
Alessio Balsini
c6dd1f1bb6 Re-enable libsnapshot ImageManagerTest am: c723fca056 am: 37645974cc am: 350a50605e
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12337395

Change-Id: I21eb1396f0976c7846cc42967b73fa96c2d280b4
2020-08-10 19:52:14 +00:00
Yifan Hong
7cb8fd1b65 libsnapshot_test: skip global setup on non-VAB devices. am: b085db746a am: 632b1ab4ba
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12329326

Change-Id: I04b054a658d77823ea69a7a8e12b309ac37e17a2
2020-08-10 19:33:58 +00:00
Alessio Balsini
350a50605e Re-enable libsnapshot ImageManagerTest am: c723fca056 am: 37645974cc
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12337395

Change-Id: Ia5dcd0368b3f8ed31fa94e298eb9c53661690d75
2020-08-10 19:33:54 +00:00
Yifan Hong
632b1ab4ba libsnapshot_test: skip global setup on non-VAB devices. am: b085db746a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12329326

Change-Id: I9c273068441327d893d84e48fbec4df3189833c3
2020-08-10 19:10:40 +00:00
Alessio Balsini
37645974cc Re-enable libsnapshot ImageManagerTest am: c723fca056
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12337395

Change-Id: Ic5cd924138f4dafeb238b4f2a0f6d7d5ffb7ea99
2020-08-10 19:10:37 +00:00
Yifan Hong
b085db746a libsnapshot_test: skip global setup on non-VAB devices.
On non-VAB devices, fake super image creation may fail because it
may not support f2fs file pinning.

Also changes global setup to a testing::Environment object because it is
the recommended way in gtest's guide. SnapshotTestEnvironement::TearDown
is automatically executed before RUN_ALL_TEST returns.

Test: vts_libsnapshot_test
Test: make IsVirtualAbEnabled() return false, then all tests are
skipped.

Bug: 162557082
Change-Id: I1382f9a4ddec146fa2d8cfb21ac66ca22a2e110f
(cherry picked from commit a7c00a0943)
Merged-In: I1382f9a4ddec146fa2d8cfb21ac66ca22a2e110f
2020-08-07 18:07:14 -07:00
Alessio Balsini
c723fca056 Re-enable libsnapshot ImageManagerTest
ImageManagerTest had been temporarily disabled because flaky.
This test looks stable now, re-enable it.

Bug: 148889015
Test: atest vts_libsnapshot_test [-- --abi x86]
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I858661fed7f58d1e2857ed88f5d8e0f5220bf8c2
(cherry picked from commit 42a608162d)
Merged-In: I858661fed7f58d1e2857ed88f5d8e0f5220bf8c2
2020-08-07 18:07:13 -07:00
Eric Biggers
7a6e620447 fs_mgr: Revert "Try to recover corrupted ext4 /data with backup superblock"
This reverts commit 72abd7b246
(change Ia39af3340c0e241f62557b7c2cc8b800443342f9).

When vold enables either FDE or metadata encryption, it encrypts the
filesystem in-place.  Unfortunately, due to a bug, for ext4 filesystems
it hasn't been encrypting the backup superblocks.

Also, in read_ext4_superblock(), the check for
StartsWith(blk_device, "/dev/block/dm-") can return true even if the
encryption mapping hasn't been added yet, since when a GSI image is
booted the userdata block device is a logical volume using dm-linear.

The result is that read_ext4_superblock() can recognize a backup
superblock when the encryption mapping hasn't been added yet, causing
e2fsck to run without the encryption mapping and corrupt the filesystem.

https://android-review.googlesource.com/c/platform/system/vold/+/1385029
will fix this for new or factory-reset devices.  However, there probably
are many existing devices that already have their backup superblocks
unencrypted.  Therefore, the EncryptInPlace fix isn't enough and we have
to revert the change that started using the backup superblocks too.

Bug: 161871210
Bug: 162479411
Change-Id: I279f84c072bc6c8d3e251a5e95c78f8d6c0d50ba
Merged-In: I279f84c072bc6c8d3e251a5e95c78f8d6c0d50ba
(cherry picked from dc3e897a88)
2020-08-06 15:52:51 +08:00
Kazuhiro Inaba
3a7a8b871a cts: Skip CtsInitTestCases over a native bridge. am: 9cecf8422a am: 49ddb673c5 am: df2e518ccf
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12263311

Change-Id: I60ebd26191d4d2e431a113c82b3243419c7aa507
2020-08-05 19:57:58 +00:00
Kazuhiro Inaba
df2e518ccf cts: Skip CtsInitTestCases over a native bridge. am: 9cecf8422a am: 49ddb673c5
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12263311

Change-Id: I5d73d554acf98fc661fee827c37c9a9d9059e8ef
2020-08-05 19:38:35 +00:00
Kazuhiro Inaba
49ddb673c5 cts: Skip CtsInitTestCases over a native bridge. am: 9cecf8422a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12263311

Change-Id: I9d208b96945f99b64da031d03e09a570862bcc1b
2020-08-05 19:10:41 +00:00
Steven Moreland
b6b96398f4 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd am: 64b312bbd8 am: 0cb14f1fe7 am: ce44c8ac3c am: 1db089dc83
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: Id855ccb8767afbc80338315d8a0522054855a749
2020-08-05 00:08:49 +00:00
Steven Moreland
1db089dc83 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd am: 64b312bbd8 am: 0cb14f1fe7 am: ce44c8ac3c
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I51d7fd41157708b398888aac7f70dd09c397ee81
2020-08-04 23:37:56 +00:00
Steven Moreland
ce44c8ac3c Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd am: 64b312bbd8 am: 0cb14f1fe7
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I1cb83a4a22e205dddd10536f61392215d5cb33dc
2020-08-04 23:19:46 +00:00
Steven Moreland
0cb14f1fe7 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd am: 64b312bbd8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I7d40bc3c63aa13c4050662f17b8a0854f8864ce4
2020-08-04 23:02:18 +00:00
Steven Moreland
64b312bbd8 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I79dcbb310a2515e7f17ad2ebbb0367070084dab2
2020-08-04 22:46:49 +00:00