Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ryan Roberts" <ryan.roberts@arm.com>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	robh@kernel.org, conor+dt@kernel.org,
	"Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [RFC PATCH v2 09/15] misc/arm-cla: Add userspace interface
Date: Thu, 15 Oct 2026 14:47:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-172989@kernel.org> (raw)
In-Reply-To: <20261015142552.4128028-10-ryan.roberts@arm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] core: format string mismatch in dev_set_name causes init failure on 32-bit archs
- [Medium] misc/arm-cla: missing array_index_nospec in cla_vma_fault creates Spectre v1 gadget
--

commit 91161eb49b1b380686ad6f07674f5b53c3cf7baa
Author: Ryan Roberts <ryan.roberts@arm.com>

    misc/arm-cla: Add userspace interface
    
    Expose CLA devices through a character device so userspace can enumerate
    the available hardware and map accelerator register frames.

> diff --git a/drivers/misc/arm-cla/cla-user.c b/drivers/misc/arm-cla/cla-user.c
> new file mode 100644
> index 0000000000000..41cd5e4a7d017
> --- /dev/null
> +++ b/drivers/misc/arm-cla/cla-user.c
> @@ -0,0 +1,541 @@
[ ... ]
> +static vm_fault_t cla_vma_fault(struct vm_fault *vmf)
> +{
> +	struct vm_area_struct *vma = vmf->vma;
> +	struct cla_ctx_key key = CLA_CTX_KEY_PL0(vma->vm_mm, vma->vm_file);
> +	struct cla_domain *domain;
> +	struct cla_dev *dev;
> +	struct cla_ctx *ctx;
> +	unsigned long pg;
> +
> +	/*
> +	 * Reassignment needs mmap_lock, so we cannot wait while holding it.
> +	 * The private futex fault-in path can reach here without allowing
> +	 * mmap_lock to be dropped. Reject faults that do not allow retry.
> +	 */
> +	if (!(vmf->flags & FAULT_FLAG_ALLOW_RETRY))
> +		return VM_FAULT_SIGBUS;
> +
> +	pg = vma->vm_pgoff + ((vmf->address - vma->vm_start) >> PAGE_SHIFT);
> +	dev = cla_lut_pg[pg];
> +	domain = dev->domain;

[Severity: Medium]
In cla_vma_fault(), pg is calculated from the user-controlled vmf->address
and used to index the global cla_lut_pg array.

Is there a risk that speculative execution could bypass the VMA bounds checks
prior to this handler, resulting in an out-of-bounds read that is immediately
dereferenced? Could this create a Spectre v1 gadget, and should we use
array_index_nospec() to clamp pg before indexing?

> +
> +	mutex_lock(&domain->lock);
> +	ctx = cla_domain_lookup_ctx(domain, &key);
[ ... ]
> +static int __init cla_accel_class_add(const struct cla_accel_desc *desc)
> +{
> +	struct cla_accel_class *aclass;
> +	unsigned int i;
> +	int ret;
[ ... ]
> +	aclass->desc = *desc;
> +	device_initialize(&aclass->dev);
> +	aclass->dev.class = cla_class;
> +	aclass->dev.devt = cla_devt + cla_nr_classes;
> +	aclass->dev.release = cla_accel_class_release;
> +
> +	ret = dev_set_name(&aclass->dev, "%03lx:%03lx",
> +			   FIELD_GET(CLA_IIDR_IMPLEMENTER, desc->iidr),
> +			   FIELD_GET(CLA_IIDR_PRODUCTID, desc->iidr));

[Severity: High]
Does this format string cause argument misalignment on 32-bit architectures?

Because desc->iidr is a u64, FIELD_GET() returns a 64-bit value. Using %03lx
expects a 32-bit unsigned long on 32-bit systems. This could cause the first
%03lx to consume the lower 32 bits, and the second %03lx to consume the upper
32 bits, completely ignoring the intended PRODUCTID argument.

If devices share the same implementer but have different product IDs, could
this result in identical names and cause device_add() to fail with -EEXIST?

> +	if (ret)
> +		goto err_put;
> +
> +	/* The node cannot be opened until cla_user_init() adds the cdev. */
> +	ret = device_add(&aclass->dev);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015142552.4128028-1-ryan.roberts@arm.com?part=9

  reply	other threads:[~2026-10-15 14:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 14:25 [RFC PATCH v2 00/15] Arm Core Local Accelerator Driver Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 01/15] misc/arm-cla: Add driver skeleton and documentation Ryan Roberts
2026-10-15 14:35   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 02/15] misc/arm-cla: Add launch operation helpers Ryan Roberts
2026-10-15 14:42   ` sashiko-bot
2026-10-15 16:17   ` Greg Kroah-Hartman
2026-10-15 16:32     ` Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 03/15] dt-bindings: misc: Add Arm Core Local Accelerator Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 04/15] misc/arm-cla: Probe firmware-described devices Ryan Roberts
2026-10-15 14:37   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 05/15] misc/arm-cla: Initialize devices on CPU bringup Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 06/15] misc/arm-cla: Accelerator context save and restore Ryan Roberts
2026-10-15 14:41   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 07/15] misc/arm-cla: Set up memory translation context Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 08/15] misc/arm-cla: Manage domain contexts Ryan Roberts
2026-10-15 14:38   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 09/15] misc/arm-cla: Add userspace interface Ryan Roberts
2026-10-15 14:47   ` sashiko-bot [this message]
2026-10-15 14:25 ` [RFC PATCH v2 10/15] KVM: arm64: Introduce support to pin VMIDs Ryan Roberts
2026-10-15 14:38   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 11/15] KVM: arm64: Export stage-2 MMU config Ryan Roberts
2026-10-15 14:43   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 12/15] vfio: Support VFIO devices that access the CPU MMU Ryan Roberts
2026-10-15 14:44   ` sashiko-bot
2026-10-15 16:44   ` Jason Gunthorpe
2026-10-15 14:25 ` [RFC PATCH v2 13/15] misc/arm-cla: Add stage-2 MTC and VM context switch Ryan Roberts
2026-10-15 14:40   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 14/15] misc/arm-cla: Support exclusive context assignment Ryan Roberts
2026-10-15 14:41   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 15/15] misc/arm-cla: Add vfio-mdev user interface Ryan Roberts
2026-10-15 14:49   ` sashiko-bot
2026-10-15 16:41   ` Jason Gunthorpe

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=sashiko-outbox-172989@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=robh@kernel.org \
    --cc=ryan.roberts@arm.com \
    --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