mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Stefan Kerkmann <s.kerkmann@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH v2 0/7] arm: crypto: sha256: fix generation of thumb2 assembly
Date: Thu, 07 Nov 2024 15:02:18 +0100	[thread overview]
Message-ID: <20241107-fix-sha256-assembly-v2-0-5fdb418f7f54@pengutronix.de> (raw)

The checked in `sha256-core.S_shipped` assembly file has a thumb2
specific workaround applied[1]. This fix wasn't backported to the perl
script `sha256-armv4.pl` used to generate the assembly, thus when the
script is run it would regenerate the buggy code.

Under rare circumstances the modification timestamp of `sha256-armv4.pl`
differs enough from `sha256-core.S_shipped` that make triggers a
regeneration - leading to a broken sha256 digest on ARMv7 compiled in
Thumb2 mode. In my case it was a Yocto build of barebox from an external
source tree. Either the git checkout/clone process produced different
timestamps, as these are non-deterministic, or I accidentally touched
the file in another way. The bug expressed itself not in crashes but
wrong sha256 sums.

The mentioned problem in[1] was fixed and explained further in upstream
kernel commit[2]. Thus this commit updates the script and generated
assembly to the most recent kernel commit[3].

To better catch regressions in the future the existing digest tests now
exercise the optimized implementations for ARMv5/v6/v7/v8 and the ARMv7
test binaries are compiled in thumb2 mode.

[1]: b73bc6e303 (arm: crypto: fix SHA256 shipped assembler code, 2018-10-05)
[2]: 69216a545cf8 (crypto: sha256/arm - fix crash bug in Thumb2 build, 2019-02-16)
[3]: 54781938ec34 (crypto: arm/sha256-neon - avoid ADRL pseudo instruction, 2020-09-16)

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
Changes in v2:
- Updated the root cause, no functional changes
- Link to v1: https://lore.kernel.org/r/20241106-fix-sha256-assembly-v1-0-ad1ac961f15f@pengutronix.de

---
Stefan Kerkmann (7):
      arm: crypto: sha256: fix generation of thumb2 assembly
      arm: configs: multi_v5_v6_defconfig: move rpi1 armv6 targets
      arm: configs: multi_v5_v6_defconfig: enable arm optimized sha1/sha256 digest
      arm: configs: multi_v7_defconfig: compile for thumb2
      arm: configs: multi_v7_defconfig: enable arm optimized sha256 digest
      arm: configs: multi_v8_defconfig: enable arm optimized sha1/sha256 digest
      test: arm: rpi: run tests against multi_v5_v6_defconfig

 .github/workflows/test-labgrid-pytest.yml          |  4 ++
 arch/arm/configs/multi_v5_v6_defconfig             |  6 ++-
 arch/arm/configs/multi_v7_defconfig                |  7 +--
 arch/arm/configs/multi_v8_defconfig                |  5 +-
 arch/arm/crypto/sha256-armv4.pl                    | 25 ++++++----
 arch/arm/crypto/sha256-core.S_shipped              | 55 ++++++++++++++++++----
 ...yaml => qemu-raspi0@multi_v5_v6_defconfig.yaml} |  0
 ...ml => qemu-raspi1ap@multi_v5_v6_defconfig.yaml} |  0
 8 files changed, 74 insertions(+), 28 deletions(-)
---
base-commit: d9f7f6d930069df35e28fedb35719bfd12fbd6e4
change-id: 20241106-fix-sha256-assembly-ad3d25bf5a9f

Best regards,
-- 
Stefan Kerkmann <s.kerkmann@pengutronix.de>




             reply	other threads:[~2024-11-07 14:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 14:02 Stefan Kerkmann [this message]
2024-11-07 14:02 ` [PATCH v2 1/7] " Stefan Kerkmann
2024-11-07 14:02 ` [PATCH v2 2/7] arm: configs: multi_v5_v6_defconfig: move rpi1 armv6 targets Stefan Kerkmann
2024-11-07 14:02 ` [PATCH v2 3/7] arm: configs: multi_v5_v6_defconfig: enable arm optimized sha1/sha256 digest Stefan Kerkmann
2024-11-07 14:02 ` [PATCH v2 4/7] arm: configs: multi_v7_defconfig: compile for thumb2 Stefan Kerkmann
2024-11-07 14:02 ` [PATCH v2 5/7] arm: configs: multi_v7_defconfig: enable arm optimized sha256 digest Stefan Kerkmann
2024-11-07 14:02 ` [PATCH v2 6/7] arm: configs: multi_v8_defconfig: enable arm optimized sha1/sha256 digest Stefan Kerkmann
2024-11-07 14:02 ` [PATCH v2 7/7] test: arm: rpi: run tests against multi_v5_v6_defconfig Stefan Kerkmann
2024-11-08  9:52 ` [PATCH v2 0/7] arm: crypto: sha256: fix generation of thumb2 assembly Sascha Hauer

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=20241107-fix-sha256-assembly-v2-0-5fdb418f7f54@pengutronix.de \
    --to=s.kerkmann@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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