[dm-devel] alignment enforcement in dm-crypt causes severe problems

Milan Broz gmazyland at gmail.com
Wed Apr 8 15:05:31 UTC 2020


On 08/04/2020 12:21, Andreas Kinzler wrote:
> 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.

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




More information about the dm-devel mailing list