summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorPatrik Torstensson <totte@google.com>2018-04-13 15:34:48 -0700
committerAmit Pundir <amit.pundir@linaro.org>2018-07-19 21:59:32 +0530
commit4ab0d1112ded33e922a23b515646abcef66a957a (patch)
tree3775b7e19fc0c9b5794dc8a587c3a633f7db23ff /drivers/md
parent7dccf52f645f1b0f1fa61b5282328071e2e0bbcc (diff)
ANDROID: Add kconfig to make dm-verity check_at_most_once default enabled
This change adds a kernel config for default enable the check_at_most_once dm-verity option. This is to give us the ability to enforce the usage of at_most_once for entry-level phones. Change-Id: Id40416672c4c2209a9866997d8c164b5de5dc7dc Signed-off-by: Patrik Torstensson <totte@google.com> Bug: 72664474
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/Kconfig20
-rw-r--r--drivers/md/dm-verity-target.c8
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 5649d1ab0083..95de7ee56dfc 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -545,4 +545,24 @@ config DM_ANDROID_VERITY
of the metadata contents are verified against the key included
in the system keyring. Upon success, the underlying verity
target is setup.
+
+config DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED
+ bool "Verity will validate blocks at most once"
+ depends on DM_VERITY
+ ---help---
+ Default enables at_most_once option for dm-verity
+
+ Verify data blocks only the first time they are read from the
+ data device, rather than every time. This reduces the overhead
+ of dm-verity so that it can be used on systems that are memory
+ and/or CPU constrained. However, it provides a reduced level
+ of security because only offline tampering of the data device's
+ content will be detected, not online tampering.
+
+ Hash blocks are still verified each time they are read from the
+ hash device, since verification of hash blocks is less performance
+ critical than data blocks, and a hash block will not be verified
+ any more after all the data blocks it covers have been verified anyway.
+
+ If unsure, say N.
endif # MD
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index ceff074b3b74..d2e3abc182b3 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -1053,6 +1053,14 @@ int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
goto bad;
}
+#ifdef CONFIG_DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED
+ if (!v->validated_blocks) {
+ r = verity_alloc_most_once(v);
+ if (r)
+ goto bad;
+ }
+#endif
+
v->hash_per_block_bits =
__fls((1 << v->hash_dev_block_bits) / v->digest_size);