* [dm-devel] [PATCH] dm verity: fix error handling for check_at_most_once [not found] <CGME20230316031936epcas1p1ebd93477dcf3bf9ab1640306dd1da8ff@epcas1p1.samsung.com> @ 2023-03-16 3:18 ` Yeongjin Gil 0 siblings, 0 replies; 6+ messages in thread From: Yeongjin Gil @ 2023-03-16 3:18 UTC (permalink / raw) To: agk, snitzer, dm-devel; +Cc: Yeongjin Gil, Sungjong Seo, totte, linux-kernel In verity_work(), the return value of verity_verify_io() is converted to blk_status and passed to verity_finish_io(). BTW, when a bit is set in v->validated_blocks, verity_verify_io() skips verification regardless of I/O error for the corresponding bio. In this case, the I/O error could not be returned properly, and as a result, there is a problem that abnormal data could be read for the corresponding block. To fix this problem, when an I/O error occurs, do not skip verification even if the bit related is set in v->validated_blocks. Fixes: 843f38d382b1 ("dm verity: add 'check_at_most_once' option to only validate hashes once") Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> --- drivers/md/dm-verity-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index ade83ef3b439..9316399b920e 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -523,7 +523,7 @@ static int verity_verify_io(struct dm_verity_io *io) sector_t cur_block = io->block + b; struct ahash_request *req = verity_io_hash_req(v, io); - if (v->validated_blocks && + if (v->validated_blocks && bio->bi_status == BLK_STS_OK && likely(test_bit(cur_block, v->validated_blocks))) { verity_bv_skip_block(v, io, iter); continue; -- 2.39.2 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] dm verity: fix error handling for check_at_most_once @ 2023-03-16 3:18 ` Yeongjin Gil 0 siblings, 0 replies; 6+ messages in thread From: Yeongjin Gil @ 2023-03-16 3:18 UTC (permalink / raw) To: agk, snitzer, dm-devel; +Cc: totte, linux-kernel, Yeongjin Gil, Sungjong Seo In verity_work(), the return value of verity_verify_io() is converted to blk_status and passed to verity_finish_io(). BTW, when a bit is set in v->validated_blocks, verity_verify_io() skips verification regardless of I/O error for the corresponding bio. In this case, the I/O error could not be returned properly, and as a result, there is a problem that abnormal data could be read for the corresponding block. To fix this problem, when an I/O error occurs, do not skip verification even if the bit related is set in v->validated_blocks. Fixes: 843f38d382b1 ("dm verity: add 'check_at_most_once' option to only validate hashes once") Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> --- drivers/md/dm-verity-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index ade83ef3b439..9316399b920e 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -523,7 +523,7 @@ static int verity_verify_io(struct dm_verity_io *io) sector_t cur_block = io->block + b; struct ahash_request *req = verity_io_hash_req(v, io); - if (v->validated_blocks && + if (v->validated_blocks && bio->bi_status == BLK_STS_OK && likely(test_bit(cur_block, v->validated_blocks))) { verity_bv_skip_block(v, io, iter); continue; -- 2.39.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [dm-devel] [PATCH] dm verity: fix error handling for check_at_most_once 2023-03-16 3:18 ` Yeongjin Gil @ 2023-03-16 18:44 ` Eric Biggers -1 siblings, 0 replies; 6+ messages in thread From: Eric Biggers @ 2023-03-16 18:44 UTC (permalink / raw) To: Yeongjin Gil Cc: snitzer, totte, linux-kernel, Nathan Huckleberry, dm-devel, Sami Tolvanen, Sungjong Seo, agk Hi Yeongjin, On Thu, Mar 16, 2023 at 12:18:42PM +0900, Yeongjin Gil wrote: > In verity_work(), the return value of verity_verify_io() is converted to > blk_status and passed to verity_finish_io(). BTW, when a bit is set in > v->validated_blocks, verity_verify_io() skips verification regardless of > I/O error for the corresponding bio. In this case, the I/O error could > not be returned properly, and as a result, there is a problem that > abnormal data could be read for the corresponding block. > > To fix this problem, when an I/O error occurs, do not skip verification > even if the bit related is set in v->validated_blocks. > > Fixes: 843f38d382b1 ("dm verity: add 'check_at_most_once' option to only validate hashes once") > > Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > --- > drivers/md/dm-verity-target.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index ade83ef3b439..9316399b920e 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -523,7 +523,7 @@ static int verity_verify_io(struct dm_verity_io *io) > sector_t cur_block = io->block + b; > struct ahash_request *req = verity_io_hash_req(v, io); > > - if (v->validated_blocks && > + if (v->validated_blocks && bio->bi_status == BLK_STS_OK && > likely(test_bit(cur_block, v->validated_blocks))) { > verity_bv_skip_block(v, io, iter); > continue; Thanks for sending this patch! This looks like a correct fix, but I have some comments: * Using "check_at_most_once" is strongly discouraged, as it reduces security. If you are using check_at_most_once to improve performance at the cost of reduced security, please consider that very recently, dm-verity performance has significantly improved due to the removal of the WQ_UNBOUND workqueue flag which was causing significant I/O latency. See commit c25da5b7baf1 ("dm verity: stop using WQ_UNBOUND for verify_wq"). * I think your commit message does not explain a key aspect of the problem which is why is verity even attempted when the underlying I/O has failed? This appears to be because of the Forward Error Correction (FEC) feature. So, this issue is specific to the case where both FEC and check_at_most_once is used. Can you make your commit message explain this? * This patch does not appear to have been received by the dm-devel mailing list, which is the list where dm-verity patches should be reviewed on. It doesn't show up in the archive at https://lore.kernel.org/dm-devel. Also, I'm subscribed to dm-devel and I didn't receive this patch in my inbox. (I had to download it from https://lore.kernel.org/lkml instead.) Did you receive a bounce message when you sent this patch? * Please add 'Cc: stable@vger.kernel.org' to the commit message, just below the Fixes line, as per Documentation/process/stable-kernel-rules.rst. This will ensure that the fix will be backported to the stable kernels. * "Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>" does not have a corresponding Author or Co-developed-line, which is not allowed. Did you mean to list Sungjong as the Author or as a co-author? * No blank line between Fixes and the Signed-off-by line(s), please. Thanks! - Eric -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dm verity: fix error handling for check_at_most_once @ 2023-03-16 18:44 ` Eric Biggers 0 siblings, 0 replies; 6+ messages in thread From: Eric Biggers @ 2023-03-16 18:44 UTC (permalink / raw) To: Yeongjin Gil Cc: agk, snitzer, dm-devel, totte, linux-kernel, Sungjong Seo, Nathan Huckleberry, Sami Tolvanen Hi Yeongjin, On Thu, Mar 16, 2023 at 12:18:42PM +0900, Yeongjin Gil wrote: > In verity_work(), the return value of verity_verify_io() is converted to > blk_status and passed to verity_finish_io(). BTW, when a bit is set in > v->validated_blocks, verity_verify_io() skips verification regardless of > I/O error for the corresponding bio. In this case, the I/O error could > not be returned properly, and as a result, there is a problem that > abnormal data could be read for the corresponding block. > > To fix this problem, when an I/O error occurs, do not skip verification > even if the bit related is set in v->validated_blocks. > > Fixes: 843f38d382b1 ("dm verity: add 'check_at_most_once' option to only validate hashes once") > > Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > --- > drivers/md/dm-verity-target.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index ade83ef3b439..9316399b920e 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -523,7 +523,7 @@ static int verity_verify_io(struct dm_verity_io *io) > sector_t cur_block = io->block + b; > struct ahash_request *req = verity_io_hash_req(v, io); > > - if (v->validated_blocks && > + if (v->validated_blocks && bio->bi_status == BLK_STS_OK && > likely(test_bit(cur_block, v->validated_blocks))) { > verity_bv_skip_block(v, io, iter); > continue; Thanks for sending this patch! This looks like a correct fix, but I have some comments: * Using "check_at_most_once" is strongly discouraged, as it reduces security. If you are using check_at_most_once to improve performance at the cost of reduced security, please consider that very recently, dm-verity performance has significantly improved due to the removal of the WQ_UNBOUND workqueue flag which was causing significant I/O latency. See commit c25da5b7baf1 ("dm verity: stop using WQ_UNBOUND for verify_wq"). * I think your commit message does not explain a key aspect of the problem which is why is verity even attempted when the underlying I/O has failed? This appears to be because of the Forward Error Correction (FEC) feature. So, this issue is specific to the case where both FEC and check_at_most_once is used. Can you make your commit message explain this? * This patch does not appear to have been received by the dm-devel mailing list, which is the list where dm-verity patches should be reviewed on. It doesn't show up in the archive at https://lore.kernel.org/dm-devel. Also, I'm subscribed to dm-devel and I didn't receive this patch in my inbox. (I had to download it from https://lore.kernel.org/lkml instead.) Did you receive a bounce message when you sent this patch? * Please add 'Cc: stable@vger.kernel.org' to the commit message, just below the Fixes line, as per Documentation/process/stable-kernel-rules.rst. This will ensure that the fix will be backported to the stable kernels. * "Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>" does not have a corresponding Author or Co-developed-line, which is not allowed. Did you mean to list Sungjong as the Author or as a co-author? * No blank line between Fixes and the Signed-off-by line(s), please. Thanks! - Eric ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dm-devel] [PATCH] dm verity: fix error handling for check_at_most_once 2023-03-16 18:44 ` Eric Biggers @ 2023-03-17 6:18 ` 길영진/System Core Lab.(MX)/삼성전자 -1 siblings, 0 replies; 6+ messages in thread From: 길영진/System Core Lab.(MX)/삼성전자 @ 2023-03-17 6:18 UTC (permalink / raw) To: 'Eric Biggers' Cc: snitzer, linux-kernel, 'Nathan Huckleberry', dm-devel, 'Sami Tolvanen', 'Sungjong Seo', agk Hi Eric, Thank you for your detailed feedback. > Hi Yeongjin, > > On Thu, Mar 16, 2023 at 12:18:42PM +0900, Yeongjin Gil wrote: > > In verity_work(), the return value of verity_verify_io() is converted > > to blk_status and passed to verity_finish_io(). BTW, when a bit is set > > in > > v->validated_blocks, verity_verify_io() skips verification regardless > > v->of > > I/O error for the corresponding bio. In this case, the I/O error could > > not be returned properly, and as a result, there is a problem that > > abnormal data could be read for the corresponding block. > > > > To fix this problem, when an I/O error occurs, do not skip > > verification even if the bit related is set in v->validated_blocks. > > > > Fixes: 843f38d382b1 ("dm verity: add 'check_at_most_once' option to > > only validate hashes once") > > > > Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> > > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > > --- > > drivers/md/dm-verity-target.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/md/dm-verity-target.c > > b/drivers/md/dm-verity-target.c index ade83ef3b439..9316399b920e > > 100644 > > --- a/drivers/md/dm-verity-target.c > > +++ b/drivers/md/dm-verity-target.c > > @@ -523,7 +523,7 @@ static int verity_verify_io(struct dm_verity_io *io) > > sector_t cur_block = io->block + b; > > struct ahash_request *req = verity_io_hash_req(v, io); > > > > - if (v->validated_blocks && > > + if (v->validated_blocks && bio->bi_status == BLK_STS_OK && > > likely(test_bit(cur_block, v->validated_blocks))) { > > verity_bv_skip_block(v, io, iter); > > continue; > > Thanks for sending this patch! This looks like a correct fix, but I have > some > comments: > > * Using "check_at_most_once" is strongly discouraged, as it reduces > security. > If you are using check_at_most_once to improve performance at the cost > of > reduced security, please consider that very recently, dm-verity > performance > has significantly improved due to the removal of the WQ_UNBOUND > workqueue flag > which was causing significant I/O latency. See commit c25da5b7baf1 > ("dm verity: stop using WQ_UNBOUND for verify_wq"). > > * I think your commit message does not explain a key aspect of the problem > which > is why is verity even attempted when the underlying I/O has failed? > This > appears to be because of the Forward Error Correction (FEC) feature. So, > this > issue is specific to the case where both FEC and check_at_most_once is > used. > Can you make your commit message explain this? Okay. I will update commit message. > > * This patch does not appear to have been received by the dm-devel mailing > list, > which is the list where dm-verity patches should be reviewed on. It > doesn't > show up in the archive at https://lore.kernel.org/dm-devel. Also, I'm > subscribed to dm-devel and I didn't receive this patch in my inbox. (I > had to > download it from https://lore.kernel.org/lkml instead.) Did you receive > a > bounce message when you sent this patch? I am not sure but I received message from googlemail.com as follow "totte@google.com because the address couldn't be found". I will try to send v2 patch exclude totte@google.com and check the mailing. > > * Please add 'Cc: stable@vger.kernel.org' to the commit message, just > below the > Fixes line, as per Documentation/process/stable-kernel-rules.rst. This > will > ensure that the fix will be backported to the stable kernels. Okay. > > * "Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>" does not have a > corresponding Author or Co-developed-line, which is not allowed. Did > you mean > to list Sungjong as the Author or as a co-author? I created a patch through an internal review with Sungjong. I will change the tag to "Reviewed-by" > > * No blank line between Fixes and the Signed-off-by line(s), please. Okay. Thanks. I will send v2 patch soon. > > Thanks! > > - Eric -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] dm verity: fix error handling for check_at_most_once @ 2023-03-17 6:18 ` 길영진/System Core Lab.(MX)/삼성전자 0 siblings, 0 replies; 6+ messages in thread From: 길영진/System Core Lab.(MX)/삼성전자 @ 2023-03-17 6:18 UTC (permalink / raw) To: 'Eric Biggers' Cc: agk, snitzer, dm-devel, linux-kernel, 'Sungjong Seo', 'Nathan Huckleberry', 'Sami Tolvanen' Hi Eric, Thank you for your detailed feedback. > Hi Yeongjin, > > On Thu, Mar 16, 2023 at 12:18:42PM +0900, Yeongjin Gil wrote: > > In verity_work(), the return value of verity_verify_io() is converted > > to blk_status and passed to verity_finish_io(). BTW, when a bit is set > > in > > v->validated_blocks, verity_verify_io() skips verification regardless > > v->of > > I/O error for the corresponding bio. In this case, the I/O error could > > not be returned properly, and as a result, there is a problem that > > abnormal data could be read for the corresponding block. > > > > To fix this problem, when an I/O error occurs, do not skip > > verification even if the bit related is set in v->validated_blocks. > > > > Fixes: 843f38d382b1 ("dm verity: add 'check_at_most_once' option to > > only validate hashes once") > > > > Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> > > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > > --- > > drivers/md/dm-verity-target.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/md/dm-verity-target.c > > b/drivers/md/dm-verity-target.c index ade83ef3b439..9316399b920e > > 100644 > > --- a/drivers/md/dm-verity-target.c > > +++ b/drivers/md/dm-verity-target.c > > @@ -523,7 +523,7 @@ static int verity_verify_io(struct dm_verity_io *io) > > sector_t cur_block = io->block + b; > > struct ahash_request *req = verity_io_hash_req(v, io); > > > > - if (v->validated_blocks && > > + if (v->validated_blocks && bio->bi_status == BLK_STS_OK && > > likely(test_bit(cur_block, v->validated_blocks))) { > > verity_bv_skip_block(v, io, iter); > > continue; > > Thanks for sending this patch! This looks like a correct fix, but I have > some > comments: > > * Using "check_at_most_once" is strongly discouraged, as it reduces > security. > If you are using check_at_most_once to improve performance at the cost > of > reduced security, please consider that very recently, dm-verity > performance > has significantly improved due to the removal of the WQ_UNBOUND > workqueue flag > which was causing significant I/O latency. See commit c25da5b7baf1 > ("dm verity: stop using WQ_UNBOUND for verify_wq"). > > * I think your commit message does not explain a key aspect of the problem > which > is why is verity even attempted when the underlying I/O has failed? > This > appears to be because of the Forward Error Correction (FEC) feature. So, > this > issue is specific to the case where both FEC and check_at_most_once is > used. > Can you make your commit message explain this? Okay. I will update commit message. > > * This patch does not appear to have been received by the dm-devel mailing > list, > which is the list where dm-verity patches should be reviewed on. It > doesn't > show up in the archive at https://lore.kernel.org/dm-devel. Also, I'm > subscribed to dm-devel and I didn't receive this patch in my inbox. (I > had to > download it from https://lore.kernel.org/lkml instead.) Did you receive > a > bounce message when you sent this patch? I am not sure but I received message from googlemail.com as follow "totte@google.com because the address couldn't be found". I will try to send v2 patch exclude totte@google.com and check the mailing. > > * Please add 'Cc: stable@vger.kernel.org' to the commit message, just > below the > Fixes line, as per Documentation/process/stable-kernel-rules.rst. This > will > ensure that the fix will be backported to the stable kernels. Okay. > > * "Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>" does not have a > corresponding Author or Co-developed-line, which is not allowed. Did > you mean > to list Sungjong as the Author or as a co-author? I created a patch through an internal review with Sungjong. I will change the tag to "Reviewed-by" > > * No blank line between Fixes and the Signed-off-by line(s), please. Okay. Thanks. I will send v2 patch soon. > > Thanks! > > - Eric ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-20 5:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20230316031936epcas1p1ebd93477dcf3bf9ab1640306dd1da8ff@epcas1p1.samsung.com>
2023-03-16 3:18 ` [dm-devel] [PATCH] dm verity: fix error handling for check_at_most_once Yeongjin Gil
2023-03-16 3:18 ` Yeongjin Gil
2023-03-16 18:44 ` [dm-devel] " Eric Biggers
2023-03-16 18:44 ` Eric Biggers
2023-03-17 6:18 ` [dm-devel] " 길영진/System Core Lab.(MX)/삼성전자
2023-03-17 6:18 ` 길영진/System Core Lab.(MX)/삼성전자
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.