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=1796219588; b=KRsef3O994Umoxx5uHtsUDqUc+LkeSkBAbqDfS1K4bJutmeN/8veiqikZ2bJMwQt8AIq hsw3Raou/mCSu6TITG1MSUT9Ak6JnkJffHiGeZRZUbaRSzNSM0aseUowpJL3H7UPpdNIy qI+IiBvjdsi2saJhp29aBTc9rFWeCr8Rs+JQRlfgTvM4cAy/8v9PpSwSPpXKsRLZAmxam EWkOHiaxDJGUMhj+SPv0pm5I6R8TSaYcz6uaql9lvtUZYqnT19FsGGtnNCBrZVgAxkQks evytXlEnb+9EHFgpwbBN6rQDBOMw3ntgvWs7/gGfgUE1KCpOisaqE2E1qP6075FcPKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796219588; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=d8TkSIO6+Iq5uJX8BXRuouJ6+6yM4Qa2m8SOwDaUwck=; b=XWYBrLlF/QYM2wSnw88WCZuOdE+TAkyBj8yz9gTQG8EQ9cP7rR44pgZhlHZAB2j65jqz FWSRVuXi8IZscwPx4GCDpH6LDxNY47SsdaUnAuHt+nEkwzQduRh+h37fFCAciZOdXbK5l l0eEXXsb4UKjAYwLo99LfqVBQZDqjj9PB13GdhnmNBoKkKgYGBJci9B74O/ymjtb1UrXf FFocnguz4NdNnd+E3rsr3D/Oz6YGnvd3h+67FiYaZF7SPB0Lubo9JJ/LHJN686P4Kcu6F xCPZhh3TKiRvD4e6FLg4zzw0xSmxf8UPn4B2QNcKHvi7Q7UVuK02lGmqoAIdkNHWigg== 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=jPgaoNDv; 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 A0FCE606A31A for ; Wed, 2 Dec 2026 13:53:08 +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=jPgaoNDv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A0C91F00893; Wed, 2 Dec 2026 13:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796219588; bh=d8TkSIO6+Iq5uJX8BXRuouJ6+6yM4Qa2m8SOwDaUwck=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=jPgaoNDvkKZtaXnSQluCBNODqScWHeubGqdtep1MXfMiGX4ay+4zmYNkopPLeVHUx kWJiGzI4uCFXdSPzwKV3jMqY4o6vj2gIWycIaRHffYFycL1bixWHIm7DCx7m51W1io Bo9hGvWEL1/77sk2BHUecgwxWjG744iXXyiRiEvNeD9DkkMGpWut5oPNmhVP1dV2Nl gpscRRDAhAR7i5t5m+quI96gMLWLEpqC8QJ2fucDS4ZH4dRqWrCiny9ulrUmfMM/bd urrAPHO8HefurD/+F3PuXKWdPU1cVS+ru80dIKBlDnTbUfJ01uW6t3njX/AzivXsW0 8R1CodvNsqs6w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] virtio: Handle vbuf allocation failure in panic path Reply-To: sashiko-reviews@lists.linux.dev To: Syh-Xiong <1850029304@qq.com> Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 13:53:07 +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 2 potential issues to consider: - [Medium] drm/virtio: NULL dereference of virtio_gpu_panic_get_vbuf() return in callers - [Low] drm/virtio: missing Fixes: trailer for commit 6f3d9d0dd335 It also noticed 1 related pre-existing issue this patch does not introduce: - [High] drm/virtio: slab allocation deadlock in virtio_gpu_panic_get_vbuf() [1] -- commit 3cd455d3f4907312dc90888e92ffe07456cc5f36 Author: Syh-Xiong <1850029304@qq.com> > virtio: Handle vbuf allocation failure in panic path > > virtio_gpu_panic_get_vbuf() does not check the return value of > kmem_cache_zalloc(),so a failed allocation is followed by a > NULL pointer dereference. > > Signed-off-by: Syh-Xiong <1850029304@qq.com> [Severity: Low] Should this bug fix include a Fixes: tag for the commit that added virtio_gpu_panic_get_vbuf()? Fixes: 6f3d9d0dd335 ("drm/virtio: Add drm_panic support") > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio= /virtgpu_vq.c > index d99fb9e326e81..0d7ae44471522 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c > @@ -94,6 +94,8 @@ virtio_gpu_panic_get_vbuf(struct virtio_gpu_device *vgd= ev, int size) > struct virtio_gpu_vbuffer *vbuf; > =20 > vbuf =3D kmem_cache_zalloc(vgdev->vbufs, GFP_ATOMIC); [Severity: High] This problem wasn't introduced by this patch, but calling kmem_cache_zalloc() from the drm_panic handler can deadlock [1] if the kernel panics while a slab allocator spinlock is already held, hanging the system before the panic screen or kdump can run. > + if (!vbuf) > + return NULL; [Severity: Medium] Does returning NULL here still result in an immediate NULL pointer dereference in the callers? Its sole caller, virtio_gpu_panic_alloc_cmd_resp(), does not check vbuf before reading vbuf->buf: drivers/gpu/drm/virtio/virtgpu_vq.c:virtio_gpu_panic_alloc_cmd_resp() { vbuf =3D virtio_gpu_panic_get_vbuf(vgdev, cmd_size); *vbuffer_p =3D vbuf; return (struct virtio_gpu_command *)vbuf->buf; } Both callers of virtio_gpu_panic_alloc_cmd_resp(), virtio_gpu_panic_cmd_resource_flush() and virtio_gpu_panic_cmd_transfer_to_host_2d(), also pass the returned cmd_p to memset() and dereference vbuf->objs without checking for NULL. [1] https://sashiko.dev/#/bug/linux-c6d68f26-60e8-47ae-8a01-6ff4145223a3 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/tencent_108E6BD0C26= 83FCD678A1B68C99A5CFFF806@qq.com?part=3D1