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=1796453890; b=ZyMw2G77G2fu8ANowRYxIo1z4xaIXE+zL3b63/IiMwFTxlya6iY3hPKK2zzV/O39BZmI 2syxkvA1Nq2ruyGJUUFsScc9sDMUN6kE2Haw3PifzyKTl6ID2ON9e/EYBvosELsFacS0E qzEge0lbP976DjzWkhj3Zjs+KnnugJZwdEtyswmynnlyHBqRQSqZyYxIW0J1P4gdCQSKT ueJb4ty+3O3wT7enrp3s+jvmt4hkmnxzgzu9+4bgEMfqU2QAMDQz5oBLpKgyni/g6l4Ne NziYEPB6p6Tkd3ooQbR4TFTUdwOvjKwKbq/KqY9RfhBnLhY6Ue3rL+8k+qQ9/kr/A/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796453890; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=9AgipINivofU7DU0LPjTCSjYB/QeJUA/xxHq5k9pKYI=; b=oDs7f4Ag3yt6C80YvOykY8GMc7lJTXCfWhbh0rr9f2K64gMUv8z4+3P7lvfhQsmZ4ro0 oGoBqE/hl1b56xiMByKVhHv0ZSxAwxzZPOmogUjGaVMZIwXxSp1xg2I36krU/BpLkpZul 97RAte1Ip4BLV2G0ICpxZ2PtHgrQ2X+P3bFn7jdemrEOBvXEndBQUQodEM/d8iIFzFWXf gUEHyEozpG79GFpLDa85gyc+W85jnEFvh6OJLEV1tMDdes3dZQCg8fKYwCmwG4Yn9ObfM RxbEiXFl4FIEvMTx0mjw0Cn9MeskKOrYrtWNsQHy5dJ+hU1Ew1JfL+FGYFAlI2B64Ig== 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=OQBGqymp; 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 5B0B6606A322 for ; Sat, 5 Dec 2026 06:58:10 +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: 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 Reply-To: sashiko-reviews@lists.linux.dev 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-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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