From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0D0A196C7C for ; Sun, 10 May 2026 04:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778388911; cv=none; b=AKPKEkgmIJA32oJ+9RHQkC/BfnzUSWLbajmwod/K4VaAqzvr+Zou9WOA9OtcQ45Bz4/HB6P2AFAUAGdprGi2XGKAamnyLOBI8GecSfuQXfdphFvr08us4KDHY9/KopNGuqxYZzy0Mdm8yYv262NdMeOzwPQFwsENyokSf5vSnYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778388911; c=relaxed/simple; bh=MFl8KiaQwXmBIL3qMqyRHkk7abjzh69yIfE/7EHm6ug=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=V9ePZ15L+qvh+x9pjZGnK1TwZv5fatlKu0WmeENFquVR0RTDdLG5GwJVow0DehycAzAbFFw2Fx0II07zT0vmTSD2mw3Gyeov6NuhymOdmBpWJwBkohhtd8qCLZBB0DMH1Fmv4W0RdxAdD4hizXZNu15moLaw3mK8P6R8JRJqF6s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7de44ba64e7so4830540a34.1 for ; Sat, 09 May 2026 21:55:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778388909; x=1778993709; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zZJLgGxzz9uFrUBHHhUkVePNoT/qya9TFiJFR8O1icA=; b=BvShXOcKXw5qedEBA4ArXWHMg7vWCAcbsfjg6o71EMDkXnJ2bgoSUjQdYSXQNdzWyZ +RgUTkX3bTPTlgA2KCXLbX8u+Y17U80Z0Y2/HF3q2AxUrB3w4M/2E3poCwkcGuBJ7XRM Uns5S86gKw9cbJznbppPS1vDqMyCfEXwowXli5w7gvwlc0QjiTuuMSxWvOxfJ2d7o7MW OoCTK5aTi0WuT4PfvgDdV8BmDcURtSIkuyBABdjQtJ3F1h+rOEsSgoBVwqrYzDg6QCAs Qt+r0ZWUoMrqA5Q2+pI8N+hVupC1bDpcRuZfVfntgQ4usdP3b/CstmI7W1L4Wyds1MV4 2NSg== X-Gm-Message-State: AOJu0YwlZlJO6hYsY9jF1ol7TW1ppRtcazP/nWzy0kQfdJ0xXOtzo/Ve qqM/rZXNoDFjsPl2hOidrR0/y+/xmylf9xMRRAvv1Sq5evsSpxwupkldnuecis27oeZXWrORwiS e5tHEBymSf/9CWdpxQa4gSnE+NpDvrFuXpgtq96Jd1Vx8gMdZMDsdFkdWgCA= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:213:b0:686:d107:2859 with SMTP id 006d021491bc7-69b36b3f1aamr2736980eaf.23.1778388908983; Sat, 09 May 2026 21:55:08 -0700 (PDT) Date: Sat, 09 May 2026 21:55:08 -0700 In-Reply-To: <69fd21b9.050a0220.3cf765.0360.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a000fac.050a0220.103c44.0002.GAE@google.com> Subject: Forwarded: [PATCH] drm/virtio: check virtio_gpu_array_lock_resv() return in cursor update From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] drm/virtio: check virtio_gpu_array_lock_resv() return in cursor update Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master virtio_gpu_cursor_plane_update() calls virtio_gpu_array_lock_resv() but ignores its return value. The function can fail in two ways: - dma_resv_lock_interruptible() returns -ERESTARTSYS when a signal is delivered while waiting for the reservation lock. - dma_resv_reserve_fences() returns -ENOMEM if it fails to allocate a fence slot; in this case lock_resv unlocks before returning. In both cases the resv lock is not held on return. The cursor path proceeds to queue a fenced transfer command. The queue path then walks the object array and calls dma_resv_add_fence() on the cursor BO's reservation. dma_resv_add_fence() requires the resv lock to be held; with lockdep enabled the missing lock trips dma_resv_assert_held(): WARNING: drivers/dma-buf/dma-resv.c:296 at dma_resv_add_fence+0x71e/0x840 Call Trace: virtio_gpu_array_add_fence+0xcd/0x140 virtio_gpu_queue_ctrl_sgs virtio_gpu_queue_fenced_ctrl_buffer+0x578/0xfb0 virtio_gpu_cursor_plane_update+0x411/0xbc0 drm_atomic_helper_commit_planes+0x497/0xf10 ... drm_mode_cursor_ioctl+0xd4/0x110 drm_ioctl+0x5e6/0xc60 __x64_sys_ioctl+0x18e/0x210 Beyond the WARN, mutating the dma_resv fence list without the lock races with concurrent readers/writers and can corrupt the list. Check the return value of virtio_gpu_array_lock_resv(). On failure, drop the references taken by virtio_gpu_array_add_obj() with virtio_gpu_array_put_free() (which does not unlock, matching the not-locked state) and return without queueing the command. A skipped cursor frame is harmless; the WARN and the underlying race are not. The bug was reported by syzbot, triggered via fault injection (fail_nth) on the DRM_IOCTL_MODE_CURSOR path, which forces the -ENOMEM branch in dma_resv_reserve_fences(). Reported-by: syzbot+72bd3dd3a5d5f39a0271@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=72bd3dd3a5d5f39a0271 Signed-off-by: Deepanshu Kartikey --- drivers/gpu/drm/virtio/virtgpu_plane.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index a126d1b25f46..ca379b08b9ec 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -459,7 +459,10 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane, if (!objs) return; virtio_gpu_array_add_obj(objs, vgfb->base.obj[0]); - virtio_gpu_array_lock_resv(objs); + if (virtio_gpu_array_lock_resv(objs)) { + virtio_gpu_array_put_free(objs); + return; + } virtio_gpu_cmd_transfer_to_host_2d (vgdev, 0, plane->state->crtc_w, -- 2.43.0