Skip to content

Commit e1fef0b

Browse files
jhs2-leesnitm
authored andcommitted
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 <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 374117a commit e1fef0b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Documentation/admin-guide/device-mapper/verity.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ restart_on_corruption
8383
not compatible with ignore_corruption and requires user space support to
8484
avoid restart loops.
8585

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+
8690
ignore_zero_blocks
8791
Do not verify blocks that are expected to contain zeroes and always return
8892
zeroes instead. This may be useful if the partition contains unused blocks

drivers/md/dm-verity-target.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#define DM_VERITY_OPT_LOGGING "ignore_corruption"
3232
#define DM_VERITY_OPT_RESTART "restart_on_corruption"
33+
#define DM_VERITY_OPT_PANIC "panic_on_corruption"
3334
#define DM_VERITY_OPT_IGN_ZEROES "ignore_zero_blocks"
3435
#define DM_VERITY_OPT_AT_MOST_ONCE "check_at_most_once"
3536

@@ -254,6 +255,9 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,
254255
if (v->mode == DM_VERITY_MODE_RESTART)
255256
kernel_restart("dm-verity device corrupted");
256257

258+
if (v->mode == DM_VERITY_MODE_PANIC)
259+
panic("dm-verity device corrupted");
260+
257261
return 1;
258262
}
259263

@@ -742,6 +746,9 @@ static void verity_status(struct dm_target *ti, status_type_t type,
742746
case DM_VERITY_MODE_RESTART:
743747
DMEMIT(DM_VERITY_OPT_RESTART);
744748
break;
749+
case DM_VERITY_MODE_PANIC:
750+
DMEMIT(DM_VERITY_OPT_PANIC);
751+
break;
745752
default:
746753
BUG();
747754
}
@@ -907,6 +914,10 @@ static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
907914
v->mode = DM_VERITY_MODE_RESTART;
908915
continue;
909916

917+
} else if (!strcasecmp(arg_name, DM_VERITY_OPT_PANIC)) {
918+
v->mode = DM_VERITY_MODE_PANIC;
919+
continue;
920+
910921
} else if (!strcasecmp(arg_name, DM_VERITY_OPT_IGN_ZEROES)) {
911922
r = verity_alloc_zero_digest(v);
912923
if (r) {
@@ -1221,7 +1232,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
12211232

12221233
static struct target_type verity_target = {
12231234
.name = "verity",
1224-
.version = {1, 6, 0},
1235+
.version = {1, 7, 0},
12251236
.module = THIS_MODULE,
12261237
.ctr = verity_ctr,
12271238
.dtr = verity_dtr,

drivers/md/dm-verity.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
enum verity_mode {
2121
DM_VERITY_MODE_EIO,
2222
DM_VERITY_MODE_LOGGING,
23-
DM_VERITY_MODE_RESTART
23+
DM_VERITY_MODE_RESTART,
24+
DM_VERITY_MODE_PANIC
2425
};
2526

2627
enum verity_block_type {

0 commit comments

Comments
 (0)