diff options
author | Tao Bao <tbao@google.com> | 2015-07-10 21:09:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-10 21:09:40 +0000 |
commit | d2e77d6ec57cffe78002eb16664370318399d5f9 (patch) | |
tree | a02f7f08afaa9f2dba9c931e954717c13473f3f7 /tools/releasetools/common.py | |
parent | a69dcefda3ec493216f401117417d86f8ef757ac (diff) | |
parent | 7f8ecb7f5c21630a75c69d170ba2b401d7a311a5 (diff) | |
download | build-d2e77d6ec57cffe78002eb16664370318399d5f9.zip build-d2e77d6ec57cffe78002eb16664370318399d5f9.tar.gz build-d2e77d6ec57cffe78002eb16664370318399d5f9.tar.bz2 |
am 7f8ecb7f: Merge "Zero out blocks that may be touched by dm-verity." into mnc-dev
* commit '7f8ecb7f5c21630a75c69d170ba2b401d7a311a5':
Zero out blocks that may be touched by dm-verity.
Diffstat (limited to 'tools/releasetools/common.py')
-rw-r--r-- | tools/releasetools/common.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index e8ab5ec..a720abb 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -1253,7 +1253,23 @@ class BlockDifference(object): script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % ( self.device, ranges_str, self.tgt.TotalSha1(include_clobbered_blocks=True))) - script.Print('Verified the updated %s image.' % (partition,)) + + # Bug: 20881595 + # Verify that extended blocks are really zeroed out. + if self.tgt.extended: + ranges_str = self.tgt.extended.to_string_raw() + script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % ( + self.device, ranges_str, + self._HashZeroBlocks(self.tgt.extended.size()))) + script.Print('Verified the updated %s image.' % (partition,)) + script.AppendExtra( + 'else\n' + ' abort("%s partition has unexpected non-zero contents after OTA ' + 'update");\n' + 'endif;' % (partition,)) + else: + script.Print('Verified the updated %s image.' % (partition,)) + script.AppendExtra( 'else\n' ' abort("%s partition has unexpected contents after OTA update");\n' @@ -1286,6 +1302,15 @@ class BlockDifference(object): return ctx.hexdigest() + def _HashZeroBlocks(self, num_blocks): # pylint: disable=no-self-use + """Return the hash value for all zero blocks.""" + zero_block = '\x00' * 4096 + ctx = sha1() + for _ in range(num_blocks): + ctx.update(zero_block) + + return ctx.hexdigest() + # TODO(tbao): Due to http://b/20939131, block 0 may be changed without # remounting R/W. Will change the checking to a finer-grained way to # mask off those bits. |