dm verity: correcting logic used with corrupted_errs counter
Subsystems (2)
One more question :
Current code has DM_VERITY_MAX_CORRUPTED_ERRS set to 100 can we
reduce this ? or is there any data that made us to keep this 100 ? Regards,
Ravi
-----Original Message-----
From: Ravi Kumar Siddojigari <[email protected]>
Sent: Wednesday, November 18, 2020 6:17 PM
To: '[email protected]' <[email protected]>
Subject: [PATCH] dm verity: correcting logic used with corrupted_errs counter
In verity_handle_err we see that the "corrupted_errs" is never going to be more than one as the code will fall through "out" label and hit panic/kernel_restart on the first error which is not as expected.. Following patch will make sure that corrupted_errs are incremented and only panic/kernel_restart once it reached DM_VERITY_MAX_CORRUPTED_ERRS.
--- drivers/md/dm-verity-target.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/dm-verity-target.c +0 -0
@@ -221,8 +221,10 @@ static int verity_handle_err(struct dm_verity *v, enum
verity_block_type type,
/* Corruption should be visible in device status in all modes */ v->hash_failed = 1;
- if (v->corrupted_errs >= DM_VERITY_MAX_CORRUPTED_ERRS)
+ if (v->corrupted_errs >= DM_VERITY_MAX_CORRUPTED_ERRS) {
+ DMERR("%s: reached maximum errors", v->data_dev->name);
goto out;
+ }
v->corrupted_errs++;
@@ -240,13 +242,13 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,
DMERR_LIMIT("%s: %s block %llu is corrupted", v->data_dev->name,
type_str, block);
- if (v->corrupted_errs == DM_VERITY_MAX_CORRUPTED_ERRS)
- DMERR("%s: reached maximum errors", v->data_dev->name);
snprintf(verity_env, DM_VERITY_ENV_LENGTH, "%s=%d,%llu",
DM_VERITY_ENV_VAR_NAME, type, block);
kobject_uevent_env(&disk_to_dev(dm_disk(md))->kobj, KOBJ_CHANGE,
envp);
+ /* DM_VERITY_MAX_CORRUPTED_ERRS limit not reached yet */
+ return 0;
out:
if (v->mode == DM_VERITY_MODE_LOGGING)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project