Commit graph

6178 commits

Author SHA1 Message Date
Eric Biggers
cc2f93829c Merge "Delete unused code conditional on MANAGE_MISC_DIRS" into main 2024-02-27 23:51:33 +00:00
Eric Biggers
d0e9a59885 Delete unused code conditional on MANAGE_MISC_DIRS
Since MANAGE_MISC_DIRS is hardcoded to 0, and it always has been, there
is no need to have it in the code.

Test: build
Change-Id: I30a73e67999841271e07dbc3eeb1b8568529a7c3
2024-02-27 03:00:34 +00:00
Treehugger Robot
527a52874e Merge "Reduce AppFuse max read size." into main 2024-02-19 10:39:40 +00:00
David Anderson
f75d8fc237 Merge "Add API to get remaining lifetime as a percentage." into main 2024-02-01 04:51:03 +00:00
David Anderson
0620564ecb Add API to get remaining lifetime as a percentage.
This differs slightly from the previous API, which exists for idle
maintenance, whereas this value is intended to be displayed to users.
First, it returns remaining lifetime, rather than used lifetime. Second,
it rounds up the returned value for usabilty purposes. This isn't an
issue on Pixel (which reports at 1% granularity), but devices which
report at 10% granularity should show 100% out-of-box, which is not
possible to distinguish in the old API.

Bug: 309886423
Test: StorageManager.getRemainingStorageLifetime
Change-Id: Ic5f6ec9969667302ba8bad95b2765e2cc740bed4
2024-01-31 22:50:18 +00:00
Neil Fuller
5b711b10db Merge "Add time_offset=<UTC offset> to mount arguments" into main 2024-01-19 17:26:00 +00:00
Neil Fuller
6eea031719 Add time_offset=<UTC offset> to mount arguments
Add time_offset=<UTC offset> to mount arguments for the vfat driver.

This is not being release flagged as it's a fix for a regression but is
a cosmetic fix that shouldn't affect anything besides reported file
timestamps.

Changes for issue 246256335 in Android U stopped Android syncing the
current time zone UTC offset to the kernel because doing so is
discouraged. It is discouraged because the current offset alone is not
very useful - it tells the kernel nothing of DST or historic UTC
offsets. Converting to and from local times are are best left to
userspace where time zone rules information is available, and different
users can use different time zones.

However, because FAT32 is poorly designed WRT timestamps, the kernel
FAT32 driver, vfat, does use the kernel offset when available and when
it isn't given a fixed offset to use at volume mount time. This means
that Android devices after the change from issue 246256335 displayed
more obviously incorrect times.

This change adds the argument necessary to vold when mounting a FAT32
volume to set a fixed UTC offset to adjust FAT32 local times
to a UTC-like time ("UTC time" from now on). Userspace then uses the UTC
offset for that UTC time, calculated using TZDB rules, to convert back
to a local time. This is still prone to generating some incorrect times,
e.g. due to DST or other historic offset changes, or a user time zone
change on device after mounting the volume. FAT32 lacks the information
about "what was the UTC offset at file time X?" (unlike exFAT) AND the
vfat driver has no way to look up the time zone rules itself. This
change is a reasonable "better than nothing" change to address times
being obviously wrong after the change from issue 246256335, especially
when a user copies a file from a desktop computer to USB / sd card
storage and immediately plugs the device into an Android device. It does
this without reverting to kernel UTC offset syncing, which is flawed
(i.e. it would never work completely), discouraged, and more effort/code
to improve, e.g. because userspace would have to schedule alarms for
offset changes.

Testing:

1) Obtain a USB FAT32 formatted USB storage device that can be plugged into
   a pixel device, e.g. with an OTG USB adapter.
2) On a desktop computer, mount the device and write some files / note
   times associated with existing files. These times will already be
   adjusted by this OS to be "local time" based on its own logic, but if
   it's working correctly that time will be exactly the local time value
   stored in the FAT32 volume itself.
3) On a rooted Android device where you can use adb via Wifi (adb tcpip
   / adb connect), leaving the USB port free for external USB devices....
   a) $ adb root
   b) Insert the USB storage
   c) $ mount | grep 'fat'
   d) For the USB storage drive, observe the time_offset argument (or
   tz=UTC when time_offset == 0) reported (this would not be reported
   without this patch)
   e) ls -l /mnt/<mount location from (3c)>
   f) Confirm the local time displayed is as expected. e.g. the time
   should be the same as shown in (2), regardless of the device's time
   zone.
4) To observe the "fixed offset behavior" at mount time, alter the time
   zone setting on the device via Settings -> System -> Date & Time
   a) Repeat 3c-3e.
   b) The times shown will have changed by the difference between
   the original and new time zone chosen.
   c) Extract / re-insert the USB storage device.
   d) Repeat 3c-3e
   e) The times shown should match the times from (2) again
5) Confirm the write behavior:
   a) $ touch /mnt/<mount location from (3c)>/foobar
   b) $ ls -l /mnt/<mount location from (3c)>
   c) The time should match the device's displayed local time (status
   bar)
   d) Unmount the USB device and insert the USB device into a desktop computer
   e) Confirm the timestamp matches the Android device's local time when
   (5a) took place, e.g. using "ls -lT" on MacOS.

Testing was done with numerous zones with positive, negative and zero offsets.
Interesting zones like India (UTC+5:30), Kiribati (UTC+14), Wake Island
(UTC-11), the various fixed offset zones like Etc/GMT+12, Etc/GMT-14
were tried.

Note: Depending on the time zones being used on devices (Android and
desktop) and when the files were written / testing took place during the
year, you may see file times shifting by 1 hour from the "ls -l" step
depending on whether they were written in summer or winter time.  This
is because the userspace code for rendering times knows about DST but
the kernel driver is applying a fixed offset and does not.  This is
expected and illustrates the points at the top of this comment about
FAT32 integration never being perfect.
See https://www.google.com/search?q=fat32+dst for other examples.

Bug: 319417938
Bug: 315058275
Bug: 246256335
Test: See above
Change-Id: Ic7ce159d88db5d5cf5894bcc26ea60bd7c44917d
2024-01-19 16:51:20 +00:00
Treehugger Robot
55af483b78 Merge "Don't use std::allocator::pointer" into main 2024-01-11 21:22:05 +00:00
Tomasz Wasilczyk
786b395266 Don't use std::allocator::pointer
It's removed in C++20

Bug: 175635923
Test: m MODULES-IN-system-vold
Change-Id: Ief2875bfd3e2d2e5023ad4c0bb754a616fd42419
2024-01-10 00:01:58 +00:00
Eric Biggers
7730a4944f Merge "Remove userSerial param from vold methods that don't use it" into main 2024-01-05 19:09:29 +00:00
Eric Biggers
a5a468c431 Remove userSerial param from vold methods that don't use it
createUserStorageKeys(), unlockCeStorage(), and prepareUserStorage()
have a user serial number parameter, but they don't actually do anything
with it except log it.  Remove this unnecessary parameter.

Bug: 316035110
Test: presubmit
Flag: N/A, mechanical refactoring
Change-Id: I73ebae1afb2bdb7ca856b40b34ce806fdda718fe
2024-01-04 22:39:43 +00:00
Eric Biggers
69c4d769ed Merge "vold: remove session keyring workaround for old kernels" into main 2024-01-04 18:21:23 +00:00
Eric Biggers
0e87a83cba vold: remove session keyring workaround for old kernels
The android-4.14-stable and later kernels support the
FS_IOC_ADD_ENCRYPTION_KEY and FS_IOC_REMOVE_ENCRYPTION_KEY ioctls.  This
has superseded the old way of adding fscrypt keys to the kernel, which
was to use the add_key() syscall to add keys to the "session" keyring.
On kernels that support the ioctls, Android doesn't use the obsolete
way.  Since upgrading even just to Android 14 requires at minimum a
android-4.14-stable kernel (according to
https://source.android.com/docs/core/architecture/kernel/android-common#compatibility-matrix),
there is no need to support the obsolete way anymore.

Therefore, this commit removes the code that added and removed keys
to/from the session keyring.  Now the ioctls are used unconditionally.

Flag: N/A for the following reasons:
      - Removing obsolete code, which is fairly safe
      - Very early code, so runtime flag cannot be used
      - This topic also removes code from init, which cannot use aconfig
        libraries because they do not support recovery_available

Bug: 311736104
Test: Build and boot Cuttlefish
Change-Id: I0d9abbda77b1ac838ea6f014dbe22ab032c0e5ae
2023-12-05 19:39:33 +00:00
Hyeeun Jun
fb014fc6e8 Reduce AppFuse max read size.
Since the max read size of FUSE is 128KB in default, the socket header
of the appfuse epollcontroller is allocated in order 4 (64KB).  When
memory environment is in insufficient situation that has a lot of
fragment, order 4 size memory allication is impossible, so more than
several tens of seconds could take to allocate the socket header.

To prevent the issue, limit the fuse read size to 64KB, so that the
memory allocation order of the socket header is changed to order 2.

Bug: 312503249
Test: atest AppFusePerfTest
Change-Id: I7020801b7539d980515885396916f8be1f1008e9
2023-12-05 08:11:21 +00:00
Daniel Rosenberg
a6fcafe382 Merge "Add support for 16k F2FS" into main am: 1dd20644dc
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2836451

Change-Id: I2be3d858550a9a24524db0bf1cafbe0b671b1da4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-01 22:36:30 +00:00
Daniel Rosenberg
1dd20644dc Merge "Add support for 16k F2FS" into main 2023-12-01 21:16:02 +00:00
Daniel Rosenberg
fb2bf902fd Add support for 16k F2FS
Currently F2FS block size must match page size, so this just does that.
If we support page size != block size for F2FS, this should be
revisited.

Bug: 279820706
Test: Boot 16K device
Change-Id: I6b3b367cdf76ccf5b2c5d309499027a5e7383a44
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2023-12-01 01:07:22 +00:00
Jaegeuk Kim
ffa86e0a00 Merge "Use logical path to handle different dm target per boot" into main am: c322b82524
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2825095

Change-Id: I7ac7964c817d1004e8975f793feb280072b9c3a5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-15 02:11:58 +00:00
Jaegeuk Kim
c322b82524 Merge "Use logical path to handle different dm target per boot" into main 2023-11-15 01:38:42 +00:00
Jaegeuk Kim
95c61b3391 Use logical path to handle different dm target per boot
When using multiple partitions, f2fs stores all the device paths, but we cannot
guarantee the dm targets are all the same across boot cycles.

Bug: 287247093
Change-Id: Ie4308a27548d4e814924afb656478cfa55fcf8b6
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2023-11-13 16:59:56 -08:00
Jahdiel Alvarez
f97bb9485e Merge "Verify if pid actually killed for processes with open files" into main am: ef22c8f122
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2806219

Change-Id: I0b4d38161da10dfa2532931e58bbe13164c8073a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-01 18:20:51 +00:00
Jahdiel Alvarez
ef22c8f122 Merge "Verify if pid actually killed for processes with open files" into main 2023-11-01 18:02:35 +00:00
Jahdiel Alvarez
d7c42966b9 Verify if pid actually killed for processes with open files
Its possible for vold to read a pid from procfs, the pid is killed
externally and then vold tries to kill it. In this scenario, we sleep
for 5s without needing it. Verify the return value from the kill syscall
and validate that the pid was killed, if the pid didn't exist at the
moment of the kill call, then don't count the pid as being killed.

Test: Boots successfully
Bug: 307801020
Change-Id: Ie127108b85be7249cf8b2881f4917d653d032186
2023-10-30 09:50:48 -07:00
Eric Biggers
7eb9a899be Merge "Rename "user key" methods in vold" into main am: b5c02ec925
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2787028

Change-Id: I5325a46b67cb76319a7d1f06f76e46587be78b08
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-25 16:42:06 +00:00
Eric Biggers
b5c02ec925 Merge "Rename "user key" methods in vold" into main 2023-10-25 16:24:44 +00:00
Eric Biggers
a53a66caed Rename "user key" methods in vold
Rename methods that refer to "user key" to be more precise about what
they mean.  For more details, see the corresponding frameworks/base
changes (I202ebbfd2b4f79fedb3ed120a8ad81500c126894 and
I5894beb97823dced5954e405d779fada49c79e8d).

No change in behavior except for some changed log messages.

Flag: exempt, mechanical refactoring only
Test: presubmit
Change-Id: I9edcb557172395f4f6cf8e837efcc06fcfefb37d
2023-10-19 19:58:46 +00:00
Eric Biggers
c6fa21391c Merge changes If530edaf,I7f11a135,I28412f24,Ia27a61fa,If221e239 into main am: f15785a54d am: 56e7c29466 am: 24a5445880 am: 1a2598d77d
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777079

Change-Id: I87f95a1074b6c82778cb63ca264e97cf1c3c2b4f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 22:18:56 +00:00
Eric Biggers
7177cdad85 Evict adoptable storage CE and DE keys when possible am: 1eddb7cb6d am: 51961be5c0 am: 11dd35816f am: 7ad54533d6
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2685268

Change-Id: I71abfc49d44359f20c71acca7e00194092e6e129
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 22:18:54 +00:00
Eric Biggers
e37ee0f1d7 Don't erase key from s_new_ce_keys on eviction am: 0798ed5470 am: 5c04a6034f am: a5c24c9b89 am: 9cd6136633
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777078

Change-Id: I877cd0acef6c49abc15adf08be77de0678a836e8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 22:18:51 +00:00
Eric Biggers
87ee928382 Call fscrypt_destroy_volume_keys() under mCryptLock am: 7862729266 am: 82b0c1e67f am: b14cdca7e7 am: 04304226f9
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777077

Change-Id: I09878f85d51a1345bf8eb5e81a0c1959788373e3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 22:18:49 +00:00
Eric Biggers
f3b0d263f5 Fold read_and_install_user_ce_key() into fscrypt_unlock_user_key() am: fc1df0eae0 am: db7a017bdd am: 988342f572 am: 66fdfbcfe3
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777076

Change-Id: Ia8f13fc2a170938524772a3b70fe475451adf619
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 22:18:47 +00:00
Eric Biggers
1a2598d77d Merge changes If530edaf,I7f11a135,I28412f24,Ia27a61fa,If221e239 into main am: f15785a54d am: 56e7c29466 am: 24a5445880
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777079

Change-Id: I8cfec06342f3c41e1b0f078003206cca8abf3689
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:46:27 +00:00
Eric Biggers
7ad54533d6 Evict adoptable storage CE and DE keys when possible am: 1eddb7cb6d am: 51961be5c0 am: 11dd35816f
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2685268

Change-Id: Icbdc9126a4ff2738bd5c3bd09e80aaa55076bec6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:46:24 +00:00
Eric Biggers
9cd6136633 Don't erase key from s_new_ce_keys on eviction am: 0798ed5470 am: 5c04a6034f am: a5c24c9b89
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777078

Change-Id: I1ad69037eee1e20549eba3e878781994313c079b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:46:21 +00:00
Eric Biggers
04304226f9 Call fscrypt_destroy_volume_keys() under mCryptLock am: 7862729266 am: 82b0c1e67f am: b14cdca7e7
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777077

Change-Id: I462653f9791c70afc26aba229cf2c0fa40cd9b73
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:46:17 +00:00
Eric Biggers
66fdfbcfe3 Fold read_and_install_user_ce_key() into fscrypt_unlock_user_key() am: fc1df0eae0 am: db7a017bdd am: 988342f572
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777076

Change-Id: Ie1e999b1257d1a38a81f53cf7ff705869c11ad52
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:46:14 +00:00
Eric Biggers
24a5445880 Merge changes If530edaf,I7f11a135,I28412f24,Ia27a61fa,If221e239 into main am: f15785a54d am: 56e7c29466
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777079

Change-Id: I138a741fd8c39a9c88397b7ae9d34f47cdd81859
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:13:35 +00:00
Eric Biggers
11dd35816f Evict adoptable storage CE and DE keys when possible am: 1eddb7cb6d am: 51961be5c0
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2685268

Change-Id: If66c6364c4ee40ffd512f0d903a9b478b6f9cf6e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:13:33 +00:00
Eric Biggers
a5c24c9b89 Don't erase key from s_new_ce_keys on eviction am: 0798ed5470 am: 5c04a6034f
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777078

Change-Id: I921d6e3bcb4fbf8bf403fbc252451549c8790c5c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:13:30 +00:00
Eric Biggers
b14cdca7e7 Call fscrypt_destroy_volume_keys() under mCryptLock am: 7862729266 am: 82b0c1e67f
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777077

Change-Id: I1c408c84b2852b67558a93fc34b02c6fa11043e9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:13:27 +00:00
Eric Biggers
988342f572 Fold read_and_install_user_ce_key() into fscrypt_unlock_user_key() am: fc1df0eae0 am: db7a017bdd
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777076

Change-Id: I0688fcde6f17fddfa49f3bbb0f1283eb73ccb906
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 21:13:24 +00:00
Eric Biggers
56e7c29466 Merge changes If530edaf,I7f11a135,I28412f24,Ia27a61fa,If221e239 into main am: f15785a54d
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777079

Change-Id: I7272ff8c06c5bc98f8c0934bbcc601a7daf5bc18
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 20:39:10 +00:00
Eric Biggers
51961be5c0 Evict adoptable storage CE and DE keys when possible am: 1eddb7cb6d
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2685268

Change-Id: I7b9e1a5591ca10ac4e3c73d50bdd64d1d9b3231d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 20:39:08 +00:00
Eric Biggers
5c04a6034f Don't erase key from s_new_ce_keys on eviction am: 0798ed5470
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777078

Change-Id: Ie8d1225a60de51466682e8314a1fb57eaf38c2e5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 20:39:04 +00:00
Eric Biggers
82b0c1e67f Call fscrypt_destroy_volume_keys() under mCryptLock am: 7862729266
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777077

Change-Id: I8cccab648454b7d7b3a3ec1946d3ff56f2e53fa1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 20:39:01 +00:00
Eric Biggers
db7a017bdd Fold read_and_install_user_ce_key() into fscrypt_unlock_user_key() am: fc1df0eae0
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2777076

Change-Id: I6077b8454dc1c69e263186bdf36f3467af4c6bb0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-06 20:38:57 +00:00
Eric Biggers
f15785a54d Merge changes If530edaf,I7f11a135,I28412f24,Ia27a61fa,If221e239 into main
* changes:
  Revert "fskeyring & userspace reboot: support CE keys"
  Evict adoptable storage CE and DE keys when possible
  Don't erase key from s_new_ce_keys on eviction
  Call fscrypt_destroy_volume_keys() under mCryptLock
  Fold read_and_install_user_ce_key() into fscrypt_unlock_user_key()
2023-10-06 19:52:39 +00:00
Eric Biggers
01604fb13f Revert "fskeyring & userspace reboot: support CE keys"
Userspace reboot turned out to be a dead end and is no longer supported.
Therefore, remove the code from vold that handled keeping CE storage
unlocked past the userdata filesystem being unmounted and mounted.

This is a revert of commit 1c6731c649 (https://r.android.com/1254615)
with various conflicts resolved.

Bug: 292469129
Change-Id: If530edaf7c1566dd3bd8b1322f935f38a2e66beb
Merged-In: If530edaf7c1566dd3bd8b1322f935f38a2e66beb
(cherry picked from commit 2b97a88ba4)
2023-10-06 15:30:18 +00:00
Eric Biggers
1eddb7cb6d Evict adoptable storage CE and DE keys when possible
Adoptable storage CE and DE keys were not being explicitly evicted,
resulting in the benefits of key eviction not being fully realized on
devices that use adoptable storage.  Fix this by evicting the adoptable
storage keys when the corresponding internal storage keys are evicted:

- In lockUserKey, evict the CE keys for adoptable storage volumes, not
  just the CE key for internal storage as was done before.

- In destroyUserKey, evict the user's CE and DE keys for adoptable
  storage, not just the internal storage keys as was done before.

To make this possible, starting keeping track of the EncryptionPolicy of
each currently installed adoptable storage key.

(This CL is reworked from https://r.android.com/2660878,
 original author Arnab Sen <arnabse@amazon.com>)

Test: On Cuttlefish with config_multiuserMaxRunningUsers changed to 1:
    sm set-virtual-disk true
    sm partition disk:7,416 private
    pm create-user 10
    am start-user 10
    am stop-user 10
    # Verified that this fails with "Required key not available".
    touch /mnt/expand/f1ad173b-d6d9-4948-8eb7-ccdd7b053b22/misc_ce/10/foo.txt
    am start-user 10
    pm remove-user 10
    # Checked for all the expected "Evicted fscrypt key" messages.
    # 2 from when user was stopped, and 4 from when user was removed.
    adb logcat | grep Evicted

Change-Id: I7f11a135d8550618cd96013f834cebd54be5ef84
Merged-In: I7f11a135d8550618cd96013f834cebd54be5ef84
(cherry picked from commit 68fd3689a1)
2023-10-06 15:30:16 +00:00
Eric Biggers
0798ed5470 Don't erase key from s_new_ce_keys on eviction
Erasing a key from s_new_ce_keys is equivalent to destroying it, so it
shouldn't be done when the key is merely being evicted.

This didn't matter in practice since eviction requests don't come in
before the key gets persisted, but fix this to avoid confusion.

Test: see I7f11a135d8550618cd96013f834cebd54be5ef84
Change-Id: I28412f243925b5a7242449b617fe9de9c90912b6
Merged-In: I28412f243925b5a7242449b617fe9de9c90912b6
(cherry picked from commit 3529302ede)
2023-10-06 15:30:15 +00:00