From: "Óscar Megía López" <megia.oscar@gmail.com>
To: Dave Airlie <airlied@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
Cc: "Óscar Megía López" <megia.oscar@gmail.com>,
virtualization@lists.linux.dev,
spice-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev,
"Christian König" <christian.koenig@amd.com>
Subject: [PATCH] drm/qxl: zero-initialize struct qxl_release
Date: Sun, 22 Nov 2026 16:16:10 +0100 [thread overview]
Message-ID: <20261122151629.223013-1-megia.oscar@gmail.com> (raw)
qxl_release_free() used to check release->base.ops to find out whether
the embedded dma_fence had been initialized. Since commit 2bcbc706dfa0
("dma-buf: add dma_fence_was_initialized function v2") it uses a flag
in fence->flags instead, but qxl_release_alloc() allocates the release
with kmalloc(), so the flags contain stale data.
Cursor releases never go through dma_fence_init(), so with a stale flag
qxl_release_free() takes the initialized-fence path and calls
dma_fence_signal() on a garbage fence->lock, triggering:
BUG: KASAN: slab-use-after-free in _raw_spin_lock_irqsave+0x7b/0xe0
Write of size 4 at addr ffff888010462700 by task kworker/3:1/91
CPU: 3 UID: 0 PID: 91 Comm: kworker/3:1
Not tainted 7.3.0-00341-gf47d223627f8-dirty #556 PREEMPT(lazy)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS Arch Linux 1.17.0-2-2 04/01/2014
Workqueue: events qxl_gc_work
Call Trace:
<TASK>
dump_stack_lvl+0x4d/0x70
print_report+0x14b/0x4b0
? __pfx__raw_spin_lock_irqsave+0x10/0x10
kasan_report+0xfa/0x120
? _raw_spin_lock_irqsave+0x7b/0xe0
? _raw_spin_lock_irqsave+0x7b/0xe0
kasan_check_range+0x134/0x220
_raw_spin_lock_irqsave+0x7b/0xe0
? __pfx__raw_spin_lock_irqsave+0x10/0x10
? __kasan_slab_free+0x47/0x70
? kfree+0x21b/0x450
dma_fence_signal+0x72/0x130
qxl_release_free+0x2cf/0x600
qxl_garbage_collect+0x25c/0x500
? __pfx_qxl_garbage_collect+0x10/0x10
? __pfx__raw_spin_lock+0x10/0x10
process_one_work+0x696/0xf90
? __pfx___schedule+0x10/0x10
? __pfx_process_one_work+0x10/0x10
? _raw_spin_lock_irq+0x85/0xe0
? __pfx__raw_spin_lock_irq+0x10/0x10
worker_thread+0x4bd/0xd00
? __kthread_parkme+0x8d/0x170
? __pfx_worker_thread+0x10/0x10
? __pfx_worker_thread+0x10/0x10
kthread+0x32e/0x420
? recalc_sigpending+0x162/0x210
? __pfx_kthread+0x10/0x10
ret_from_fork+0x362/0x5a0
? __pfx_ret_from_fork+0x10/0x10
? __switch_to+0xaf9/0xf30
? __switch_to_asm+0x33/0x70
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocate with kzalloc() so an uninitialized fence is always seen as such.
Fixes: 2bcbc706dfa0 ("dma-buf: add dma_fence_was_initialized function v2")
Assisted-by: claude-Sonnet 5.5
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Óscar Megía López <megia.oscar@gmail.com>
---
drivers/gpu/drm/qxl/qxl_release.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 06979d0e8a9f..ffc9e8f0a4c2 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -91,7 +91,7 @@ qxl_release_alloc(struct qxl_device *qdev, int type,
int handle;
size_t size = sizeof(*release);
- release = kmalloc(size, GFP_KERNEL);
+ release = kzalloc(size, GFP_KERNEL);
if (!release) {
DRM_ERROR("Out of memory\n");
return -ENOMEM;
--
2.56.1
reply other threads:[~2026-11-22 15:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122151629.223013-1-megia.oscar@gmail.com \
--to=megia.oscar@gmail.com \
--cc=airlied@redhat.com \
--cc=christian.koenig@amd.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=spice-devel@lists.freedesktop.org \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®