From: "Ravi Kumar Siddojigari" <rsiddoji@codeaurora.org>
To: <linux-block@vger.kernel.org>
Subject: [PATCH] dm verity: correcting logic used with corrupted_errs counter
Date: Wed, 18 Nov 2020 18:17:25 +0530 [thread overview]
Message-ID: <001a01d6bda8$fd4aee30$f7e0ca90$@codeaurora.org> (raw)
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.
Signed-off-by: Ravi Kumar Siddojigari <rsiddoji@codeaurora.org>
---
drivers/md/dm-verity-target.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index f74982dcbea0..d86900a2a8d7 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -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
next reply other threads:[~2020-11-18 12:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 12:47 Ravi Kumar Siddojigari [this message]
2020-11-20 13:06 [PATCH] dm verity: correcting logic used with corrupted_errs counter Ravi Kumar Siddojigari
2020-12-02 18:05 Ravi Kumar Siddojigari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='001a01d6bda8$fd4aee30$f7e0ca90$@codeaurora.org' \
--to=rsiddoji@codeaurora.org \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.