Commit graph

2946 commits

Author SHA1 Message Date
Daniel Rosenberg
149ed5fb3c Merge changes I977cc03b,I7b621476,Ib57f4461 am: 58551c0568 am: 5da6d2a0f9
am: 6647c75d3c

Change-Id: Iecf990d139b98ba2788cb6ba82e6673c28bb08c2
2019-03-21 14:28:39 -07:00
Daniel Rosenberg
6647c75d3c Merge changes I977cc03b,I7b621476,Ib57f4461 am: 58551c0568
am: 5da6d2a0f9

Change-Id: I98125f4b3277601bf2795e76cb8b8b889e1725e4
2019-03-21 14:23:22 -07:00
Daniel Rosenberg
5da6d2a0f9 Merge changes I977cc03b,I7b621476,Ib57f4461
am: 58551c0568

Change-Id: I0ecec87455c3c8daa53b00be941539998eea1cd2
2019-03-21 14:19:27 -07:00
Daniel Rosenberg
58551c0568 Merge changes I977cc03b,I7b621476,Ib57f4461
* changes:
  Add health check to checkpointing
  Change abortChanges to take a message and bool
  Make needsCheckpoint cover whole session
2019-03-21 21:01:08 +00:00
Daniel Rosenberg
8daeec05e8 Add health check to checkpointing
Take action if we are running out of checkpoint space.
Configurable via ro.sys properties.
ro.sys.cp_usleeptime = Time to sleep between checks
ro.sys.cp_min_free_bytes = Min free space to act on
ro.sys.cp_commit_on_full = action to take. Either commits or reboots to
                           continue attempt without checkpoint, or retry
			   and eventually abort OTA

Test: Trigger a checkpoint and fill the disk.
Bug: 119769392
Change-Id: I977cc03b7aef9320d661c8a0d716f8a1ef0be347
2019-03-21 13:33:49 -07:00
Daniel Rosenberg
a59e4396a4 Change abortChanges to take a message and bool
abortChanges will attempt to pass a reboot message, and will only reboot
if the device is currently checkpointing. Additionally, it can opt to
attempt to prevent future attempts. This only works for non-bootloader
controlled updates. Failures are ignored, as it will always reboot the
device. In the unlikely event of such a failure, the device will
continue to retry as though you did not ask to prevent future attempts.

Test: vdc checkpoint abortChanges abort_retry_test 1
      vdc checkpoint abortChanges abort_noretry_test 0

Change-Id: I7b6214765a1faaf4fd193c73331696b53ae572d2
2019-03-21 13:33:49 -07:00
Daniel Rosenberg
84203c1e24 Make needsCheckpoint cover whole session
This makes needCheckpoint return true when the device will or is using
checkpointing.

Test: vdc checkpoint startCheckpoint 1
      reboot
      vdc checkpoint needsCheckpoint
      should return 1 before and after data mounts, and 0 once the
      checkpoint has been committed

Change-Id: Ib57f4461d837f41a8110ed318168165a684d913a
2019-03-21 13:33:49 -07:00
Rubin Xu
f2e846f153 Remove excess logging in secdiscard
Remove all debug logs to reduce logspam a bit.

Bug: 64349233
Test: manual
Change-Id: I234fae7b9fb719b09af27985736f43f085dad301
2019-03-21 19:13:51 +00:00
Paul Crowley
178ee0ded1 Merge "Shell no longer globs, so glob in pushBackContents" am: a41b7849d0 am: 04017039b7
am: 612065e22b

Change-Id: I296bf6ce7d616e3615e2a39293b2b60c2ce85c4d
2019-03-19 12:39:54 -07:00
Paul Crowley
612065e22b Merge "Shell no longer globs, so glob in pushBackContents" am: a41b7849d0
am: 04017039b7

Change-Id: Ifc9ef0e513dd3d7ed6d0b67ddbec236145196b18
2019-03-19 12:35:48 -07:00
Paul Crowley
04017039b7 Merge "Shell no longer globs, so glob in pushBackContents"
am: a41b7849d0

Change-Id: Iedd9a6d6834adc844e13e9ec596062032588fd53
2019-03-19 12:31:37 -07:00
Paul Crowley
a41b7849d0 Merge "Shell no longer globs, so glob in pushBackContents" 2019-03-19 19:13:56 +00:00
Paul Lawrence
183f8cd213 Merge "Add vdc checkpoint supportsBlockCheckpoint" am: 860c731158 am: 4c5ce24e80
am: ca54294cf8

Change-Id: Ibee238347b863404670e972f41cebcb4986c8435
2019-03-18 16:47:37 -07:00
Paul Lawrence
ca54294cf8 Merge "Add vdc checkpoint supportsBlockCheckpoint" am: 860c731158
am: 4c5ce24e80

Change-Id: I60320da84c973841b4efd425e0cfc7cc81052fe6
2019-03-18 16:27:46 -07:00
Paul Lawrence
4c5ce24e80 Merge "Add vdc checkpoint supportsBlockCheckpoint"
am: 860c731158

Change-Id: I61a7059649e8dc0ff5096f3494d5e4b0f8f3b787
2019-03-18 16:08:51 -07:00
Treehugger Robot
860c731158 Merge "Add vdc checkpoint supportsBlockCheckpoint" 2019-03-18 22:56:47 +00:00
Paul Lawrence
c5c79c5679 Add vdc checkpoint supportsBlockCheckpoint
Also add vdc checkpoint supportsFileCheckpoint
This is to allow tests to be specific to supported checkpoint mode.

Test: Built on Taimen and Crosshatch, made sure both new functions work
as expected

Change-Id: I0eab7453b13c0a2e31840ef9ad24a692cec55b00
2019-03-18 13:40:00 -07:00
Paul Crowley
51209e9e40 Shell no longer globs, so glob in pushBackContents
Bug: 113246065
Bug: 123057215

Test: As described in b/113246065 comment 1
Change-Id: Id766773ed4abe80a9fc1d5305f099aedfe8eed90
2019-03-18 10:26:47 -07:00
Chris Fries
a475189b32 Merge "Fsync directories before delete key" am: 7573874d3f am: 3a38070bbf
am: 08613423ee

Change-Id: I6007af911ba3fcafad590d33deea25a5c55b03c3
2019-03-14 08:44:08 -07:00
Chris Fries
08613423ee Merge "Fsync directories before delete key" am: 7573874d3f
am: 3a38070bbf

Change-Id: I568a6e8a39929b77ba76b021657e248a4e49e470
2019-03-14 08:40:08 -07:00
Chris Fries
3a38070bbf Merge "Fsync directories before delete key"
am: 7573874d3f

Change-Id: I568638b5de3c58d868024f959f890094eb1bd501
2019-03-14 08:34:06 -07:00
Woody Lin
a598e04a91 Fsync directories before delete key
The boot failure symptom is reproduced on Walleye devices. System boots
up after taking OTA and try to upgrade key, but keymaster returns "failed
to ugprade key". Device reboots to recovery mode because of the failure,
and finally trapped in bootloader screen. Possible scenario is:

(After taking OTA)
vold sends old key and op=UPGRADE to keymaster
keymaster creates and saves new key to RPMB, responses new key to vold
vold saves new key as temp key
vold renames temp key to main key -------------- (1) -- still in cache
vold sends old key and op=DELETE_KEY to keymaster
keymaster removes old key from RPMB ------------ (2) -- write directly to RPMB
==> SYSTEM INTERRUPTED BY CRASH OR SOMETHING; ALL CACHE LOST.
==> System boots up, key in RPMB is deleted but key in storage is old key.

Solution: A Fsync is required between (1) and (2) to cover this case.

Detail analysis: b/124279741#comment21

Bug: 112145641
Bug: 124279741
Test: Insert fault right after deleteKey in vold::begin (KeyStorage.cpp),
      original boot failure symptom is NOT reproducible.
Change-Id: Ia042b23699c37c94758fb660aecec64d39f39738
Merged-In: Ib8c349d6d033f86b247f4b35b8354d97cf249d26
2019-03-14 10:29:42 -05:00
Paul Crowley
2e58acb412 Fsync directories after creating files
Bug: 112145641
Bug: 124279741
Bug: 120248692
Test: adb shell locksettings set-pin 1111 && \
    adb shell "echo b > /proc/sysrq-trigger"
Change-Id: I53d252942c21365983b4f8b6e0948b1864f195c1
Merged-In: I53d252942c21365983b4f8b6e0948b1864f195c1
2019-03-14 10:26:21 -05:00
Chris Fries
7573874d3f Merge "Fsync directories before delete key" 2019-03-14 15:19:20 +00:00
Woody Lin
37c82f5c0f Fsync directories before delete key
The boot failure symptom is reproduced on Walleye devices. System boots
up after taking OTA and try to upgrade key, but keymaster returns "failed
to ugprade key". Device reboots to recovery mode because of the failure,
and finally trapped in bootloader screen. Possible scenario is:

(After taking OTA)
vold sends old key and op=UPGRADE to keymaster
keymaster creates and saves new key to RPMB, responses new key to vold
vold saves new key as temp key
vold renames temp key to main key -------------- (1) -- still in cache
vold sends old key and op=DELETE_KEY to keymaster
keymaster removes old key from RPMB ------------ (2) -- write directly to RPMB
==> SYSTEM INTERRUPTED BY CRASH OR SOMETHING; ALL CACHE LOST.
==> System boots up, key in RPMB is deleted but key in storage is old key.

Solution: A Fsync is required between (1) and (2) to cover this case.

Detail analysis: b/124279741#comment21

Bug: 112145641
Bug: 124279741
Test: Insert fault right after deleteKey in vold::begin (KeyStorage.cpp),
      original boot failure symptom is NOT reproducible.
Change-Id: Ib8c349d6d033f86b247f4b35b8354d97cf249d26
2019-03-14 16:48:32 +08:00
The Android Open Source Project
8924680dfb [automerger skipped] Merge "DO NOT MERGE - Skip PPRL.190305.001 into master" am: 027fe9217c -s ours am: e1d82ea744 -s ours
am: 1c4f1e80e0 -s ours
am skip reason: subject contains skip directive

Change-Id: I8a1dd28839de20a90acbef6e911f7135724eed3e
2019-03-11 17:47:32 -07:00
The Android Open Source Project
b9bda094ad [automerger skipped] DO NOT MERGE - Skip PPRL.190305.001 into master am: 37c6ce4fb0 -s ours am: 1a158c67a0 -s ours
am: 9c5a36769b -s ours
am skip reason: subject contains skip directive

Change-Id: I4106b7617a6cb26979eeaa66fe7c49209676a22b
2019-03-11 17:46:36 -07:00
The Android Open Source Project
1c4f1e80e0 [automerger skipped] Merge "DO NOT MERGE - Skip PPRL.190305.001 into master" am: 027fe9217c -s ours
am: e1d82ea744 -s ours
am skip reason: subject contains skip directive

Change-Id: Ia2810aced1e11dc131b010e4d45833eded34ae26
2019-03-11 17:14:30 -07:00
The Android Open Source Project
9c5a36769b [automerger skipped] DO NOT MERGE - Skip PPRL.190305.001 into master am: 37c6ce4fb0 -s ours
am: 1a158c67a0 -s ours
am skip reason: subject contains skip directive

Change-Id: I853be075f650f9afcc8271dc6e80d4766f847be9
2019-03-11 17:13:37 -07:00
The Android Open Source Project
e1d82ea744 [automerger skipped] Merge "DO NOT MERGE - Skip PPRL.190305.001 into master"
am: 027fe9217c -s ours
am skip reason: subject contains skip directive

Change-Id: I2dc06015f2c873a8d9a62d743d97fc489937b644
2019-03-11 16:55:26 -07:00
The Android Open Source Project
1a158c67a0 [automerger skipped] DO NOT MERGE - Skip PPRL.190305.001 into master
am: 37c6ce4fb0 -s ours
am skip reason: subject contains skip directive

Change-Id: I6fa5c1108107e07e1d6c77592eaa6269672fdd2b
2019-03-11 16:54:31 -07:00
Treehugger Robot
027fe9217c Merge "DO NOT MERGE - Skip PPRL.190305.001 into master" 2019-03-11 23:16:31 +00:00
The Android Open Source Project
37c6ce4fb0 DO NOT MERGE - Skip PPRL.190305.001 into master
Bug: 127812889
Change-Id: I5bff7948e2fc254d0595329bd7a7262586de0c32
2019-03-11 14:57:55 -07:00
Jiyong Park
4b64463572 Merge "Don't unmount /storage for early native processes" am: ee9554b2d9 am: b5acb5bfba
am: f1baff6ddd

Change-Id: I7107dd9d24dd07f9c17ea11d24db17db2cd10f12
2019-03-08 18:05:14 -08:00
Jiyong Park
f1baff6ddd Merge "Don't unmount /storage for early native processes" am: ee9554b2d9
am: b5acb5bfba

Change-Id: I2c3b48550a64486214835fbcfa1879cc2cbddb2b
2019-03-08 18:00:12 -08:00
Jiyong Park
b5acb5bfba Merge "Don't unmount /storage for early native processes"
am: ee9554b2d9

Change-Id: I985413323a86816b392bd00211c550aef93328ae
2019-03-08 17:55:15 -08:00
Treehugger Robot
ee9554b2d9 Merge "Don't unmount /storage for early native processes" 2019-03-09 01:33:40 +00:00
Daniel Rosenberg
dfe9605bf4 Merge changes I91cf0def,I47570e8e am: 5f01cf3cac am: 84ceaedb59
am: 738694469d

Change-Id: I3df9cd0523d2bfcdc716c855c8dca86aba09be9d
2019-03-07 20:07:29 -08:00
Daniel Rosenberg
738694469d Merge changes I91cf0def,I47570e8e am: 5f01cf3cac
am: 84ceaedb59

Change-Id: Ibc16fa468ce9f3253bc133d2cc52c966c8eac96d
2019-03-07 19:32:33 -08:00
Daniel Rosenberg
84ceaedb59 Merge changes I91cf0def,I47570e8e
am: 5f01cf3cac

Change-Id: If269c0d3134dc98683982a96224885503b2f8434
2019-03-07 18:43:46 -08:00
Treehugger Robot
5f01cf3cac Merge changes I91cf0def,I47570e8e
* changes:
  Make Checkpoint restore resume safe
  Add vdc checkpoint restoreCheckpointPart
2019-03-07 23:56:21 +00:00
Daniel Rosenberg
5298593b1b Make Checkpoint restore resume safe
This allows us to resume rolling back in the event of an unexpected
shutdown during the restore process. We save  progress after we process
each log sector, and whenever restarting the current log sector would
result in invalid data.

Test: Run restore, interrupt it, and attempt to resume
Change-Id: I91cf0defb0d22fc5afdb9debc2963c956e9e171c
2019-03-07 13:58:49 -08:00
Daniel Rosenberg
dda598103d Add vdc checkpoint restoreCheckpointPart
Restores the first n entries of a checkpoint. Allows automated testing
of interrupted restores.

Test: vdc checkpoint restoreCheckpoint [device] [n]
Change-Id: I47570e8eba0bc3c6549a04a33600df05d393990b
2019-03-07 13:58:49 -08:00
Daniel Rosenberg
cf9eb9b944 Merge "Switch Checkpoint Restore code to c style File ops" am: bc1901f8af am: 73cfd4918b
am: 1467b739da

Change-Id: Ib5513522c9819215e42f8960c9e6d2231d0cf40c
2019-03-06 22:26:43 -08:00
Daniel Rosenberg
1467b739da Merge "Switch Checkpoint Restore code to c style File ops" am: bc1901f8af
am: 73cfd4918b

Change-Id: I2df8869defe16ba3886f999dc993ab802b77086e
2019-03-06 22:21:45 -08:00
Daniel Rosenberg
73cfd4918b Merge "Switch Checkpoint Restore code to c style File ops"
am: bc1901f8af

Change-Id: I52f3551d5a86d7e2edbb116bec98e8d2a11535df
2019-03-06 22:16:41 -08:00
Daniel Rosenberg
bc1901f8af Merge "Switch Checkpoint Restore code to c style File ops" 2019-03-07 06:10:58 +00:00
Daniel Rosenberg
8271ae986e Switch Checkpoint Restore code to c style File ops
In preparation for restore code, we need to guarantee fsync happens.
Switch over to fd based operations to prepare for that.

Test: Successfully restores device over reboots
Change-Id: Ic9901779e8a4258bf8090d6a62fa9829e343fd39
2019-03-06 22:05:09 -08:00
Sudheer Shanka
8cad97b48f Pass unshared_obb flag to sdcardfs setup.
Bug: 110960295
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Change-Id: I945722849ce225ca701bba482c859f1a6567bb63
2019-03-05 14:43:14 -08:00
Jiyong Park
8d21c924d7 Don't unmount /storage for early native processes
Motivation:

Early processes launched before the runtime APEX - that hosts the bionic
libs - is activated can't use the bionic libs from the APEX, but from the
system partition (which we call the bootstrap bionic). Other processes
after the APEX activation should use the bionic libs from the APEX.
In order to let both types of processes to access the bionic libs via
the same standard paths /system/lib/{libc|libdl|libm}.so, some mount
namespace magic is used.

To be specific, when the device boots, the init initially bind-mounts
the bootstrap bionic libs to the standard paths with MS_PRIVATE. Early
processes are then executed with their own mount namespaces (via
unshare(CLONE_NEWNS)). After the runtime APEX is activated, init
bind-mounts the bionic libs in the APEX to the same standard paths.
Processes launched thereafter use the bionic libs from the APEX (which
can be updated.)

Important thing is that, since the propagation type of the mount points
(the standard paths) is 'private', the new bind-mount events for the
updated bionic libs should not affect the early processes. Otherwise,
they would experience sudden change of bionic libs at runtime. However,
other mount/unmounts events outside of the private mount points are
still shared across early/late processes as before. This is made possible
because the propagation type of / is 'shared' .

Problem:

vold uses the equality of the mount namespace to filter-out processes
that share the global mount namespace (the namespace of the init). However,
due to the aforementioned change, the early processes are not filtered
out because they have different mount namespaces. As a result,
umount2("/storage/") is executed on them and this unmount event
becomes visible to the global mount namespace (because as mentioned before /
is 'shared').

Solution:

Fiter-out the early processes by skipping a native (non-Java) process
whose UID is < AID_APP. The former condition is because all early
processes are native ones; i.e., zygote is started after the runtime
APEX is activated. The latter condition is to not filter-out native
processes created locally by apps.

Bug: 120266448
Test: m; device boots

Change-Id: I054deedc4af8421854cf35be84e14995523a259a
2019-03-04 16:22:41 +09:00