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 61EE3606A337 for ; Sat, 5 Dec 2026 06:58:22 +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=OQBGqymp Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C106D10E17C; Sat, 5 Dec 2026 06:58:16 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D15410E17C for ; Sat, 5 Dec 2026 06:58:10 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 53E294097A; Sat, 5 Dec 2026 06:58:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05F321F00936; Sat, 5 Dec 2026 06:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796453890; bh=9AgipINivofU7DU0LPjTCSjYB/QeJUA/xxHq5k9pKYI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=OQBGqympnvhTQ+cBzusSlxnJ/GApN5xEkxuIyNXCiXt5xlN3zerjtPdtPjiX3A/Wo kxd67fVdOJJChGdwRTPYxCKCd0N+xkEz4+l1rJ1JLqhu6ytPk7HJPDMfmblvWg1Mzs 9TAUA6cjb8wcFOOpP8AwLBcu469M84x6GNrWV9CtyStgxsj9msZx8ys2RZfj+dgc2B 85tEdPQf/vpQFU/+Sj6+ZT7Ap4kxnLooec77rICNeLW0IDFbW/q1pWAho9kAgdpirl 2yizNvodpeZl2HfSt98bv60pRlOUvd02GQHManSathtXTGJYVhn+fPlD1X44Scsw7O GsIllDzG+0ARQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 2/2] drm/virtio: test transfer and damage history To: "Aditya Tipre" , dri-devel@lists.freedesktop.org Cc: virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261205063321.56168-3-tipreaditya@gmail.com> References: <20261205063321.56168-1-tipreaditya@gmail.com> <20261205063321.56168-3-tipreaditya@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 06:58:09 +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=-11.1 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/virtio: self-deadlock in virtio_gpu_dequeue_ctrl_func() via free_vbuf() - [Medium] drm/virtio: NULL dereference in transfer_test_exit() on init failure - [Low] drm/virtio: duplicate conflicting MODULE_LICENSE() in embedded KUnit tests -- commit dd698453aabfa8903931653819f0e8fe9b1fff6e Author: Aditya Tipre drm/virtio: test transfer and damage history This commit adds KUnit tests for virtio-gpu transfer ownership, response validation, and bounded damage history, linked into the virtio-gpu module when CONFIG_DRM_VIRTIO_GPU_KUNIT_TEST is enabled. > diff --git a/drivers/gpu/drm/virtio/Makefile b/drivers/gpu/drm/virtio/Mak= efile > index cede1184fa4ea..9db1b859d9a4f 100644 > --- a/drivers/gpu/drm/virtio/Makefile > +++ b/drivers/gpu/drm/virtio/Makefile > @@ -9,4 +9,7 @@ virtio-gpu-y :=3D virtgpu_drv.o virtgpu_kms.o virtgpu_gem= .o virtgpu_vram.o \ > virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o virtgpu_submit.o= \ > virtgpu_transfer.o virtgpu_damage.o > =20 > +virtio-gpu-$(CONFIG_DRM_VIRTIO_GPU_KUNIT_TEST) +=3D tests/virtgpu_transf= er_test.o > +virtio-gpu-$(CONFIG_DRM_VIRTIO_GPU_KUNIT_TEST) +=3D tests/virtgpu_damage= _test.o > + > obj-$(CONFIG_DRM_VIRTIO_GPU) +=3D virtio-gpu.o [Severity: Low] Does linking tests/virtgpu_transfer_test.o and tests/virtgpu_damage_test.o directly into virtio-gpu.o cause their MODULE_LICENSE("GPL") declarations to conflict with MODULE_LICENSE("GPL and additional rights") in virtgpu_drv.c? Because these tests are compiled into the composite virtio-gpu module rather than standalone test modules, each MODULE_LICENSE() adds a duplicate, conflicting license=3D entry (and duplicate virtio_gpu.file=3D entries when built-in) to .modinfo. Removing MODULE_LICENSE("GPL") from both test files avoids this. [ ... ] > diff --git a/drivers/gpu/drm/virtio/tests/virtgpu_transfer_test.c b/drive= rs/gpu/drm/virtio/tests/virtgpu_transfer_test.c > new file mode 100644 > index 0000000000000..a6ad76f601e19 > --- /dev/null > +++ b/drivers/gpu/drm/virtio/tests/virtgpu_transfer_test.c [ ... ] > +static int transfer_test_init(struct kunit *test) > +{ > + struct transfer_test *ctx; > + struct drm_gem_object *obj; > + > + ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); > + if (!ctx) > + return -ENOMEM; > + ctx->vgdev =3D kunit_kzalloc(test, sizeof(*ctx->vgdev), GFP_KERNEL); > + ctx->bo =3D kunit_kzalloc(test, sizeof(*ctx->bo), GFP_KERNEL); > + if (!ctx->vgdev || !ctx->bo) > + return -ENOMEM; > + test->priv =3D ctx; [ ... ] > +static void transfer_test_exit(struct kunit *test) > +{ > + struct transfer_test *ctx =3D test->priv; > + unsigned int i; > + > + virtio_gpu_transfer_stop(ctx->vgdev); [Severity: Medium] Can transfer_test_exit() dereference a NULL ctx when transfer_test_init() fails? If any of the three kunit_kzalloc() calls returns NULL, transfer_test_init() returns -ENOMEM before setting test->priv. KUnit still invokes suite->exit(test) in kunit_run_case_cleanup() on init failure, so transfer_test_exit() dereferences ctx->vgdev and oopses. Returning early when !ctx avoids the crash while letting KUnit free any partial allocations. [ ... ] > +static void transfer_test_success(struct kunit *test) > +{ > + struct transfer_test *ctx =3D test->priv; > + struct virtio_gpu_transfer *transfer =3D transfer_test_alloc(test); > + struct virtio_gpu_ctrl_hdr response; > + > + KUNIT_ASSERT_NOT_NULL(test, transfer); > + KUNIT_ASSERT_EQ(test, transfer_test_publish(ctx, transfer), 0); > + response =3D transfer_test_response(transfer); > + KUNIT_EXPECT_TRUE(test, virtio_gpu_transfer_reply(ctx->vgdev, transfer, > + &response, sizeof(response))); > + KUNIT_EXPECT_EQ(test, transfer->state, VIRTIO_GPU_TRANSFER_COMPLETE); > + KUNIT_EXPECT_EQ(test, ctx->vgdev->transfer_count[0], 0); > + KUNIT_EXPECT_EQ(test, kref_read(&transfer->ref), 1); > + virtio_gpu_fence_event_process(ctx->vgdev, transfer->fence_id); > +} [Severity: High] In the real completion path added by commit "drm/virtio: accumulate confirmed dumb-buffer damage", can free_vbuf() self-deadlock ctrlq.dequeue_work when virtio_gpu_transfer_put() drops the last BO reference? A damage-tracked transfer holds one GEM reference in entry->objs and another in transfer->bo. If userspace closes the GEM handle while the transfer is in flight, virtio_gpu_dequeue_ctrl_func() wakes ctrlq.ack_queue (allowing submitters to refill ctrlq.vq), schedules obj_free_work to drop entry->objs, and then calls free_vbuf() synchronously: CPU0 (ctrlq.dequeue_work) CPU1 (obj_free_work) virtio_gpu_dequeue_ctrl_func() virtio_gpu_transfer_reply() virtio_gpu_transfer_put() wake_up(&vgdev->ctrlq.ack_queue) virtio_gpu_array_put_free_delayed() virtio_gpu_array_put_free_work() drm_gem_object_put(bo) free_vbuf(vgdev, entry) virtio_gpu_transfer_put() virtio_gpu_transfer_release() drm_gem_object_put(bo) virtio_gpu_free_object() virtio_gpu_cmd_unref_resource() virtio_gpu_queue_ctrl_sgs() wait_event(ctrlq.ack_queue, ...) <-- self-deadlock Because ctrlq.dequeue_work is the only worker that reclaims ctrlq descriptors and wakes ctrlq.ack_queue, the entire control virtqueue hangs permanently. This is the same deadlock commit f0c6cef7e717 ("drm/virtio: add worker for object release") avoided by deferring GEM object release to obj_free_work. Deferring transfer release (or its BO reference drop) to obj_free_work would avoid running drm_gem_object_put() from ctrlq.dequeue_work. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205063321.5616= 8-1-tipreaditya@gmail.com?part=3D2