Skip to content

librbd: add crypto image dispatch layer - #37935

Merged
dillaman merged 1 commit into
ceph:masterfrom
orozery:librbd-image-address-remap
Nov 18, 2020
Merged

dillaman merged 1 commit into
ceph:masterfrom
orozery:librbd-image-address-remap

Conversation

@orozery

@orozery orozery commented Nov 3, 2020

Copy link
Copy Markdown
Contributor

This PR adds a new sync ImageDispatcher::remap_extents (similar to prepare_copyup).
This allows for "address translation" of image extents.
Specifically, for shifting offsets in encrypted images with a LUKS header preamble.

The new image dispatcher method is added to (almost) every call in librbd to Striper::file_to_extents/extents_to_file to correctly translates image to object extents, given the actual image data no longer starts at offset 0.

The two places I skipped for now are DiffIterate and TrimRequest. Let me know if this makes sense.

Other than that, any ideas for tests I should add?

Comment thread src/librbd/crypto/CryptoImageDispatch.h Resolved
Comment thread src/librbd/crypto/CryptoImageDispatch.h Resolved
@orozery
orozery force-pushed the librbd-image-address-remap branch from 325153f to d4a744a Compare November 13, 2020 08:26
@orozery

orozery commented Nov 13, 2020

Copy link
Copy Markdown
Contributor Author

changes pushed

@orozery

orozery commented Nov 15, 2020

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@dillaman dillaman left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm -- just that one small nit

Comment thread src/librbd/CMakeLists.txt Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: move up one line to keep in lexicographic order

This commit adds a crypto image dispatch layer, in addition to the existing crypto object dispatch layer.
The single purpose of this layer is to translate logical image offset to "on-disk" offsets,
given a crypto header which occupies the beginning of the image data.
This calculation is done via a new remap_extents api,
which is used in to wrap existing Striper translations between object and image extents.

Signed-off-by: Or Ozeri <[email protected]>
@orozery
orozery force-pushed the librbd-image-address-remap branch from d4a744a to 8d6a479 Compare November 17, 2020 06:40
@dillaman
dillaman merged commit be72ffd into ceph:master Nov 18, 2020
idryomov added a commit to idryomov/ceph that referenced this pull request Jun 22, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
idryomov added a commit to idryomov/ceph that referenced this pull request Jun 28, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)
idryomov added a commit to idryomov/ceph that referenced this pull request Jun 28, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)
idryomov added a commit to idryomov/ceph that referenced this pull request Jul 3, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)

Conflicts:
	src/librbd/api/DiffIterate.cc [ ImageArea support not in
	  quincy ]
	src/test/librbd/test_librbd.cc [ commit 4a5a0a5 ("librbd:
	  add cloned images encryption API") not in quincy
idryomov added a commit to idryomov/ceph that referenced this pull request Jul 8, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)
smanjara pushed a commit to smanjara/ceph that referenced this pull request Jul 11, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)

Resolves: rhbz#2295023
idryomov added a commit to idryomov/ceph that referenced this pull request Jul 12, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)

Conflicts:
	src/librbd/api/DiffIterate.cc [ ImageArea support not in
	  quincy ]
	src/test/librbd/test_librbd.cc [ commit 4a5a0a5 ("librbd:
	  add cloned images encryption API") not in quincy
idryomov added a commit to idryomov/ceph that referenced this pull request Jul 15, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)
mkogan1 pushed a commit to mkogan1/ceph that referenced this pull request Jul 18, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)

Resolves: rhbz#2295017
mkogan1 pushed a commit to mkogan1/ceph that referenced this pull request Aug 7, 2024
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 8d6a479 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit cdeb0ef)

Resolves: rhbz#2292562
afreen23 pushed a commit to rhcs-dashboard/ceph that referenced this pull request Jul 29, 2026
diff-iterate wasn't updated when librbd was being prepared to support
encryption in commit 4761bb2 ("librbd: add crypto image dispatch
layer").  This is even noted in [1]:

> The two places I skipped for now are DiffIterate and TrimRequest.

CryptoImageDispatch has since been removed, but diff-iterate in
fast-diff mode is still unaware of encryption and just assumes that all
offsets are raw.  This means that the callback gets invoked with
incorrect image offsets when encryption is loaded.  For example, for
a LUKS1-formatted image with some data at offsets 0 and 20971520,
diff-iterate with encryption loaded reports

  0~4194304
  4194304~4194304
  25165824~4194304

instead of

  0~4194304
  20971520~4194304

as "exists".  For any piece of code that is using diff-iterate to
optimize block-by-block processing (e.g. copy an encrypted source image
to a differently-encrypted destination image), this is fatal: it would
skip processing block 20971520 which has data and instead process block
25165824 which doesn't have any data and was to be skipped, producing
a corrupted destination image.

[1] ceph#37935 (comment)

Fixes: https://tracker.ceph.com/issues/66570
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit f84621523954e71f44d139e4be0f80f8b262aeaa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants