android_system_core/set-verity-state
David Anderson 0aabcbc973 remount: Remove errno interaction from fs_mgr_overlayfs_teardown.
This patch eliminates errno as part of the return contract for
fs_mgr_overlayfs_teardown().

The non-standard use of implicit errno makes it extremely difficult to
reason about how these functions can fail. As it turns out,
fs_mgr_overlayfs_teardown has been consistently failing for a long time,
but in a place where errno isn't set, which meant "enable-verity" never
saw the failure.

The failure was originating from umount2(MNT_DETACH) which guaranteed
that DeleteBackingImage would fail with EBUSY, and DeleteBackingImage is
a binder call that doesn't set errno.

This patch switches to umount() and returns a "busy" status if the
unmount fails with EBUSY. In this case it will also disable the scratch
partition. There is a long-standing existing bug where, for non-VAB
devices, it will delete the underlying scratch partition off super. This
is pretty risky with MNT_DETACH, but that path is left unchanged here.

Some duplicated code in set-verity-state was refactored as well, since
the return value of fs_mgr_overlayfs_teardown is now more complex.

Bug: 241179247
Test: adb-remount-test.sh
Change-Id: I2ca75332b75a302622ba9b86d122a6f2accdda3e
2022-09-19 22:30:05 -07:00
..
.clang-format Move enable-verity/disable-verity out of adb to a helper binary. 2019-10-23 14:33:36 -07:00
Android.bp set-verity-state: Add -h -v -R (automatic reboot) options 2022-08-17 06:13:20 +00:00
OWNERS Add an OWNERS file for set-verity-state. 2022-08-05 21:09:05 +00:00
set-verity-state.cpp remount: Remove errno interaction from fs_mgr_overlayfs_teardown. 2022-09-19 22:30:05 -07:00