From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380364; b=Jw9DENTgzhUHamLPhtoaQw7idn7kukQ/l/QBJKGNU15UpEqVtzmGxNNLY4GekfnFxW/v tOk1DWTZ3Bs5/zvPdPJXGoUxdmENOU/8ypKuYSHUfcz28qN49jTcOL0pw4c5kcX2KmQ4P a3Uovu9drqPZzvP/ukJ9b+/XF1ydURTNNixFfy3UM8VN4TkUjiiRCsLTJfx0vSG0JhpNI 7Y2slG5E/3v0pbaJ5kPir5+9Gl60kMyl1NZ/WPV2yLPpTV2xQr7GCg59Wum33SlxFyX9o 5n81yyqNE7rvj2zo0cAOAVw2VhGIvE+67i/uGbn/qzX24al6jQQOcNQmRG5KuxHkLZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380364; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Date:From: To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=UwAFvs99O8iz3W0CS6HOfcFLoG794hw/nAu91DOWv/8=; b=o0z4xl+xc8WKrXbBgvdWKKtcAgdxljBrwCHWBZqkBDpjGZDeWpRYaiKsc2NkddOATrA2 +jycD4p5NT6Ulo6d6fVN8GutqeugMYpNiKnCNXsjdYQ6rluFrvKYE+vx2Q/lYwl6RrFbc A9xZH0pdCXfChnBkQ4qrlpwveD27gXD7DAZCMN/yLffvEhdTqWvCp4E9Lb7nyiLx+LFTc yR2+29HLxA8aGPiGRIzEO6OvG9VvGcT4e2rlDxCA/Nwl+zFmODKpDlFgkv96XPtVddmam 3uk819X8S3gUfNrQe6DtDW4MFbWU2NMBzOXO+FVvUxgkN2GkARyJHGEnDj4ArIvwoXQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZAyKBkJO; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b="YAqBp0w/"; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37A15606A333 for ; Fri, 4 Dec 2026 10:32:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 37A15606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZAyKBkJO; dkim=pass (2048-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=YAqBp0w/ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796380364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UwAFvs99O8iz3W0CS6HOfcFLoG794hw/nAu91DOWv/8=; b=ZAyKBkJOGQeAWVJ0n32CIKXPEEIBBpiv0ZocOJ28kE+PLj8ysXO+ZAOIDhHb/xrfvBS5UQ yvcrd0a+dL4OMX5SaSrY5+u6C17ymIyjnOdCLT98D92I1/Blp3Neb8YGGoBUQcSIp3ZUDe ICR7k1JINBb3txyG6wIjRpOLSGOIVgE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-tM3yHAIxPmyNTT-MuRVQzQ-1; Fri, 4 Dec 2026 10:32:41 +0000 X-MC-Unique: tM3yHAIxPmyNTT-MuRVQzQ-1 X-Mimecast-MFC-AGG-ID: tM3yHAIxPmyNTT-MuRVQzQ_1796380360 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4bb6bbc025aso7139995e9.3 for ; Fri, 04 Dec 2026 02:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796380360; x=1796985160; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=UwAFvs99O8iz3W0CS6HOfcFLoG794hw/nAu91DOWv/8=; b=YAqBp0w/WDNAAD5JhgTdfTQd47q0Zs2u8skIeyVdOBvXtlC+atqR5LQA3oSra+3vWO C8T7ctXlkh3+1QIf4MO6ONvZgOe34jTGVxbdRKBXD+s/o4wRGHkmdFPuf/OH3HGYtcvO Ahb36ufjgCrkMFGM0VFezHSCRTDqFw80T17vVKgbE4RmdPREWR4Uo6piG6TYKDy7GrHt PuES+fuUk+NdszzZYJaqvU88tDoQQ1OuEl1zUxeuwuFa9nk0CFHJ5nlReZ7PRLws9MSR bsyM1gs4g7ADhW52IN2/rO9dlzxBgNEvNEbirRYwk2O+IYTTM/ARDL7YGwJUFVQbIlJp cXeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796380360; x=1796985160; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=UwAFvs99O8iz3W0CS6HOfcFLoG794hw/nAu91DOWv/8=; b=s5a1KikO+njaQUlZQaCfTcWoG8YB1Q+649ytlwc2aDWb2UYtYyhzlCg9367KOcGQIm 2x/J6cUaVdPcfoKSgNHyFKjw8LKEr21GwWYGZRnD84nkMdfEdnZrtQSl6BG6ASHDrAz4 Fg4tTijTptBeWhEkKlng8ouXQSAkjamrfF1WUPEsFOp7T3qx8oh5r/W2GaPydLH9/TqK 3TEZR1lBhKhNBfWtBbR5wrtwVqPUrHjWMwAD97BxXvyI480AtWVxPZl8rfxlWV/6hV5R UmRASvdvmbGOJn2NNMX+Bl2S4egUz0GVQ2X3JPrT2DSwM8UO9ucejK0wSrgonjXnBR42 F0uQ== X-Gm-Message-State: APuU4Z8yF820+tuExlVqjZbvV4YMnqzpNgfHoxYesrCCmSI5Ox/nEW1I U9bEHeCR4AR1rqBBs2/SpEMadfT97Qv2o4KFE7WQgiwHRCroE8mYbjKfySIkqMzvyyE/zvGi3q3 Ozbg97LV4TUtVnv0GJta4gkBa1F0ad9w5k7yKguZnJbFxBCX0FXelyVklFYjzlA== X-Gm-Gg: AZFdTZeL/E1x5KzTlkvV8ptgne15RAjofOCD15qcLQ8qYxQ/iBELEt4gCXR7/5yysBn edqlHALdYVUUhkhEDr8BahXleB/EOtJOYpMlr7LqJ5a5/oMSXnA3VuKT6a9HPOv55YKDQYSi81C tFi1mUjwPJARCaO2dr8d4eTNHZw+HmYt6HzSJqCsKx/dG3/Z7xOowvuCV+sGbJhxvxHMnLJRJah 9pi613IQLBETi3q+qG56EHn7a6cr6U/+k6xUg/LKs+hhgh7SkX632N2sULPmBBWZzxJEXBusHK0 sl9DHA0+uBpOJ6tMWAxOyvx9HkeHfSdtQRJbAFM6zC/rW062Z3axgcKK9pBMNxy8Eh5ASgktkpO tIQ0hXqj4Fc+1TnDspAxFOxV3dzoSTaIoyZAx9ahs1Q== X-Received: by 2002:a05:600d:12:b0:4a1:f720:74cd with SMTP id 5b1f17b1804b1-4bbeb8dd849mr22138045e9.24.1796380359828; Fri, 04 Dec 2026 02:32:39 -0800 (PST) X-Received: by 2002:a05:600d:12:b0:4a1:f720:74cd with SMTP id 5b1f17b1804b1-4bbeb8dd849mr22137555e9.24.1796380359256; Fri, 04 Dec 2026 02:32:39 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:153a:4c00:6468:7acf:febf:a046]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbea298de4sm34975165e9.1.2026.12.04.02.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 02:32:38 -0800 (PST) Date: Fri, 4 Dec 2026 05:32:36 -0500 From: "Michael S. Tsirkin" To: sashiko-reviews@lists.linux.dev Cc: kvm@vger.kernel.org Subject: Re: [PATCH v6] vfio/pci: expose ACPI _ROM through a device region Message-ID: <20261204053151-mutt-send-email-mst@kernel.org> References: X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Dec 04, 2026 at 10:19:57AM +0000, sashiko-bot@kernel.org wrote: > 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); > > > > +#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 = VFIO_PCI_OFFSET_TO_INDEX(*ppos); > > + struct vfio_pci_region *region = &vdev->region[index - VFIO_PCI_NUM_REGIONS]; > > + u64 pos = *ppos & VFIO_PCI_OFFSET_MASK; > > + struct acpi_object_list params = { ARRAY_SIZE(args), args }; > > + struct acpi_buffer result = { 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 = pos % SZ_4K; > > + union acpi_object args[] = { > > + { .integer = { .type = ACPI_TYPE_INTEGER, .value = pos - skip } }, > > + { .integer = { .type = ACPI_TYPE_INTEGER, .value = 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. Ugh. Should teach me not to try hand editing the patch right before sending( Pls ignore will retest and resend. > > + > > + 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 = result.pointer; > > + available = min_t(size_t, obj->buffer.length, SZ_4K); > > + if (skip >= available) { > > + kfree(obj); > > + return 0; > > + } > > + > > + count = min(count, available - skip); > > + count -= copy_to_user(buf, obj->buffer.pointer + skip, count); > > + kfree(obj); > > + if (!count) > > + return -EFAULT; > > + > > + *ppos += 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 >= 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. > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/fc3a67c19998f3fbfcfa3511a87a56f07697c9a1.1796376699.git.mst@redhat.com?part=1