alignment enforcement in dm-crypt causes severe problems
Hello devs,
please see issue: https://github.com/virtio-win/kvm-guest-drivers-windows/issues/446
Short summary: When using encrypted disks with qemu (using dm-crypt) and pass that through LIO/vhost to qemu (via virtio-scsi) the following code is hit:
https://elixir.bootlin.com/linux/v5.3.18/source/drivers/md/dm-crypt.c#L1251
I am not familiar with the specification/contract of "bio". So I am not sure if the enforced alignment is legitimate.
Under Windows you cannot even initialize a disk because it wants to write sector 0 (count = 1) at offset 432.
Could some expert please comment?
Regards Andreas
Quoted 5 lines · Andreas Kinzler
Hello devs,
please see issue:
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/446
Quoted 8 lines
Short summary: When using encrypted disks with qemu (using dm-crypt) and pass that through LIO/vhost to qemu (via virtio-scsi) the following code is hit:
https://elixir.bootlin.com/linux/v5.3.18/source/drivers/md/dm-crypt.c#L1251
I am not familiar with the specification/contract of "bio". So I am not sure if the enforced alignment is legitimate.
Encryption in dm-crypt works with sectors as atomic units of encryption, so data legth in bio must be aligned to whole sectors.
For example, if you use CBC (Cipher Block Chaining mode), and only partial encrypted sector is written, the rest is corrupted.
So this restriction is perfectly valid there.
The question is what operation sends such bio structures. If it is some control operation, it should probably bypass it.
Anyway this seems like but in the driver that sends such bio.
Milan