Re: [PATCH v6 11/11] blksnap: prevents using devices with data integrity or inline encryption

Eric Biggers
2023-11-27T22:47:27Z

On Fri, Nov 24, 2023 at 05:59:33PM +0100, Sergei Shtepa wrote:
> There is an opinion that the use of the blksnap module may violate the
> security of encrypted data. The difference storage file may be located
> on an unreliable disk or even network storage.

I think this misses the point slightly. The main problem is that blksnap writes
data in plaintext that is supposed to be encrypted, as indicated by the bio
having an encryption context. That's just what it does, at least based on the
last patchset; it's not just "an opinion". See
https://lore.kernel.org/linux-block/20a5802d-424d-588a-c497-1d1236c52880@veeam.com/

> +#ifdef CONFIG_BLK_INLINE_ENCRYPTION
> + if (bio->bi_crypt_context) {
> + pr_err_once("Hardware inline encryption is not supported\n");
> + diff_area_set_corrupted(tracker->diff_area, -EPERM);
> + return false;
> + }
> +#endif

The error message for ->bi_crypt_context being set should say
"Inline encryption", not "Hardware inline encryption". The submitter of the bio
may have intended to use blk-crypto-fallback.

Anyway, this patch is better than ignoring the problem. It's worth noting,
though, that this patch does not prevent blksnap from being set up on a block
device on which blk-crypto-fallback is already being used (or will be used).
When that happens, I/O will suddenly start failing. For usability reasons,
ideally that would be prevented somehow.

- Eric