From: Sergei Shtepa <sergei.shtepa@linux.dev>
To: axboe@kernel.dk, hch@infradead.org, corbet@lwn.net, snitzer@kernel.org
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
viro@zeniv.linux.org.uk, brauner@kernel.org,
linux-block@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Sergei Shtepa <sergei.shtepa@veeam.com>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH v6 11/11] blksnap: prevents using devices with data integrity or inline encryption
Date: Fri, 24 Nov 2023 17:59:33 +0100 [thread overview]
Message-ID: <20231124165933.27580-12-sergei.shtepa@linux.dev> (raw)
In-Reply-To: <20231124165933.27580-1-sergei.shtepa@linux.dev>
From: Sergei Shtepa <sergei.shtepa@veeam.com>
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. To implement secure
compatibility with hardware inline encrypted devices will require
discussion of algorithms and restrictions. For example, a restriction
on the location of the difference storage only in virtual memory might
help. Currently, there is no need for compatibility of the blksnap
module and hardware inline encryption.
I see no obstacles to ensuring the compatibility of the blksnap module
and block devices with data integrity. However, this functionality was
not planned or tested. Perhaps in the future this compatibility can be
implemented.
Theoretically possible that the block device was added to the snapshot
before crypto_profile and integrity.profile were initialized.
Checking the values of bi_crypt_context and bi_integrity ensures that
the blksnap will not perform any actions with I/O units with which it
is not compatible.
Reported-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Sergei Shtepa <sergei.shtepa@veeam.com>
---
drivers/block/blksnap/snapshot.c | 17 +++++++++++++++++
drivers/block/blksnap/tracker.c | 14 ++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/drivers/block/blksnap/snapshot.c b/drivers/block/blksnap/snapshot.c
index 21d94f12b5fc..a7675fdcf359 100644
--- a/drivers/block/blksnap/snapshot.c
+++ b/drivers/block/blksnap/snapshot.c
@@ -149,6 +149,23 @@ int snapshot_add_device(const uuid_t *id, struct tracker *tracker)
int ret = 0;
struct snapshot *snapshot = NULL;
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+ if (tracker->orig_bdev->bd_disk->queue->integrity.profile) {
+ pr_err("Blksnap is not compatible with data integrity\n");
+ ret = -EPERM;
+ goto out_up;
+ } else
+ pr_debug("Data integrity not found\n");
+#endif
+
+#ifdef CONFIG_BLK_INLINE_ENCRYPTION
+ if (tracker->orig_bdev->bd_disk->queue->crypto_profile) {
+ pr_err("Blksnap is not compatible with hardware inline encryption\n");
+ ret = -EPERM;
+ goto out_up;
+ } else
+ pr_debug("Inline encryption not found\n");
+#endif
snapshot = snapshot_get_by_id(id);
if (!snapshot)
return -ESRCH;
diff --git a/drivers/block/blksnap/tracker.c b/drivers/block/blksnap/tracker.c
index 2b8978a2f42e..b38ead9afa69 100644
--- a/drivers/block/blksnap/tracker.c
+++ b/drivers/block/blksnap/tracker.c
@@ -57,6 +57,20 @@ static bool tracker_submit_bio(struct bio *bio)
if (diff_area_is_corrupted(tracker->diff_area))
return false;
+#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
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+ if (bio->bi_integrity) {
+ pr_err_once("Data integrity is not supported\n");
+ diff_area_set_corrupted(tracker->diff_area, -EPERM);
+ return false;
+ }
+#endif
return diff_area_cow(bio, tracker->diff_area, ©_iter);
}
--
2.20.1
next prev parent reply other threads:[~2023-11-24 17:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 16:59 [PATCH v6 00/11] blksnap - block devices snapshots module Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 01/11] documentation: Block Device Filtering Mechanism Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 02/11] block: " Sergei Shtepa
2023-12-07 7:44 ` Christoph Hellwig
2023-12-07 11:22 ` Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 03/11] documentation: Block Devices Snapshots Module Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 04/11] blksnap: header file of the module interface Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 05/11] blksnap: module management interface functions Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 06/11] blksnap: handling and tracking I/O units Sergei Shtepa
2023-12-07 8:23 ` Christoph Hellwig
2023-11-24 16:59 ` [PATCH v6 07/11] blksnap: difference storage and chunk Sergei Shtepa
2023-12-07 8:36 ` Christoph Hellwig
2023-11-24 16:59 ` [PATCH v6 08/11] blksnap: event queue from the difference storage Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 09/11] blksnap: snapshot and snapshot image block device Sergei Shtepa
2023-11-24 16:59 ` [PATCH v6 10/11] blksnap: Kconfig and Makefile Sergei Shtepa
2023-12-07 7:47 ` Christoph Hellwig
2023-11-24 16:59 ` Sergei Shtepa [this message]
2023-11-27 22:47 ` [PATCH v6 11/11] blksnap: prevents using devices with data integrity or inline encryption Eric Biggers
2023-11-28 11:00 ` Sergei Shtepa
2023-11-28 17:18 ` Eric Biggers
2023-11-29 15:15 ` Sergei Shtepa
2023-11-24 17:03 ` [PATCH v6 00/11] blksnap - block devices snapshots module Jens Axboe
2023-11-24 17:12 ` Sergei Shtepa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231124165933.27580-12-sergei.shtepa@linux.dev \
--to=sergei.shtepa@linux.dev \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=corbet@lwn.net \
--cc=ebiggers@kernel.org \
--cc=hch@infradead.org \
--cc=juri.lelli@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sergei.shtepa@veeam.com \
--cc=snitzer@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox