From: sashiko-bot@kernel.org
To: "Alex Ousherovitch" <aousherovitch@rambus.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 11/19] crypto: cmh - add DRBG hwrng
Date: Thu, 17 Sep 2026 23:14:41 +0000 [thread overview]
Message-ID: <20260917231441.C6EB61F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260917225929.2494111-12-aousherovitch@rambus.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] rng: DMA use-after-free on module unload due to un-aborted DRBG operation
- [Medium] rng: infinite retry loop on fatal hardware error in cmh_rng_read()
- [Medium] rng: mailbox queue exhaustion from orphaned DRBG requests
--
commit 8d9076a5e8784ced0b9563b435b225e28e6737e2
Author: Alex Ousherovitch <aousherovitch@rambus.com>
crypto: cmh - add DRBG hwrng
This commit registers the CMH DRBG core as a hardware RNG provider. It adds
synchronous reads that map DMA buffers and submit VCQ commands through the
transaction manager to gather entropy from the device.
> diff --git a/drivers/crypto/cmh/cmh_rng.c b/drivers/crypto/cmh/cmh_rng.c
> new file mode 100644
> index 0000000000000..a73634024e135
> --- /dev/null
> +++ b/drivers/crypto/cmh/cmh_rng.c
[ ... ]
> + /*
> + * Use the noabort variant: if the MBX is occupied by a slow
> + * operation (e.g. SLH-DSA sign at 120 s), we must not issue
> + * MBX_COMMAND_ABORT -- that would kill the unrelated in-flight
> + * VCQ. On timeout with an in-flight VCQ (-EINPROGRESS), the
> + * orphan callback defers DMA cleanup until the RH fires.
> + */
> + ret = cmh_tm_submit_sync_noabort(vcq, DRBG_READ_VCQ_CMDS, 1,
> + msecs_to_jiffies(drbg_timeout_ms),
> + cmh_dma_orphan_free, orphan);
[Severity: High]
Could this cause a DMA use-after-free during module unload? Since
cmh_tm_submit_sync_noabort() leaves the hardware operation running in the
background, if the cmh module is unloaded, cmh_tm_cleanup() will force-cancel
the transaction and trigger cmh_dma_orphan_free(). This unmaps and frees the
DMA buffer while the hardware accelerator is still actively writing to it.
> + if (ret == -EINPROGRESS) {
> + /*
> + * The orphan callback owns dmabuf and frees it on VCQ
> + * completion. Return 0 (not -EAGAIN): .read() only runs with
> + * wait=true (see the !wait early return above), and the hwrng
> + * core forwards a negative errno straight to a blocking read
> + * whereas a 0 return makes it retry.
> + */
> + return 0;
> + }
[Severity: Medium]
Does returning 0 here cause mailbox queue exhaustion? When 0 is returned
on a timeout, the hwrng core immediately retries the read. Since the
hardware might be blocked by a slow operation, won't this rapidly submit
more DRBG requests until the Command Message Queue is completely filled
with orphaned requests, blocking all other subsystems?
[ ... ]
> + switch (ret) {
> + case -EAGAIN:
> + case -EBUSY:
> + case -ETIMEDOUT:
> + case -EIO:
> + /*
> + * -ENODEV: the TM is not running -- occurs when the
> + * hwrng kthread (PF_NOFREEZE, not frozen during
> + * suspend) calls .read() while the device is suspended.
> + * Treat as transient: the TM restarts on resume.
> + */
> + case -ENODEV:
> + dev_dbg_ratelimited(cmh_dev(),
> + "rng: transient DRBG failure (rc=%d)\n",
> + ret);
> + kfree_sensitive(dmabuf);
> + /*
> + * Back off before the hwrng core re-issues the
> + * blocking read: rng_dev_read() loops on a 0 return
> + * with only a conditional need_resched, so a persistent
> + * transient fault would otherwise spin the CPU.
> + */
> + msleep(CMH_DRBG_RETRY_BACKOFF_MS);
> + return 0;
[Severity: Medium]
Will this create an infinite retry loop for fatal hardware errors? By
masking -EIO to 0 and treating it as a transient error, rng_dev_read()
will retry the read indefinitely if the accelerator encounters a persistent
failure. Should fatal errors be propagated to break the loop instead of
returning 0?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917225929.2494111-1-aousherovitch@rambus.com?part=11
next prev parent reply other threads:[~2026-09-17 23:14 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 22:59 [PATCH v5 00/19] crypto: cmh - add Rambus CryptoManager Hub driver Alex Ousherovitch
2026-09-17 22:59 ` [PATCH v5 01/19] dt-bindings: crypto: add Rambus CryptoManager Hub Alex Ousherovitch
2026-09-17 23:08 ` sashiko-bot
2026-09-28 18:18 ` Rob Herring
2026-10-03 0:01 ` Ousherovitch, Alex
2026-09-17 22:59 ` [PATCH v5 02/19] crypto: cmh - add core platform driver Alex Ousherovitch
2026-09-17 23:17 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 03/19] crypto: cmh - add key provisioning and management Alex Ousherovitch
2026-09-17 23:15 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 04/19] crypto: cmh - add SHA-2/SHA-3/SHAKE ahash Alex Ousherovitch
2026-09-17 23:11 ` sashiko-bot
2026-09-23 5:47 ` Herbert Xu
2026-09-23 20:50 ` Ousherovitch, Alex
2026-09-28 5:17 ` Herbert Xu
2026-10-05 17:04 ` Ousherovitch, Alex
2026-10-05 22:31 ` Ousherovitch, Alex
2026-10-08 8:20 ` Herbert Xu
2026-10-08 18:19 ` Ousherovitch, Alex
2026-09-17 22:59 ` [PATCH v5 05/19] crypto: cmh - add HMAC ahash Alex Ousherovitch
2026-09-17 23:14 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 06/19] crypto: cmh - add CSHAKE/KMAC ahash Alex Ousherovitch
2026-09-17 23:16 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 07/19] crypto: cmh - add SM3 ahash Alex Ousherovitch
2026-09-17 23:12 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 08/19] crypto: cmh - add AES skcipher/aead/cmac Alex Ousherovitch
2026-09-17 23:11 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 09/19] crypto: cmh - add SM4 skcipher/aead/cmac/xcbc Alex Ousherovitch
2026-09-17 23:10 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 10/19] crypto: cmh - add ChaCha20-Poly1305 Alex Ousherovitch
2026-09-17 23:11 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 11/19] crypto: cmh - add DRBG hwrng Alex Ousherovitch
2026-09-17 23:14 ` sashiko-bot [this message]
2026-09-17 22:59 ` [PATCH v5 12/19] crypto: cmh - add RSA akcipher Alex Ousherovitch
2026-09-17 23:10 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 13/19] crypto: cmh - add ECDSA/SM2 sig Alex Ousherovitch
2026-09-17 22:59 ` [PATCH v5 14/19] crypto: cmh - add ECDH/X25519 kpp Alex Ousherovitch
2026-09-17 22:59 ` [PATCH v5 15/19] crypto: cmh - add ML-KEM/ML-DSA (QSE) Alex Ousherovitch
2026-09-17 22:59 ` [PATCH v5 16/19] crypto: cmh - add SLH-DSA/LMS/XMSS (HCQ) Alex Ousherovitch
2026-09-17 22:59 ` [PATCH v5 17/19] Documentation: ioctl: add CMH ioctl documentation and register 'J' Alex Ousherovitch
2026-09-17 23:17 ` sashiko-bot
2026-09-17 22:59 ` [PATCH v5 18/19] selftests: crypto: cmh - add kselftest for management ioctl Alex Ousherovitch
2026-09-17 22:59 ` [PATCH v5 19/19] MAINTAINERS: add Rambus CryptoManager Hub (CMH) Alex Ousherovitch
2026-09-23 5:48 ` [PATCH v5 00/19] crypto: cmh - add Rambus CryptoManager Hub driver Herbert Xu
2026-09-23 17:42 ` Ousherovitch, Alex
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=20260917231441.C6EB61F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aousherovitch@rambus.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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