All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: [PULL 1/6] crypto: avoid overwriting Error object erasing keyslot
Date: Mon, 23 Nov 2026 17:00:45 +0000	[thread overview]
Message-ID: <20261123170050.4166517-2-berrange@redhat.com> (raw)
In-Reply-To: <20261123170050.4166517-1-berrange@redhat.com>

When erasing a keyslot we deliberately ignore some errors and
carry on trying to erase as much as possible. This results in
overwriting Error objects and triggering an assertion. Don't
pass in the &local_err, if errp is already set.

Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/4697
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 crypto/block-luks.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/crypto/block-luks.c b/crypto/block-luks.c
index 0926ad28f0c..c6ac3b2e29b 100644
--- a/crypto/block-luks.c
+++ b/crypto/block-luks.c
@@ -1148,14 +1148,12 @@ qcrypto_block_luks_erase_key(QCryptoBlock *block,
     slot->active = QCRYPTO_BLOCK_LUKS_KEY_SLOT_DISABLED;
 
     ret = qcrypto_block_luks_store_header(block, writefunc,
-                                          opaque, &local_err);
+                                          opaque, errp);
 
-    if (ret < 0) {
-        error_propagate(errp, local_err);
-    }
     /*
-     * Now try to erase the key material, even if the header
-     * update failed
+     * Note: errp may be non-NULL from this point onwards,
+     * as we carry trying to erase key material even in the
+     * face of errors
      */
     for (i = 0; i < QCRYPTO_BLOCK_LUKS_ERASE_ITERATIONS; i++) {
         if (qcrypto_random_bytes(garbagesplitkey,
@@ -1169,6 +1167,7 @@ qcrypto_block_luks_erase_key(QCryptoBlock *block,
             if (i > 0) {
                 return -1;
             }
+            local_err = NULL;
         }
         if (writefunc(block,
                       slot->key_offset_sector * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,
-- 
2.56.1



  reply	other threads:[~2026-11-23 17:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 17:00 [PULL 0/6] Misc fixes patches Daniel P. Berrangé
2026-11-23 17:00 ` Daniel P. Berrangé [this message]
2026-11-23 17:00 ` [PULL 2/6] crypto: add newline in error hint messages Daniel P. Berrangé
2026-11-23 17:00 ` [PULL 3/6] tests/functional: update to newer sunxi kernel package Daniel P. Berrangé
2026-11-30 16:21   ` Brian Cain
2026-11-30 16:31     ` Brian Cain
2026-12-01  9:12     ` Daniel P. Berrangé
2026-11-23 17:00 ` [PULL 4/6] tests/functional: add Accept header when downloading assets Daniel P. Berrangé
2026-11-23 17:00 ` [PULL 5/6] docs: document 'unavailable' state is no longer output Daniel P. Berrangé
2026-11-23 17:00 ` [PULL 6/6] qapi: correctly mark 'ignore-unavailable' deprecated Daniel P. Berrangé
2026-11-23 20:32 ` [PULL 0/6] Misc fixes patches Richard Henderson

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=20261123170050.4166517-2-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.