Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Saravanakrishnan Krishnamoorthy" <skrishnamoorthy@rambus.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 17/19] Documentation: ioctl: add CMH ioctl documentation and register 'J'
Date: Thu, 06 Aug 2026 20:25:11 +0000	[thread overview]
Message-ID: <20260806202513.34DB71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806195519.2703224-18-skrishnamoorthy@rambus.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] UAPI Architecture Anti-Pattern: Bypassing standard cryptographic subsystems with a massive custom ioctl interface.
- [High] Privilege Separation and Access Control Violation in device node.
- [Medium] Misleading UAPI Naming in SM2 ECDH Hash struct leads to API misuse.
- [Medium] Hardware Error Management Anti-Pattern: Exposing read-to-clear error state directly to user-space.
--

--- Patch [17]: [PATCH v3 17/19] Documentation: ioctl: add CMH ioctl documentation and register 'J' ---
commit dcc392785ff594e59facfd1248a64d489fc2a2fd
Author: Alex Ousherovitch <aousherovitch@rambus.com>

Documentation: ioctl: add CMH ioctl documentation and register 'J'

This commit adds documentation for the /dev/cmh_mgmt misc device ioctls
used by the Rambus CryptoManager Hub (CMH) hardware crypto accelerator. It
covers key management, derivation, public-key cryptography, post-quantum
cryptography, and hardware management. It also registers the ioctl magic
number 'J' (0x4A) in ioctl-number.rst.

> diff --git a/Documentation/userspace-api/ioctl/cmh_mgmt.rst b/Documentation/userspace-api/ioctl/cmh_mgmt.rst
> new file mode 100644
> index 0000000000000..d17a77975df6c
> --- /dev/null
> +++ b/Documentation/userspace-api/ioctl/cmh_mgmt.rst

[ ... ]

> +Introduction
> +============
> +
> +The ``/dev/cmh_mgmt`` character device provides user-space access to key
> +management, key derivation, public-key, and post-quantum cryptographic
> +operations on the CryptoManager Hub (CMH) hardware accelerator.
> +
> +The device is created by the ``cmh`` kernel module as a ``misc_device``.
> +All operations are synchronous -- the ioctl blocks until the hardware
> +completes.  Opening the device requires ``CAP_SYS_ADMIN``.

[Severity: High]
Could the global permission check on the device node create a privilege
escalation regression?

Looking at cmh_mgmt_open() in drivers/crypto/cmh/cmh_mgmt.c:

    if (!capable(CAP_SYS_ADMIN))
        return -EPERM;

If an administrator opens /dev/cmh_mgmt and delegates the file descriptor
to an unprivileged process for cryptographic data-plane operations, the
lack of per-ioctl capability checks means that process can escalate its
access to invoke system management operations like DRBG_CONFIG or EAC_READ.

Alternatively, if delegation is not used, this structure forces standard
applications to run as root just to access the crypto hardware.

[ ... ]

> +CMH_IOCTL_SM2_ECDH_HASH
> +~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +Derive the shared key from the shared point and ZA digests.
> +
> +:Direction: ``_IOWR``
> +:Number: 0x35
> +:Argument: ``struct cmh_ioctl_sm2_ecdh_hash``
> +
> +::
> +
> +  struct cmh_ioctl_sm2_ecdh_hash {
> +      __u32 version;
> +      __u32 __reserved;
> +      __u64 peer_id_digest;    /* ptr to Z_A -- initiator's digest (32B) */
> +      __u64 id_digest;         /* ptr to Z_B -- responder's digest (32B) */

[Severity: Medium]
Will this struct naming lead to API misuse and silent protocol failures?

The names peer_id_digest and id_digest naturally imply relative ownership,
but the documentation requires absolute protocol ordering. If a developer
implements the initiator role using the uapi struct fields as named, they
must pass their own digest as peer_id_digest, which contradicts the naming.

[ ... ]

> +Hardware Management ioctls
> +==========================
> +
> +CMH_IOCTL_EAC_READ
> +-------------------
> +
> +Read and clear the hardware Error and Alarm Controller registers.

[ ... ]

> +The eSW atomically reads and clears the registers on each call.
> +Successive reads show only new events since the last read.

[Severity: Medium]
Does exposing read-to-clear error state directly to user-space risk silent
loss of hardware error events?

Looking at cmh_mgmt_eac_read() in drivers/crypto/cmh/cmh_mgmt.c:

    vcq_add_eac_read(&vcq[1], rsp_dma, sizeof(*rsp));

The driver unconditionally fetches and clears the state from hardware
without multiplexing or caching it for other listeners. If multiple
processes, or a daemon and a debugging tool, invoke the EAC_READ ioctl,
each caller steals events from the others, preventing reliable error
monitoring or telemetry.

[ ... ]

> +Relationship to the in-kernel crypto API
> +=========================================
> +
> +The main reason these operations are exposed as ioctls, rather than
> +through the standard in-kernel crypto API, is the CMH datastore key
> +model: an ioctl can operate on a *datastore-referenced* (hardware-held)

[Severity: High]
Does bypassing standard cryptographic subsystems introduce a fragmentation
regression for the user-space ecosystem?

By bypassing standard kernel abstractions like AF_ALG or the keys subsystem
in favor of a vendor-specific uapi, this approach commits the kernel to
permanently maintaining a massive set of custom ioctls and requires
applications to implement vendor-specific code instead of relying on
standard interfaces.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806195519.2703224-1-skrishnamoorthy@rambus.com?part=17

  reply	other threads:[~2026-08-06 20:25 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 19:54 [PATCH v3 00/19] crypto: cmh - add Rambus CryptoManager Hub driver Saravanakrishnan Krishnamoorthy
2026-08-06 19:55 ` [PATCH v3 01/19] dt-bindings: crypto: add Rambus CryptoManager Hub Saravanakrishnan Krishnamoorthy
2026-08-06 20:01   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 02/19] crypto: cmh - add core platform driver Saravanakrishnan Krishnamoorthy
2026-08-06 20:11   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 03/19] crypto: cmh - add key provisioning and management Saravanakrishnan Krishnamoorthy
2026-08-06 20:17   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 04/19] crypto: cmh - add SHA-2/SHA-3/SHAKE ahash Saravanakrishnan Krishnamoorthy
2026-08-06 20:12   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 05/19] crypto: cmh - add HMAC ahash Saravanakrishnan Krishnamoorthy
2026-08-06 20:09   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 06/19] crypto: cmh - add CSHAKE/KMAC ahash Saravanakrishnan Krishnamoorthy
2026-08-06 20:10   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 07/19] crypto: cmh - add SM3 ahash Saravanakrishnan Krishnamoorthy
2026-08-06 20:07   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 08/19] crypto: cmh - add AES skcipher/aead/cmac Saravanakrishnan Krishnamoorthy
2026-08-06 20:10   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 09/19] crypto: cmh - add SM4 skcipher/aead/cmac/xcbc Saravanakrishnan Krishnamoorthy
2026-08-06 20:09   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 10/19] crypto: cmh - add ChaCha20-Poly1305 Saravanakrishnan Krishnamoorthy
2026-08-06 20:12   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 11/19] crypto: cmh - add DRBG hwrng Saravanakrishnan Krishnamoorthy
2026-08-06 20:17   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 12/19] crypto: cmh - add RSA akcipher Saravanakrishnan Krishnamoorthy
2026-08-06 20:18   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 13/19] crypto: cmh - add ECDSA/SM2 sig Saravanakrishnan Krishnamoorthy
2026-08-06 20:24   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 14/19] crypto: cmh - add ECDH/X25519 kpp Saravanakrishnan Krishnamoorthy
2026-08-06 20:34   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 15/19] crypto: cmh - add ML-KEM/ML-DSA (QSE) Saravanakrishnan Krishnamoorthy
2026-08-06 20:24   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 16/19] crypto: cmh - add SLH-DSA/LMS/XMSS (HCQ) Saravanakrishnan Krishnamoorthy
2026-08-06 20:43   ` sashiko-bot
2026-08-06 19:55 ` [PATCH v3 17/19] Documentation: ioctl: add CMH ioctl documentation and register 'J' Saravanakrishnan Krishnamoorthy
2026-08-06 20:25   ` sashiko-bot [this message]
2026-08-06 19:55 ` [PATCH v3 18/19] selftests: crypto: cmh - add kselftest for management ioctl Saravanakrishnan Krishnamoorthy
2026-08-06 19:55 ` [PATCH v3 19/19] MAINTAINERS: add Rambus CryptoManager Hub (CMH) Saravanakrishnan Krishnamoorthy

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=20260806202513.34DB71F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=skrishnamoorthy@rambus.com \
    /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