qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org, berrange@redhat.com
Cc: kris.conklin@seagate.com, jonathan.henze@seagate.com,
	evan.burgess@seagate.com, peter.maydell@linaro.org
Subject: Re: [PATCH v5 00/16] hw/misc/aspeed_hace: Fix SG Accumulative Hash Calculations
Date: Tue, 8 Oct 2024 10:01:39 +0200	[thread overview]
Message-ID: <7517bf36-aaf7-43de-b47b-768dd51c2ad0@redhat.com> (raw)
In-Reply-To: <20241008075724.2772149-1-clg@redhat.com>

On 10/8/24 09:57, Cédric Le Goater wrote:
> Hello,
> 
> This is a resping of Alejandro's series fixing SG Accumulative Hash
> Calculations. See [1] for more details.

arf.

[1] https://lore.kernel.org/all/20240807195122.2827364-1-alejandro.zeise@seagate.com/

C.

> 
> The goal of this patch series is to fix accumulative hashing support
> in the Aspeed HACE module. The issue that stemmed this patch was a
> failure to boot an OpenBMC image using the "ast2600-evb" machine. The
> U-boot 2019.04 loader failed to verify image hashes.
> 
> These incorrect image hashes given by the HACE to the U-boot guest are
> due to an oversight in the HACE module. Previously when operating in
> scatter-gather accumulative mode, the HACE would cache the address
> provided by the guest which contained the source data. However, there
> was no deep copy, so when HACE generated the digest upon the reception
> of the final accumulative chunk the digest was incorrect, as the
> addresses provided had their regions overwritten by that time.
> 
> This fix consists of two main steps:
> * Add an accumulative hashing function to the qcrypto library
> * Modify the HACE module to use the accumulative hashing functions
> 
> All the crypto library backends (nettle, gnutls, etc.) support
> accumulative hashing, so it was trivial to create wrappers for those
> functions.
> 
> Changes in v5 (clg):
> 
>   - Changed documentation "non-zero on error" -> "-1 on error"
>   - Dropped qcrypto_hash_supports() in qcrypto_glib_hash_new()
>   - Removed superfluous cast (GChecksum *) in qcrypto_glib_hash_free()
>   - Reworked qcrypto_glib_hash_finalize()
>   - Dropped qcrypto_hash_supports() in qcrypto_gcrypt_hash_new()
>   - Reworked qcrypto_gcrypt_hash_finalize()
>   - Handled gcry_md_open() errors in qcrypto_gcrypt_hash_new()
>   - Dropped qcrypto_hash_supports() in qcrypto_gnutls_hash_new()
>   - Reworked qcrypto_gnutls_hash_finalize()
>   - Handled gnutls_hash_init() errors in qcrypto_gnutls_hash_new()
>   - Replaced gnutls_hash_deinit() by gnutls_hash_output() in
>     qcrypto_gnutls_hash_finalize()
>   - Freed resources with gnutls_hash_deinit() in qcrypto_gnutls_hash_free()
>   - Dropped qcrypto_hash_supports() in qcrypto_nettle_hash_new()
>   - Split iov changes from original patch
>   - Handled qcrypto_afalg_hash_ctx_new() errors in qcrypto_afalg_hash_new()
>   - Freed alg_name in qcrypto_afalg_hash_new()
>   - Reworked qcrypto_afalg_recv_from_kernel()
>   - Split iov changes from original patch
>   - Reworked qcrypto_hash_bytesv() error handling
>   - Used hash->driver int qcrypto_hash_new(), qcrypto_hash_free() qcrypto_hash_updatev()
>   - Introduced qcrypto_hash_supports() check in  qcrypto_hash_new()
>   - Introduced g_autofree variables in qcrypto_hash_finalize_digest()
>     and qcrypto_hash_finalize_base64()
>   - Re-arrranged code in qcrypto_hash_digestv() and qcrypto_hash_digest()
>   - Improved test_hash_accumulate() with g_autofree variables
>   - Fixed spelling in commit log
>   - Checkpatch fixes
> 
> Changes in V4:
> * Restructured patches so unit tests pass for each independently.
> * Freeing hash context is now a void function.
> * Added autoptr cleanup function definition for qcrypto_hash_free.
> * Separated qcrypto_hash_update into qcrypto_hash_update and
>    qcrypto_hash_updatev.
> * Changed public hash functions to use afalg implementation correctly if support
>    is enabled.
> * Fixed accumulative hashing in afalg driver (pass MSG_MORE socket flag).
> 
> Changes in V3:
> * Reworked crypto hash API with comments from Daniel
>    * Creation/Deletion of contexts, updating, and finalizing
>    * Modified existing API functions to use the new 4 main core functions
>    * Added test for accumulative hashing
>    * Added afalg driver implementation
> * Fixed bug in HACE module where hash context fails to allocate,
>    causing the HACE internal state to be incorrect and segfault.
> 
> Changes in V2:
> * Fixed error checking bug in libgcrypt crypto backend of
>    accumulate_bytesv
> 
> Alejandro Zeise (16):
>    crypto: accumulative hashing API
>    crypto/hash-glib: Implement new hash API
>    crypto/hash-gcrypt: Implement new hash API
>    crypto/hash-gnutls: Implement new hash API
>    crypto/hash-nettle: Implement new hash API
>    util/iov: Introduce iov_send_recv_with_flags()
>    crypto/hash-afalg: Implement new hash API
>    crypto/hash: Implement and use new hash API
>    tests/unit/test-crypto-hash: accumulative hashing
>    crypto/hash-glib: Remove old hash API functions
>    crypto/hash-gcrypt: Remove old hash API functions
>    crypto/hash-gnutls: Remove old hash API functions
>    crypto/hash-nettle: Remove old hash API functions
>    crypto/hash-afalg: Remove old hash API functions
>    crypto/hashpriv: Remove old hash API function
>    hw/misc/aspeed_hace: Fix SG Accumulative hashing
> 
>   crypto/hashpriv.h             |  13 ++-
>   include/crypto/hash.h         | 119 ++++++++++++++++++++++++
>   include/hw/misc/aspeed_hace.h |   4 +
>   include/qemu/iov.h            |  27 ++++++
>   crypto/hash-afalg.c           | 167 ++++++++++++++++++++++++----------
>   crypto/hash-gcrypt.c          | 112 +++++++++++++----------
>   crypto/hash-glib.c            |  92 +++++++++++--------
>   crypto/hash-gnutls.c          |  97 +++++++++++++-------
>   crypto/hash-nettle.c          |  81 ++++++++++-------
>   crypto/hash.c                 | 161 ++++++++++++++++++++++++++------
>   hw/misc/aspeed_hace.c         |  96 ++++++++++---------
>   tests/unit/test-crypto-hash.c |  46 ++++++++++
>   util/iov.c                    |  25 +++--
>   13 files changed, 756 insertions(+), 284 deletions(-)
> 



  parent reply	other threads:[~2024-10-08  8:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08  7:57 [PATCH v5 00/16] hw/misc/aspeed_hace: Fix SG Accumulative Hash Calculations Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 01/16] crypto: accumulative hashing API Cédric Le Goater
2024-10-10 10:09   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 02/16] crypto/hash-glib: Implement new hash API Cédric Le Goater
2024-10-10 10:11   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 03/16] crypto/hash-gcrypt: " Cédric Le Goater
2024-10-10 10:29   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 04/16] crypto/hash-gnutls: " Cédric Le Goater
2024-10-10 10:36   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 05/16] crypto/hash-nettle: " Cédric Le Goater
2024-10-10 10:49   ` Daniel P. Berrangé
2024-10-10 11:43     ` Daniel P. Berrangé
2024-10-10 12:01       ` Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 06/16] util/iov: Introduce iov_send_recv_with_flags() Cédric Le Goater
2024-10-10 10:51   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 07/16] crypto/hash-afalg: Implement new hash API Cédric Le Goater
2024-10-10 11:16   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 08/16] crypto/hash: Implement and use " Cédric Le Goater
2024-10-10 11:21   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 09/16] tests/unit/test-crypto-hash: accumulative hashing Cédric Le Goater
2024-10-10 11:22   ` Daniel P. Berrangé
2024-10-08  7:57 ` [PATCH v5 10/16] crypto/hash-glib: Remove old hash API functions Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 11/16] crypto/hash-gcrypt: " Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 12/16] crypto/hash-gnutls: " Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 13/16] crypto/hash-nettle: " Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 14/16] crypto/hash-afalg: " Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 15/16] crypto/hashpriv: Remove old hash API function Cédric Le Goater
2024-10-08  7:57 ` [PATCH v5 16/16] hw/misc/aspeed_hace: Fix SG Accumulative hashing Cédric Le Goater
2024-10-10 11:25   ` Daniel P. Berrangé
2024-10-08  8:01 ` Cédric Le Goater [this message]
2024-10-10 11:28 ` [PATCH v5 00/16] hw/misc/aspeed_hace: Fix SG Accumulative Hash Calculations Daniel P. Berrangé
2024-10-10 11:40   ` Cédric Le Goater

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=7517bf36-aaf7-43de-b47b-768dd51c2ad0@redhat.com \
    --to=clg@redhat.com \
    --cc=berrange@redhat.com \
    --cc=evan.burgess@seagate.com \
    --cc=jonathan.henze@seagate.com \
    --cc=kris.conklin@seagate.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).