From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 684CE606A33B for ; Wed, 2 Dec 2026 06:50:13 +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=E1k9YIVm Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C60AC10E325; Wed, 2 Dec 2026 06:50:07 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 082DE10E325 for ; Wed, 2 Dec 2026 06:50:01 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id D87556142B; Wed, 2 Dec 2026 06:49:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EA9C1F00893; Wed, 2 Dec 2026 06:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796194199; bh=HbBLLBebdb/p0qXHuTinS87J/D3v42c7Zt8DdM/iyJ4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=E1k9YIVmNu86hLT6x9FmLf/8nPzJVJefu2IPcoOe8SGz++c9Hk2H9mwlx4SV7GKQB azYlwruHkxdXy9wqCMskRjyT76yBUUmJopwSjYsAKYOIcF0YAGWa+Gk+1hbp2pwfhh NSmDGJ2/gHiezMmyWnbeOnVPW/Fsaeu2Ksj0bW/UGViN0bKG18oQpkkEqirQZDvhh4 GeyzQuvmDlSTpVwPUveLfwD+0xc5HyktkLtIsQpjEvF4ymZPuTQk40DmTai7bL/Atx JU3ca/yVh9eHF8EMQ6UdlV/GSfodWRngrhmGHvR0R37K49WwCCuf/ccipEQR22J4ZY HhTKwngjOeadg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 3/6] drm/imagination: Save metadata from firmware To: "Alexandru Dadu" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261202-b4-commonize-fw-segment-loading-v2-3-45fd5153c040@imgtec.com> References: <20261202-b4-commonize-fw-segment-loading-v2-0-45fd5153c040@imgtec.com> <20261202-b4-commonize-fw-segment-loading-v2-3-45fd5153c040@imgtec.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 06:49:59 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] drm/imagination: undefined pvr_exp_fw_support in pvr_fw_load_version() - [Medium] drm/imagination: UAF and NULL deref of metadata in pvr_fw_info_get() - [Low] drm/imagination: misplaced parenthesis in pvr_fw_info_header_validate() -- commit b39417857398d201ed66dd9476480df29442e140 Author: Matt Coster drm/imagination: Save metadata from firmware This commit extracts firmware version and section layout metadata from the firmware header into an allocated struct pvr_fw_metadata during device initialization. > diff --git a/drivers/gpu/drm/imagination/pvr_fw.c b/drivers/gpu/drm/imagi= nation/pvr_fw.c > index cbde54c7291c7..2a5dcd9aeed71 100644 > --- a/drivers/gpu/drm/imagination/pvr_fw.c > +++ b/drivers/gpu/drm/imagination/pvr_fw.c [ ... ] > @@ -1549,8 +1387,8 @@ pvr_fw_info_get(const struct pvr_device *pvr_dev, > if (fw_info._padding_4) > return -EINVAL; > =20 > - fw_info.major_version =3D pvr_dev->fw_version.major; > - fw_info.minor_version =3D pvr_dev->fw_version.minor; > + fw_info.major_version =3D pvr_dev->fw_dev.metadata->version.major; > + fw_info.minor_version =3D pvr_dev->fw_dev.metadata->version.minor; > =20 > err =3D PVR_UOBJ_SET(args->pointer, args->size, fw_info); > if (err < 0) [Severity: Medium] Can pvr_fw_info_get() trigger a use-after-free or NULL pointer dereference on pvr_dev->fw_dev.metadata during device removal? Previously, pvr_fw_info_get() read pvr_dev->fw_version, which lived inside struct pvr_device for the lifetime of the DRM device. With this change, pvr_fw_free_metadata_and_device_info() frees and clears pvr_dev->fw_dev.metadata during pvr_device_fini(), which pvr_remove() runs before drm_dev_unplug(): CPU0 CPU1 pvr_remove() pvr_ioctl_dev_query() drm_dev_enter() pvr_device_fini() ... pvr_fw_free_metadata_and_device_info() kfree(pvr_dev->fw_dev.metadata) pvr_dev->fw_dev.metadata =3D NULL pvr_fw_info_get() pvr_dev->fw_dev.metadata->versi= on <-- use-after-free / NULL deref drm_dev_unplug() > diff --git a/drivers/gpu/drm/imagination/pvr_fw.h b/drivers/gpu/drm/imagi= nation/pvr_fw.h > index dab8292a84791..51acefde73ee2 100644 > --- a/drivers/gpu/drm/imagination/pvr_fw.h > +++ b/drivers/gpu/drm/imagination/pvr_fw.h > @@ -23,6 +22,30 @@ struct pvr_vm_context; > =20 > #define ROGUE_FWIF_KCCB_NUMCMDS_LOG2_DEFAULT 7 > =20 > +extern bool pvr_exp_fw_support; [ ... ] > diff --git a/drivers/gpu/drm/imagination/pvr_fw_info.c b/drivers/gpu/drm/= imagination/pvr_fw_info.c > new file mode 100644 > index 0000000000000..b0f2dad91fc32 > --- /dev/null > +++ b/drivers/gpu/drm/imagination/pvr_fw_info.c > @@ -0,0 +1,345 @@ [ ... ] > +static bool > +pvr_fw_load_version(struct pvr_device *pvr_dev, > + const struct pvr_fw_info_header *header, > + struct pvr_fw_version *version_out) > +{ > + struct drm_device *drm_dev =3D from_pvr_device(pvr_dev); > + bool invalid =3D false; > + > + struct pvr_fw_version version =3D { > + .major =3D header->fw_version_major, > + .minor =3D header->fw_version_minor, > + .build =3D header->fw_version_build, > + .open_source =3D header->flags & PVR_FW_FLAGS_OPEN_SOURCE, > + }; > + > + if (!version.open_source) { > + drm_err(drm_dev, "Firmware is not open-source compatible (found versio= n " PVR_FW_VERSION_FMT ")\n", > + PVR_FW_VERSION_FMT_ARGS(&version)); > + invalid =3D true; > + } > + > + if (version.major =3D=3D 0 || > + (version.major > PVR_FW_MAX_SUPPORTED_MAJOR_VERSION && !pvr_exp_fw_= support) || > + (version.major !=3D PVR_FW_MAX_SUPPORTED_MAJOR_VERSION && pvr_exp_f= w_support)) { > + drm_err(drm_dev, "Firmware version is unsupported (known range is 1..%= u inclusive, found " > + PVR_FW_VERSION_FMT ")\n", > + PVR_FW_MAX_SUPPORTED_MAJOR_VERSION, > + PVR_FW_VERSION_FMT_ARGS(&version)); > + invalid =3D true; > + } [Severity: High] As reported by kernel test robot on v1 [1], is the definition of pvr_exp_fw_support missing? Nothing in the tree defines it, so linking vmlinux or modpost for powervr.ko fails with an undefined symbol error. Also, when pvr_exp_fw_support is true, the check rejects any version.major !=3D PVR_FW_MAX_SUPPORTED_MAJOR_VERSION, which blocks experimental firmware major versions above PVR_FW_MAX_SUPPORTED_MAJOR_VERSI= ON instead of allowing them. > + > + if (invalid) > + return false; > + > + *version_out =3D version; > + return true; > +} > + > +static int > +pvr_fw_info_header_validate(struct pvr_device *pvr_dev, > + const struct pvr_fw_info_header *header, > + struct pvr_fw_version *fw_version_out) > +{ > + struct drm_device *drm_dev =3D from_pvr_device(pvr_dev); > + bool invalid =3D false; > + > + if (header->info_version !=3D PVR_FW_INFO_VERSION) { > + drm_err(drm_dev, > + "Firmware version is unsupported (known version is %u, found %u)\n", > + PVR_FW_INFO_VERSION, header->info_version); > + return -EINVAL; > + } > + > + if (header->header_len !=3D sizeof(struct pvr_fw_info_header)) { > + drm_err(drm_dev, "Firmware header size mismatch (found=3D%u, expected= =3D%zu)\n)", > + header->header_len, sizeof(struct pvr_fw_info_header)); > + return -EINVAL; > + } > + > + if (!header->layout_entry_num || !header->layout_entry_size) { > + drm_err(drm_dev, "Firmware layout table missing\n"); > + invalid =3D true; > + } else if (header->layout_entry_size !=3D sizeof(struct pvr_fw_layout_e= ntry)) { > + drm_err(drm_dev, > + "Firmware layout table entry size mismatch (found=3D%u, expected=3D%z= u)\n)", > + header->layout_entry_size, sizeof(struct pvr_fw_layout_entry)); > + invalid =3D true; > + } else if (header->layout_entry_num > PVR_FW_INFO_MAX_NUM_ENTRIES) { > + drm_err(drm_dev, "Firmware layout table is too large (found=3D%u, max= =3D%u)\n)", > + header->layout_entry_num, PVR_FW_INFO_MAX_NUM_ENTRIES); > + invalid =3D true; [Severity: Low] These three drm_err() format strings end with "\n)" instead of ")\n", which prints the closing parenthesis on the next log line. [1] https://lore.kernel.org/r/20261126130340.K8Rznt4t-lkp@intel.com --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-b4-commoni= ze-fw-segment-loading-v2-0-45fd5153c040@imgtec.com?part=3D3