Skip to content

delete created files when block_crypto_co_create_opts_luks fails

Daniel Henrique Barboza qemu-devel 6 versions – Applied

Status from this message: Thanks, applied to the block branch.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest4 patches 2 repliesApplied
  2. v84 patches 1 replySuperseded
  3. v74 patches 5 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v64 patches1 replySuperseded
v54 patches7 repliesSuperseded
v44 patches5 repliesSuperseded

changes in this version from the cover letter

- rebase with current master at 204aa60b37
- previous version:
https://lists.gnu.org/archive/html/qemu-devel/2019-11/msg01551.html

Patches in v9 Applied

#Subject and filesSizeRepliesApplied
1/4block: introducing 'bdrv_co_delete_file' interfaceblock/file-posix.c include/block/block_int.h+27 -00 replies
2/4block.c: adding bdrv_co_delete_fileblock.c include/block/block.h+27 -00 replies
3/4crypto.c: cleanup created file when block_crypto_co_create_opts_luks failsblock/crypto.c+18 -00 replies
4/4qemu-iotests: adding LUKS cleanup for non-UTF8 secret errortests/qemu-iotests/282 tests/qemu-iotests/282.out tests/qemu-iotests/group+79 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v9 yet.

Read the v9 thread

Cover letter [PATCH v9 0/4] delete created files when block_crypto_co_create_opts_luks fails

The version 8 of this patch series got buried and it's now conflicting with master. Rebase and re-sending it.

Also, I contemplated the idea of moving/copying the password verification in qcrypto_block_luks_create() all the way back to the start of block_crypto_co_create_opts_luks(), failing early before the bdrv_create_file(), avoiding the problem altogether without the need of a delete_file API I'm trying to push here (see patch 03 commit message for detailed info about the bug).

This idea was dropped after I saw that:

- We would need to store the resulting password, now being retrieved early in block_crypto_co_create_opts_luks(), in a new QCryptoBlockCreateOptions string to be used inside qcrypto_block_luks_create() as intended. An alternative would be to call qcrypto_secret_lookup_as_utf8() twice, discarding the first string;

- There are a lot of ways to fail in qcrypto_block_luks_create() other than a non-UTF8 password that would trigger the same problem. A more appropiate way of doing what I intended, instead of copying/hacking code around to fail before bdrv_create(), is some sort of bdrv_validate() API that would encapsulate everything that is related to user input validation for the security drivers. This API could then be called before the file creation (maybe inside bdrv_create itself) and fail early if needed. This is too overkill for what I'm trying to fix here, and I'm not sure if it would be a net gain compared to the delete_file API.

All that said, I believe that this patch series presents a sane solution with the code we have ATM.

changes in this version:
- rebase with current master at 204aa60b37
- previous version:
https://lists.gnu.org/archive/html/qemu-devel/2019-11/msg01551.html

Daniel Henrique Barboza (4):
block: introducing 'bdrv_co_delete_file' interface block.c: adding bdrv_co_delete_file
crypto.c: cleanup created file when block_crypto_co_create_opts_luks
fails
qemu-iotests: adding LUKS cleanup for non-UTF8 secret error

 block.c                    | 26 +++++++++++++++
 block/crypto.c             | 18 ++++++++++
 block/file-posix.c         | 23 +++++++++++++
 include/block/block.h      |  1 +
 include/block/block_int.h  |  4 +++
 tests/qemu-iotests/282     | 67 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/282.out | 11 +++++++
 tests/qemu-iotests/group   |  1 +
 8 files changed, 151 insertions(+)
 create mode 100755 tests/qemu-iotests/282
 create mode 100644 tests/qemu-iotests/282.out
Signature · 1 line
2.24.1