platform_system_core/fs_mgr/libdm
Yifan Hong a16f2c81a8 libsnapshot: snaity check overflow bit at the end of update
Make sure CoW device doesn't overflow. Otherwise, data previously
written to snapshot device may be overwritten.

This check acts as a safety guard to bug like b/145180464, where
the computed CoW device size is less than required, but cannot be
caught by FilesystemVerifierAction in update_engine.

Note that this is a sanity check. It doesn't prevent the following:
(1) write a snapshot until it overflows
(2) unmap and re-map the snapshot
(3) Call FinishedSnapshotWrites()

When a snapshot is re-mapped, DeviceMapper::GetTableStatus() won't
return "Overflow".

However, update_engine always writes the full hashtree / FEC / etc.
data (outside of |PartitionUpdate.operations|), calls
FinishedSnapshotWrites(), and then writes the checkpoint. If the process
is interrupted, update_engine does the full FilesystemVerifierAction
from the beginning. Snapshots aren't remapped during the process. Hence,
the hypothetical case above won't happen in reality (at time of writing)
until FilesystemVerifierAction is broken down into steps with
checkpoints.

Still, given the above hypothetical case, this function is only served
as a sanity check.

FinishedSnapshotWrites() now requires all snapshots to be mapped before
calling. Hence, tests needs to be fixed:
- For SnapshotTest (that tests SnapshotManager private APIs), map
  snapshot before calling FinishedSnapshotWrites().
- Factor out common code in SnapshotTest (PrepareOneSnapshot and
  SimulateReboot)
- For SnapshotUpdateTest and children, add MapUpdateSnapshots() helper
  and map all snapshots before calling FinishedSnapshotWrites().

Test: libsnapshot_test
Bug: 145180464

Change-Id: I3558dd1615059ba27f369c27af22e3c686e392f7
2019-12-09 16:06:03 -08:00
..
include/libdm libsnapshot: snaity check overflow bit at the end of update 2019-12-09 16:06:03 -08:00
Android.bp Fix fuzzer name and sizeof(array) 2019-10-21 11:44:08 +00:00
Android.mk Allow makefiles to be parsed in a trimmed down manifest. 2019-03-25 09:14:33 +00:00
AndroidTest.xml Make VTS run libdm_test 2019-03-22 15:11:49 -07:00
dm.cpp libsnapshot: snaity check overflow bit at the end of update 2019-12-09 16:06:03 -08:00
dm_linear_fuzzer.cpp Fix fuzzer name and sizeof(array) 2019-10-21 11:44:08 +00:00
dm_table.cpp libdm: Fix DmTable::num_sectors 2019-10-01 19:43:33 -07:00
dm_target.cpp Merge "Fix ext4/metadata/udc issue" 2019-08-27 15:21:58 +00:00
dm_test.cpp libdm: add an api to unwind dm stack 2019-12-06 22:10:45 +00:00
loop_control.cpp Fix fds libdm_test 2019-10-01 19:43:33 -07:00
loop_control_test.cpp libdm: Fix race conditions in LoopControl::Attach. 2019-07-11 15:39:53 -07:00
test_util.cpp libdm: Add unit tests for dm-linear. 2018-06-25 12:56:14 -07:00
test_util.h Move TempDevice to test_util.h 2019-10-10 20:59:33 +01:00
utility.cpp libdm: add an overload of DeleteDevice accepting a timeout_ms 2019-12-05 10:37:47 +00:00
utility.h libdm: add an overload of DeleteDevice accepting a timeout_ms 2019-12-05 10:37:47 +00:00