Commit graph

5718 commits

Author SHA1 Message Date
Nikita Ioffe
7f7850a648 Merge "vold: explicitly specify capabilities" am: 4af861b631 am: 8b23e23987
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2371428

Change-Id: Idba29df1b014fda9ee463af137bc310baaaabd65
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-03 14:26:05 +00:00
Nikita Ioffe
8b23e23987 Merge "vold: explicitly specify capabilities" am: 4af861b631
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2371428

Change-Id: Iafe087f3d1dd180069621cc9539803a4dda1bdda
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-03 13:55:07 +00:00
Nikita Ioffe
4af861b631 Merge "vold: explicitly specify capabilities" 2023-01-03 13:18:36 +00:00
Nikita Ioffe
a4c5f57f63 vold: explicitly specify capabilities
If a service doesn't specify any capabilities in it's definition in the
.rc file, then it will inherit all the capabilities from the init.
Although whether a process can use capabilities is actually controlled
by selinux (so inheriting all the init capabilities is not actually a
security vulnerability), it's better for defense-in-depth and just
bookkeeping to explicitly specify the capabilities that vold needs.

The list of capabilities that vold is allowed to use was obtained via:
```
$ adb pull /sys/fs/selinux/policy /tmp/selinux.policy
$ sesearch --allow -s vold -c capability,capability2 /tmp/selinux.policy
allow vold vold:capability { chown dac_override dac_read_search fowner fsetid kill mknod net_admin sys_admin sys_chroot sys_nice sys_ptrace };
allow vold vold:capability2 block_suspend
```

In addition, since vold execs the /system/bin/sdcard, which transitions
into sdcardd domain, we also need to add capabilities that are required
by /system/bin/sdcard:

```
sesearch --allow -s sdcardd -c capability,capability2 /tmp/selinux.policy
allow sdcardd sdcardd:capability { dac_override dac_read_search setgid setuid sys_admin sys_resource };
```

vold can also transform into the following domains which don't seem to
need any capabilities: blkid, blkid_untrusted, fsck, fsck_untrusted

vold can also transform into sgdisk domain, which only needs
CAP_SYS_ADMIN:

```
sesearch --allow -s sgdisk -c capability,capability2 /tmp/selinux.policy
allow sgdisk sgdisk:capability sys_admin
```

Bug: 249796710
Test: device boots
Test: prebumit
Change-Id: Ic2a35fd62d6ed8c7b305c23607e6c24b197cf6bc
2022-12-29 18:34:33 +00:00
Treehugger Robot
55f4d7442e Merge "Use sleep_for for fsck timeout" am: 0777c5d604 am: 93c9dbe115
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2311079

Change-Id: Id9d6ce3801debeaa06d2338bd9a914b4105d7afc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-17 01:57:41 +00:00
Treehugger Robot
93c9dbe115 Merge "Use sleep_for for fsck timeout" am: 0777c5d604
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2311079

Change-Id: I007ddd743a88a629fac27f6bf8575957661de955
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-17 01:22:47 +00:00
Treehugger Robot
0777c5d604 Merge "Use sleep_for for fsck timeout" 2022-12-17 00:28:27 +00:00
Daniel Rosenberg
8cd81faa71 Use sleep_for for fsck timeout
sleep may exit early due to interupts.
This ensures the full expected time elapses before timing out.

Bug: 258348748
Test: Mount removable storage with ~30K folders,
      observe timeout in logs
Change-Id: I8092d4be43b85c9a53e8bb2658316159ab93bfc2
2022-12-16 22:30:57 +00:00
Paul Lawrence
e65035d17d Merge "Add persist.sys.fuse.bpf.override" am: c4bc218452 am: 146112e660
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2355603

Change-Id: Iaed2486a7a3047802974ee5940ef64546dd22d1e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-16 17:56:12 +00:00
Paul Lawrence
146112e660 Merge "Add persist.sys.fuse.bpf.override" am: c4bc218452
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2355603

Change-Id: Ia2f439eb4761fa6f765e05e430b444b9dbd7f2b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-16 17:23:15 +00:00
Paul Lawrence
c4bc218452 Merge "Add persist.sys.fuse.bpf.override" 2022-12-16 16:49:54 +00:00
David Anderson
72b29de7eb Merge "Skip new userdata pre-create logic on kernels < 5.15." am: 1bb7a963c0 am: 3561a10403
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2352584

Change-Id: Ic3e026446032c2223a16ace645493f34db2e4bb6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-15 18:41:32 +00:00
David Anderson
3561a10403 Merge "Skip new userdata pre-create logic on kernels < 5.15." am: 1bb7a963c0
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2352584

Change-Id: I8679e8f50a3797397afc806efc67ee8542733cc0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-15 18:08:05 +00:00
David Anderson
1bb7a963c0 Merge "Skip new userdata pre-create logic on kernels < 5.15." 2022-12-15 17:26:59 +00:00
David Anderson
223c1b2499 Skip new userdata pre-create logic on kernels < 5.15.
Bug: 259328366
Test: table is not populated on 5.4
Change-Id: Idbf6aa11f25d5b9ba6b02917ae358f750da5fa48
2022-12-14 21:57:58 -08:00
Paul Lawrence
a688c4f1b2 Add persist.sys.fuse.bpf.override
Allows for easy override of fuse-bpf for testing without a rebuild

Test: Set this property with ro.fuse.bpf.enabled both true and false
      Make sure ro.fuse.bpf.is_running is expected result
Bug: 219958836
Change-Id: I589511ea5cda76db1d55bdc2124fb546907d8acd
2022-12-14 15:00:20 -08:00
Treehugger Robot
dc6ef047e2 Merge "Add ro.fuse.bpf.is_running" am: 1edb6550ab am: f0dec736c2
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2346803

Change-Id: I651eeeb640aa16ec35ad117cc9ac941c46c09acd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-13 16:26:07 +00:00
Treehugger Robot
f0dec736c2 Merge "Add ro.fuse.bpf.is_running" am: 1edb6550ab
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2346803

Change-Id: I384c0f605a2cf69430d4d6e1a9cde1358e715ae6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-13 15:56:11 +00:00
Treehugger Robot
1edb6550ab Merge "Add ro.fuse.bpf.is_running" 2022-12-13 15:22:48 +00:00
Paul Lawrence
8c250754a9 Add ro.fuse.bpf.is_running
s_running flag signals to tests whether fuse-bpf is running

Test: Builds, runs, ro.fuse.bpf.is_running is correct, fuse-bpf works
Bug: 202785178
Change-Id: I2b967567092da2fab90e44c44ff2e51b372b85ed
2022-12-12 17:08:42 -08:00
David Anderson
870ec56622 Merge "Populate the dm table of the early userdata device." am: 3937b479bd am: d334e77348
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2336136

Change-Id: I65c3cb33e0988f4212cb85600fc4cdda4d946382
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-12 19:25:04 +00:00
David Anderson
d334e77348 Merge "Populate the dm table of the early userdata device." am: 3937b479bd
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2336136

Change-Id: Iabe97790ca7753d4de9c8c612e900b4e5b64238f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-12 18:54:35 +00:00
David Anderson
3937b479bd Merge "Populate the dm table of the early userdata device." 2022-12-12 18:38:05 +00:00
Martijn Coenen
ba9d81bfc8 Merge "Support bind mounting volumes into other volume's mountpoint." am: 35eb1ae88a am: 1968bd5a1b
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2189643

Change-Id: I9712ae9dd4965ba0038b0b255294728462a2985a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-09 08:24:46 +00:00
Martijn Coenen
1968bd5a1b Merge "Support bind mounting volumes into other volume's mountpoint." am: 35eb1ae88a
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2189643

Change-Id: I3e0528ff7a114971a8b6da9cc939c3de0de9fd4f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-09 08:03:52 +00:00
Martijn Coenen
35eb1ae88a Merge "Support bind mounting volumes into other volume's mountpoint." 2022-12-09 07:42:00 +00:00
David Anderson
7b769bc5b1 Populate the dm table of the early userdata device.
DM_DEV_CREATE no longer creates sysfs nodes as of Linux kernel 5.15. It
is now necessary to DM_TABLE_LOAD as well.

Bug: 259328366
Test: userdata mounts
Change-Id: I0f88afdf95a97d44eb365e4302bbfdc7c28c0bcb
2022-12-08 16:23:45 -08:00
Martijn Coenen
73e3010a25 Support bind mounting volumes into other volume's mountpoint.
With the way the FUSE mount point are currently setup for emulated
volumes, there can be multiple paths that serve the same files on the
lower filesystem; eg

* /mnt/user/0/emulated/0/Android
* /mnt/user/10/emulated/0/Android

both refer to the same file on the lower filesystem:
* /data/media/0/Android

this is normally not a problem, because cross-user file access is not
allowed, and so the FUSE daemon won't serve files for other users.

With clone profiles this is no longer true however, as their volumes
are accessible by each other.

So, it can happen that an app running in clone profile 10 accesses
"/mnt/user/10/emulated/0/Android", which would be served by the FUSE
daemon for the user 10 filesystem.

At the same time, an app running in the owner profile 0 accesses
"mnt/user/0/emulated/0/Android", which would be served by the FUSE
daemon for the user 0 filesystem.

This can cause page cache inconsistencies, because multiple FUSE daemons
can be running on top of the same entries in the lower filesystem.

To prevent this, use bind mounts to make sure that cross-profile
accesses actually end up in the FUSE daemon to which the volume
belongs: "/mnt/user/10/emulated/0" is bind-mounted to
"/mnt/user/0/emulated/0", and vice-versa.

Bug: 228271997
Test: manual
Change-Id: Iefcbc813670628b329a1a5d408b6126b84991e09
2022-12-07 09:01:27 +00:00
Treehugger Robot
910acad3c3 Merge "Ignore DE retrieveKey failure for non-user-0" am: 1cb65f9de5 am: c63d77bc61
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242642

Change-Id: I638cd7a1e85a670352054ec44308e4e3bba25ee6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-29 03:17:33 +00:00
Treehugger Robot
c63d77bc61 Merge "Ignore DE retrieveKey failure for non-user-0" am: 1cb65f9de5
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242642

Change-Id: Iecab2ad6f570e4083c1ad8dc8b432c56125befa4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-29 02:17:11 +00:00
Treehugger Robot
1cb65f9de5 Merge "Ignore DE retrieveKey failure for non-user-0" 2022-11-29 01:19:25 +00:00
liulvping
69b048507f Ignore DE retrieveKey failure for non-user-0
retrieveKey can fail in load_all_de_keys if a user
is partially removed, i.e. cases where
fscrypt_destroy_user_key() got interrupted. So just
ignore the failure, else could reboot into recovery.

Test: pm create-user foo
      pm remove-user 10
      adb reboot && check device not enter recovery

Signed-off-by: liulvping <liulvping@xiaomi.com>
Change-Id: Iba9d53a0833524d00e65d0427ab03002c5d8d509
2022-11-25 00:59:14 +00:00
Paul Crowley
54654ba918 Merge "Fix unhandled exception when FUSE disabled" am: 20b1532b85 am: 3589e76deb
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2282933

Change-Id: I55051756a3d2821b51146951f7b06ba2931afd3f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-09 14:38:07 +00:00
Paul Crowley
3589e76deb Merge "Fix unhandled exception when FUSE disabled" am: 20b1532b85
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2282933

Change-Id: Iaceb4670a0032ac31bfe330e3f879b06fa351050
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-09 14:09:34 +00:00
Paul Crowley
20b1532b85 Merge "Fix unhandled exception when FUSE disabled" 2022-11-09 13:42:39 +00:00
Oleg Lyovin
667de184ed Fix unhandled exception when FUSE disabled
When running on kernel without FUSE, fs::directory_iterator
throws exception since /sys/fs/fuse/connections is missing.

This patch uses non-throwing fs::directory_iterator
and adds explicit error check.

Test: vold doesn't fail with FUSE disabled
Signed-off-by: Oleg Lyovin <ovlevin@sberdevices.ru>
Change-Id: I51b68363edf75033fcec3ce5623f419d5a68c991
2022-11-08 18:49:18 +03:00
Eric Biggers
72f359dd27 Merge "Stop using the "stretching" file" am: b0a170136c am: 20695553e1
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2252876

Change-Id: I99d3b6ab789c897ae888e83b5e5130f877ab3768
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-13 20:55:57 +00:00
Eric Biggers
20695553e1 Merge "Stop using the "stretching" file" am: b0a170136c
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2252876

Change-Id: Idc5c0d3e11e9091e4c83d34188d961d5531718e3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-13 20:17:14 +00:00
Eric Biggers
b0a170136c Merge "Stop using the "stretching" file" 2022-10-13 19:46:32 +00:00
Eric Biggers
f187f05110 Stop using the "stretching" file
As a small optimization and code simplification, stop reading and
writing the "stretching" file alongside each stored key.  vold never
does key stretching anymore.

There was one special case in the code where if the stretching file
existed and contained "nopassword", then the secret was ignored.
However, this didn't seem to be of any use, especially since it didn't
cause Keystore to be used, so it did *not* allow a key stored with no
secret to be read if a secret was unexpectedly provided.

Bug: 232452368
Bug: 251131631
Bug: 251147505
Change-Id: I5a7cbba7492526e51c451f222b9413d9fae6bce5
2022-10-13 04:11:27 +00:00
Eric Biggers
1118f5fc4e Merge "Don't use a secdiscardable file for keys encrypted by SP" am: 7cc31eb7b0 am: da999d55e5
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242561

Change-Id: Id33248ab1c5f46ae350dd73a826bb4797f0584c4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-10 17:23:42 +00:00
Eric Biggers
da999d55e5 Merge "Don't use a secdiscardable file for keys encrypted by SP" am: 7cc31eb7b0
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242561

Change-Id: Id6c2f7797065a1bdec29996ef8433b8721bacfa7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-10 16:55:00 +00:00
Eric Biggers
7cc31eb7b0 Merge "Don't use a secdiscardable file for keys encrypted by SP" 2022-10-10 16:26:26 +00:00
Eric Biggers
08f4bdfe98 Don't use a secdiscardable file for keys encrypted by SP
Storage keys that are encrypted by the user's synthetic password don't
need to be securely deletable by vold, since secure deletion is already
implemented at a higher level: the synthetic password protectors managed
by LockSettingsService.  Therefore, remove the use of the secdiscardable
file by vold in this case to improve performance.

Bug: 232452368
Bug: 251131631
Bug: 251147505
Change-Id: I847d6cd3b289dbeb1ca2760d6e261a78c179cad0
2022-10-07 16:26:29 +00:00
Eric Biggers
17cf387bca Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2 am: c33624f8b2 am: cfa19bbb92 am: 56c8e62553
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I564af10985e9f957d981f9985f1c0bfe18a107d6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 18:38:39 +00:00
Eric Biggers
56c8e62553 Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2 am: c33624f8b2 am: cfa19bbb92
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I2e226ca8f977ca2f0297754808ebd78d2b0a1b8b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 17:56:58 +00:00
Eric Biggers
cfa19bbb92 Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2 am: c33624f8b2
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I29988364b1584f326b39fdabeb4b51d167758aa5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 17:27:23 +00:00
Eric Biggers
c33624f8b2 Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I73de338c1bd35c3257a473183bf0e0cfebe179b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 16:57:43 +00:00
Eric Biggers
03ad91c3c2 Merge "cryptfs: Update the size of dm-crypt device according to sector size" 2022-09-29 16:26:44 +00:00
Hongyu Jin
8eeb028338 cryptfs: Update the size of dm-crypt device according to sector size
The legacy method for metadata encryption on adoptable storage failed
when the size of the block device isn't a multiple of the crypto sector size.

Update the size of dm-crypt device according to sector size
before construct dm_target.

Bug: 248582018
Change-Id: I5c78889bdfedca7f7b0704500fc313d7a48d5a3b
Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com>
2022-09-28 17:44:44 +08:00