Skip to contentSkip to conversation

Regression in 5.0-rc4 device-mapper - integrity data invalid

DISCUSSION Milan Broz 2 participants 4 messages Feb 5, 2019 – Feb 6, 2019 Device mapper

lore
Share & tools
lore

Milan Broz

author Reviewed-by Ming Lei
#0 lore raw

Hi Mike,

since 5.0-rc4 we are not able to use LUKS2 devices with 4k sector size.

For example,

# cryptsetup luksFormat --type luks2 -c aes-xts-plain64 --integrity hmac-sha256 /dev/sdc --sector-size 4096

fails with these syslog errors:
device-mapper: crypt: Integrity AEAD, tag size 32, IV size 0.
device-mapper: integrity: Invalid integrity data size 32768, expected 4096
device-mapper: integrity: Invalid integrity data size 32768, expected 4096

(with 512-byte sectors it seems to work ok)

Bisect shows this commit in rc4 is the problematic one (reverting fixes the problem):

commit 57c36519e4b949f89381053f7283f5d605595b42

Author: Mike Snitzer <[email protected]>
Date:   Wed Jan 16 18:53:26 2019 -0500

dm: fix clone_bio() to trigger blk_recount_segments()

DM's clone_bio() now benefits from using bio_trim() by fixing the fact that clone_bio() wasn't clearing BIO_SEG_VALID like bio_trim() does; which triggers blk_recount_segments() via bio_phys_segments().

Could you please check what is missing in the patch?

Milan

#1 lore raw
Quoted 22 lines · Milan Broz

Hi Mike,

since 5.0-rc4 we are not able to use LUKS2 devices with 4k sector size.

For example,

# cryptsetup luksFormat --type luks2 -c aes-xts-plain64 --integrity hmac-sha256 /dev/sdc --sector-size 4096

fails with these syslog errors:
device-mapper: crypt: Integrity AEAD, tag size 32, IV size 0.
device-mapper: integrity: Invalid integrity data size 32768, expected 4096
device-mapper: integrity: Invalid integrity data size 32768, expected 4096

(with 512-byte sectors it seems to work ok)

Bisect shows this commit in rc4 is the problematic one (reverting fixes the problem):

commit 57c36519e4b949f89381053f7283f5d605595b42

Author: Mike Snitzer <[email protected]>
Date:   Wed Jan 16 18:53:26 2019 -0500

dm: fix clone_bio() to trigger blk_recount_segments()

Quoted 8 lines

DM's clone_bio() now benefits from using bio_trim() by fixing the fact that clone_bio() wasn't clearing BIO_SEG_VALID like bio_trim() does; which triggers blk_recount_segments() via bio_phys_segments().

Could you please check what is missing in the patch?

Could be that this bio_trim() check is causing it to return early?:

  if (offset == 0 && size == bio->bi_iter.bi_size)
     	     return;

But I'll just effectively revert 57c36519e4b94. I don't have time right now to dwell on _why_ this patch, which seemed to be obvious cleanup, isn't safe.

Thanks!
Mike

author
#2 lore raw
Quoted 32 lines · Mike Snitzer
Quoted 29 lines · Milan Broz

Hi Mike,

since 5.0-rc4 we are not able to use LUKS2 devices with 4k sector size.

For example,

# cryptsetup luksFormat --type luks2 -c aes-xts-plain64 --integrity hmac-sha256 /dev/sdc --sector-size 4096

fails with these syslog errors:
device-mapper: crypt: Integrity AEAD, tag size 32, IV size 0.
device-mapper: integrity: Invalid integrity data size 32768, expected 4096
device-mapper: integrity: Invalid integrity data size 32768, expected 4096

(with 512-byte sectors it seems to work ok)

Bisect shows this commit in rc4 is the problematic one (reverting fixes the problem):

commit 57c36519e4b949f89381053f7283f5d605595b42

Author: Mike Snitzer <[email protected]>
Date:   Wed Jan 16 18:53:26 2019 -0500

dm: fix clone_bio() to trigger blk_recount_segments()

DM's clone_bio() now benefits from using bio_trim() by fixing the fact that clone_bio() wasn't clearing BIO_SEG_VALID like bio_trim() does; which triggers blk_recount_segments() via bio_phys_segments().

Quoted 6 lines
Quoted 1 line

Could you please check what is missing in the patch?

Could be that this bio_trim() check is causing it to return early?:

  if (offset == 0 && size == bio->bi_iter.bi_size)
     	     return;

Yes, this condition causes that bio_integrity_trim() is not called. Removing this early return in bio_trim() fixes the issue.

Not sure how this can happen though, the integrity offset should be in sync here...

Quoted 4 lines

But I'll just effectively revert 57c36519e4b94. I don't have time right now to dwell on _why_ this patch, which seemed to be obvious cleanup, isn't safe.

Thanks,
Milan

#3 lore raw
Quoted 37 lines · Milan Broz
Quoted 36 lines · Mike Snitzer
Quoted 22 lines · Milan Broz

Hi Mike,

since 5.0-rc4 we are not able to use LUKS2 devices with 4k sector size.

For example,

# cryptsetup luksFormat --type luks2 -c aes-xts-plain64 --integrity hmac-sha256 /dev/sdc --sector-size 4096

fails with these syslog errors:
device-mapper: crypt: Integrity AEAD, tag size 32, IV size 0.
device-mapper: integrity: Invalid integrity data size 32768, expected 4096
device-mapper: integrity: Invalid integrity data size 32768, expected 4096

(with 512-byte sectors it seems to work ok)

Bisect shows this commit in rc4 is the problematic one (reverting fixes the problem):

commit 57c36519e4b949f89381053f7283f5d605595b42

Author: Mike Snitzer <[email protected]>
Date:   Wed Jan 16 18:53:26 2019 -0500

dm: fix clone_bio() to trigger blk_recount_segments()

Quoted 8 lines

DM's clone_bio() now benefits from using bio_trim() by fixing the fact that clone_bio() wasn't clearing BIO_SEG_VALID like bio_trim() does; which triggers blk_recount_segments() via bio_phys_segments().

Could you please check what is missing in the patch?

Could be that this bio_trim() check is causing it to return early?:

Quoted 8 lines
Quoted 2 lines
  if (offset == 0 && size == bio->bi_iter.bi_size)
     	     return;

Yes, this condition causes that bio_integrity_trim() is not called. Removing this early return in bio_trim() fixes the issue.

Not sure how this can happen though, the integrity offset should be in sync here...

OK, think we need to get to the bottom of it now then ...

Quoted 3 lines
Quoted 3 lines

But I'll just effectively revert 57c36519e4b94. I don't have time right now to dwell on _why_ this patch, which seemed to be obvious cleanup, isn't safe.

... otherwise by reverting we'd be papering over this unexplained bug. We can always revert next week if the reason isn't found. But I'd like to get to the bottom of this.

Mike