Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm verity: add "panic_on_corruption" error handling mode

Samsung smart phones may need the ability to panic on corruption. Not
all devices provide the bootloader support needed to use the existing
"restart_on_corruption" mode. Additional details for why Samsung needs
this new mode can be found here:
https://www.redhat.com/archives/dm-devel/2020-June/msg00235.html

Signed-off-by: jhs2.lee <jhs2.lee@samsung.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

JeongHyeon Lee and committed by
Mike Snitzer
e1fef0b0 374117ad

+18 -2
+4
Documentation/admin-guide/device-mapper/verity.rst
··· 83 83 not compatible with ignore_corruption and requires user space support to 84 84 avoid restart loops. 85 85 86 + panic_on_corruption 87 + Panic the device when a corrupted block is discovered. This option is 88 + not compatible with ignore_corruption and restart_on_corruption. 89 + 86 90 ignore_zero_blocks 87 91 Do not verify blocks that are expected to contain zeroes and always return 88 92 zeroes instead. This may be useful if the partition contains unused blocks
+12 -1
drivers/md/dm-verity-target.c
··· 30 30 31 31 #define DM_VERITY_OPT_LOGGING "ignore_corruption" 32 32 #define DM_VERITY_OPT_RESTART "restart_on_corruption" 33 + #define DM_VERITY_OPT_PANIC "panic_on_corruption" 33 34 #define DM_VERITY_OPT_IGN_ZEROES "ignore_zero_blocks" 34 35 #define DM_VERITY_OPT_AT_MOST_ONCE "check_at_most_once" 35 36 ··· 254 253 255 254 if (v->mode == DM_VERITY_MODE_RESTART) 256 255 kernel_restart("dm-verity device corrupted"); 256 + 257 + if (v->mode == DM_VERITY_MODE_PANIC) 258 + panic("dm-verity device corrupted"); 257 259 258 260 return 1; 259 261 } ··· 746 742 case DM_VERITY_MODE_RESTART: 747 743 DMEMIT(DM_VERITY_OPT_RESTART); 748 744 break; 745 + case DM_VERITY_MODE_PANIC: 746 + DMEMIT(DM_VERITY_OPT_PANIC); 747 + break; 749 748 default: 750 749 BUG(); 751 750 } ··· 912 905 913 906 } else if (!strcasecmp(arg_name, DM_VERITY_OPT_RESTART)) { 914 907 v->mode = DM_VERITY_MODE_RESTART; 908 + continue; 909 + 910 + } else if (!strcasecmp(arg_name, DM_VERITY_OPT_PANIC)) { 911 + v->mode = DM_VERITY_MODE_PANIC; 915 912 continue; 916 913 917 914 } else if (!strcasecmp(arg_name, DM_VERITY_OPT_IGN_ZEROES)) { ··· 1232 1221 1233 1222 static struct target_type verity_target = { 1234 1223 .name = "verity", 1235 - .version = {1, 6, 0}, 1224 + .version = {1, 7, 0}, 1236 1225 .module = THIS_MODULE, 1237 1226 .ctr = verity_ctr, 1238 1227 .dtr = verity_dtr,
+2 -1
drivers/md/dm-verity.h
··· 20 20 enum verity_mode { 21 21 DM_VERITY_MODE_EIO, 22 22 DM_VERITY_MODE_LOGGING, 23 - DM_VERITY_MODE_RESTART 23 + DM_VERITY_MODE_RESTART, 24 + DM_VERITY_MODE_PANIC 24 25 }; 25 26 26 27 enum verity_block_type {