From: Wang Xiaolei <wangxiaolei01@kaihong.com>
To: mwen@igalia.com, mcanal@igalia.com,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
tvrtko.ursulin@igalia.com, wangxiaolei01@kaihong.com
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Iago Toral Quiroga <itoral@igalia.com>
Subject: [PATCH] drm/v3d: Fix double free of query arrays when extension parsing fails
Date: Tue, 10 Nov 2026 06:13:41 +0000 [thread overview]
Message-ID: <20261110061341.2075931-1-wangxiaolei01@kaihong.com> (raw)
v3d_get_cpu_timestamp_query_params() and v3d_copy_query_info() - the
latter used by both performance query parsers - free the query array on
their error paths through v3d_timestamp_query_info_free() /
v3d_performance_query_info_free(), but leave query_info->queries
pointing at the freed buffer.
The same job is then released by v3d_submit_cpu_ioctl()'s failure path
(v3d_submit_cleanup_jobs() -> v3d_job_cleanup() -> v3d_job_put() ->
v3d_cpu_job_free()), which calls the same helpers on the same
query_info. On these error paths query_info->count was never assigned -
it is only written after the parsing loop completes - so the syncobj
loop runs zero times and no syncobj is put twice, but the
"if (query_info->queries)" test still succeeds and the dangling pointer
is handed to kvfree() a second time.
Every failure inside the parsing loop takes this path: -ENOENT from
drm_syncobj_find(), -EFAULT from get_user(), or -ENOMEM from
kvmalloc_array() in v3d_copy_query_info(). The helpers are shared
between that error path and the job release path.
Clear the pointer once the buffer has been freed.
Fixes: 0e50fcc20bd8 ("drm/v3d: Fix potential memory leak in the timestamp extension")
Fixes: 32df4abc44f2 ("drm/v3d: Fix potential memory leak in the performance extension")
Cc: stable@vger.kernel.org
Cc: Maíra Canal <mcanal@igalia.com>
Cc: Iago Toral Quiroga <itoral@igalia.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Wang Xiaolei <wangxiaolei01@kaihong.com>
---
drivers/gpu/drm/v3d/v3d_sched.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
index 1924e3440dc9..a96023b5dce0 100644
--- a/drivers/gpu/drm/v3d/v3d_sched.c
+++ b/drivers/gpu/drm/v3d/v3d_sched.c
@@ -106,6 +106,7 @@ v3d_timestamp_query_info_free(struct v3d_timestamp_query_info *query_info,
drm_syncobj_put(query_info->queries[i].syncobj);
kvfree(query_info->queries);
+ query_info->queries = NULL;
}
}
@@ -122,6 +123,7 @@ v3d_performance_query_info_free(struct v3d_performance_query_info *query_info,
}
kvfree(query_info->queries);
+ query_info->queries = NULL;
}
}
--
2.34.1
reply other threads:[~2026-11-10 6:14 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=20261110061341.2075931-1-wangxiaolei01@kaihong.com \
--to=wangxiaolei01@kaihong.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=itoral@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=tvrtko.ursulin@igalia.com \
--cc=tzimmermann@suse.de \
/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®