From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 1/3] crypto: add glib initialization for SM3 hash
Date: Fri, 30 Oct 2026 16:23:05 +0000 [thread overview]
Message-ID: <auTEacvDn1fET0-K@redhat.com> (raw)
In-Reply-To: <0e31509d-78bd-4f08-83d3-0709fc39fda0@oss.qualcomm.com>
On Fri, Oct 30, 2026 at 05:16:31PM +0100, Philippe Mathieu-Daudé wrote:
> On 30/10/26 16:04, Daniel P. Berrangé wrote:
> > The glib backend for the hmac/hash code must have an explicit
> > initializer for every element, as the default static initializer
> > of zero maps to G_CHECKSUM_MD5 and will lead to incorrect
> > behaviour. This could potentially be a security through use of
> > the wrong hashing algorithm.
> >
> > Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/4786
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> > crypto/hash-glib.c | 1 +
> > crypto/hmac-glib.c | 1 +
> > 2 files changed, 2 insertions(+)
> >
> > diff --git a/crypto/hash-glib.c b/crypto/hash-glib.c
> > index 809cef98aee..39040f1856e 100644
> > --- a/crypto/hash-glib.c
> > +++ b/crypto/hash-glib.c
> > @@ -33,6 +33,7 @@ static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] = {
> > [QCRYPTO_HASH_ALGO_SHA384] = G_CHECKSUM_SHA384,
> > [QCRYPTO_HASH_ALGO_SHA512] = G_CHECKSUM_SHA512,
> > [QCRYPTO_HASH_ALGO_RIPEMD160] = -1,
> > + [QCRYPTO_HASH_ALGO_SM3] = -1,
> > };
>
> Should we initialize the array with range designator to prevent that?
>
> [0 ... QCRYPTO_HASH_ALGO__MAX - 1] = -1,
Oh, I didn't know that syntax exists.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-10-30 16:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 15:04 [PATCH 0/3] crypto: robustness fixes to handling of SM3 hash Daniel P. Berrangé
2026-10-30 15:04 ` [PATCH 1/3] crypto: add glib initialization for " Daniel P. Berrangé
2026-10-30 16:16 ` Philippe Mathieu-Daudé
2026-10-30 16:23 ` Daniel P. Berrangé [this message]
2026-10-30 15:04 ` [PATCH 2/3] crypto: unconditionally report SM3 hash length Daniel P. Berrangé
2026-10-30 15:04 ` [PATCH 3/3] crypto: add preventative measures wrt uninitialized hash info Daniel P. Berrangé
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=auTEacvDn1fET0-K@redhat.com \
--to=berrange@redhat.com \
--cc=philmd@oss.qualcomm.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.