Commit 8267d8fb authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer

dm integrity: fix logic bug in integrity tag testing

If all the bytes are equal to DISCARD_FILLER, we want to accept the
buffer. If any of the bytes are different, we must do thorough
tag-by-tag checking.

The condition was inverted.

Fixes: 84597a44 ("dm integrity: add optional discard support")
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 120c9257
...@@ -1333,7 +1333,7 @@ static int dm_integrity_rw_tag(struct dm_integrity_c *ic, unsigned char *tag, se ...@@ -1333,7 +1333,7 @@ static int dm_integrity_rw_tag(struct dm_integrity_c *ic, unsigned char *tag, se
if (likely(is_power_of_2(ic->tag_size))) { if (likely(is_power_of_2(ic->tag_size))) {
if (unlikely(memcmp(dp, tag, to_copy))) if (unlikely(memcmp(dp, tag, to_copy)))
if (unlikely(!ic->discard) || if (unlikely(!ic->discard) ||
unlikely(!memchr_inv(dp, DISCARD_FILLER, to_copy))) { unlikely(memchr_inv(dp, DISCARD_FILLER, to_copy) != NULL)) {
goto thorough_test; goto thorough_test;
} }
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment