From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379600; b=u1rW41JZGdbO5gMSJr2om0agwoW3qjAKGDcAJG+z6jJ/NLm+h4QN0XfFUgl41n0W2ygU sGU8Th3GxmZ614WEsvH0KraH4/sNIV4TXwk6FMobbzer7qyduMTMLoQIVX/JsybOQ9CAV L9xHsr8O3td/WknfNdr7jsMpC48GNgh02NXx5bvQp4dLVvHfp60QVqCuwXDrOp4ny4gdO a8AHKehF907JQ0SwQwPXNBJ9BrHw7iuDlvzE8MTJwdvVI8KX3/Xdy4yO8B4l+Goy2eOy6 LX3CjPAdp3c/aNmoFO/OqGP0xj6KoD90eixIMzOotXP7bkymZPo0aJE+i3OiDSEGFCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379600; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+1P8PNMqu+2VnAwy27Co65lHjerkhqWcV4roBQDT18w=; b=UkSuHRfONeloHwXHD9tyzN9uguqgWq7+iroBob7/+E8TaHGh18OsqHnwwmCPiMVLqdZZ 7L7+FuWu5oPJ2nEXSp4gyHLt8nYNjqiDYIuhZcWM/G+9CWG70xOrxQbtCcBgde5vSJruo SwQFgv1fGtNXAC0bzl8x6TpE3pOPYAM7sCE0h9NZ9dZlpi1l/+1V/bHWbGV7emOAhdFki HcBPmmkQFVWbYEFx4s2Ky6XbwTrF8oUelJ6Ug6cyEEKpadVyQ9yVPcWEDbkOrC7rZqPH8 9f8CIHA2hyLidyYDwL0s+CVAiyc8AGXSNH3B1BtfLQFAprm+SbiUzNP96P70pwN3bow== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iH1puVxk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E26A6606A322 for ; Fri, 4 Dec 2026 10:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iH1puVxk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 451B21F00936; Fri, 4 Dec 2026 10:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796379599; bh=+1P8PNMqu+2VnAwy27Co65lHjerkhqWcV4roBQDT18w=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=iH1puVxkxRmA4CGLcqAIz5GaaR7kEbnz2VI1pgaZlGg/HXNn8E5EygDRu/isjhSJk CmekOKvFRDzIYFk08z4/U9IIa8duilXilyzdTkNn4x+ZOn+3h00bAo348XCHmqURNm wdCLTHgw2ZNPhoTHc+3MGNYi6FdsskCOdarHPDASM/57LZGVP5NWVYIBzKpBG3EOeq ES/kBy490gjna6v+DdYs7Puu0YbXe3jxfVDviMbNaSmz8e1/aZoT/cRO9JqVU7JMcl xNXfqVTil98bfdGKIooW8+wu4E5wr5vNmXnvfikt+4DStqmUZcTEa2jLh69Ml3EwIj W/iSIa34ozTkw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6] vfio/pci: expose ACPI _ROM through a device region Reply-To: sashiko-reviews@lists.linux.dev To: "Michael S. Tsirkin" Cc: kvm@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 10:19:57 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] vfio/pci: use of undeclared args in vfio_pci_acpi_rom_rw() breaks build - [Low] vfio/pci: unbounded pos in vfio_pci_acpi_rom_rw() wraps on 32-bit ACPI _ROM -- commit 89f4506412531a6bddab13afe01a5db3c586ee11 Author: Michael S. Tsirkin vfio/pci: expose ACPI _ROM through a device region This commit exposes a PCI device's ACPI _ROM method through a new read-only VFIO device region (VFIO_REGION_TYPE_ACPI / VFIO_REGION_SUBTYPE_ACPI_ROM) so userspace can read the option ROM contents. > diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci= _rdwr.c > index df88480876815..f9c225b0bc72e 100644 > --- a/drivers/vfio/pci/vfio_pci_rdwr.c > +++ b/drivers/vfio/pci/vfio_pci_rdwr.c [ ... ] > @@ -198,6 +201,85 @@ ssize_t vfio_pci_core_do_io_rw(struct vfio_pci_core_= device *vdev, bool test_mem, > } > EXPORT_SYMBOL_GPL(vfio_pci_core_do_io_rw); > =20 > +#ifdef CONFIG_ACPI > +static ssize_t vfio_pci_acpi_rom_rw(struct vfio_pci_core_device *vdev, > + char __user *buf, size_t count, > + loff_t *ppos, bool iswrite) > +{ > + unsigned int index =3D VFIO_PCI_OFFSET_TO_INDEX(*ppos); > + struct vfio_pci_region *region =3D &vdev->region[index - VFIO_PCI_NUM_R= EGIONS]; > + u64 pos =3D *ppos & VFIO_PCI_OFFSET_MASK; > + struct acpi_object_list params =3D { ARRAY_SIZE(args), args }; > + struct acpi_buffer result =3D { ACPI_ALLOCATE_BUFFER, NULL }; > + union acpi_object *obj; > + size_t available; > + /* > + * ACPI limits requests to 4K, and some FW seems to only handle > + * full 4K aligned blocks. See > + * ad4a36263535 ("drm/nouveau/bios: split out shadow methods"). > + * and > + * d1626a965141 ("drm/nouveau/bios: fetch full 4KiB block to determine = ACPI ROM image size"). > + */ > + size_t skip =3D pos % SZ_4K; > + union acpi_object args[] =3D { > + { .integer =3D { .type =3D ACPI_TYPE_INTEGER, .value =3D pos - skip } = }, > + { .integer =3D { .type =3D ACPI_TYPE_INTEGER, .value =3D SZ_4K } }, > + }; [Severity: High] Does this compile with CONFIG_ACPI enabled? params references args and ARRAY_SIZE(args) before args[] is declared. Moving params after args[] would fix the build failure. > + > + if (iswrite) > + return -EINVAL; > + > + if (!count) > + return 0; > + > + if (ACPI_FAILURE(acpi_evaluate_object_typed(region->data, NULL, ¶ms, > + &result, ACPI_TYPE_BUFFER))) > + return -EIO; > + > + obj =3D result.pointer; > + available =3D min_t(size_t, obj->buffer.length, SZ_4K); > + if (skip >=3D available) { > + kfree(obj); > + return 0; > + } > + > + count =3D min(count, available - skip); > + count -=3D copy_to_user(buf, obj->buffer.pointer + skip, count); > + kfree(obj); > + if (!count) > + return -EFAULT; > + > + *ppos +=3D count; > + return count; > +} [Severity: Low] Should pos be bounded before passing it to ACPI _ROM? Because VFIO_PCI_OFFSET_MASK allows 40-bit offsets up to 1 TiB, a read at an offset >=3D 4 GiB passes a value above U32_MAX as Arg0. ACPICA truncates values above U32_MAX to 32 bits on 32-bit DSDT tables in acpi_ex_truncate_for32bit_table(), and casts buffer field offsets to u32 in acpi_ds_init_buffer_field(). An out-of-range read can therefore wrap modulo 4 GiB and alias offset 0 instead of returning 0 or -EINVAL. In addition, adding count to *ppos in the final 4 KiB of the 40-bit offset range can carry into VFIO_PCI_OFFSET_SHIFT, though this is currently harmless because ACPI _ROM is registered last. Rejecting offsets above U32_MAX (or capping below 4 GiB) avoids both issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/fc3a67c19998f3fbfcf= a3511a87a56f07697c9a1.1796376699.git.mst@redhat.com?part=3D1