* [PATCH] drm/xe/guc: Fix invalid kfree() call via __cleanup on pointer
@ 2026-06-17 14:26 Wentao Liang
2026-08-12 14:07 ` Thomas Huth
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-17 14:26 UTC (permalink / raw)
To: matthew.brost, thomas.hellstrom, rodrigo.vivi, airlied, simona
Cc: intel-xe, dri-devel, linux-kernel, Wentao Liang, stable
The variable `buf` in `fast_req_dump()` is declared with
`__cleanup(kfree)`, which passes `&buf` (the stack address of the
pointer variable) to kfree() rather than the heap address stored
in `buf`. This would cause an invalid free of a stack address,
leading to memory corruption or a crash.
`__cleanup(func)` is designed for value-typed variables where the
cleanup function should receive a pointer to the variable. For
heap-allocated pointers, `__free(kfree)` must be used instead,
since DEFINE_FREE creates a wrapper that correctly dereferences
the pointer before passing it to kfree().
This is the same class of bug recorded in CVE-2026-45959 and fixed by
commit d5abcc33ee76 ("crypto: ccp - Fix a crash due to incorrect
cleanup usage of kfree").
Fixes: ea944d57eac7 ("drm/xe/guc_ct: Cleanup ifdef'ry")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/gpu/drm/xe/xe_guc_ct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
index a11cff7a20be..73867a5cbe3a 100644
--- a/drivers/gpu/drm/xe/xe_guc_ct.c
+++ b/drivers/gpu/drm/xe/xe_guc_ct.c
@@ -116,7 +116,7 @@ static void fast_req_dump(struct xe_guc_ct *ct, u16 fence, unsigned int slot)
{
struct xe_gt *gt = ct_to_gt(ct);
#if IS_ENABLED(CONFIG_DRM_XE_DEBUG_GUC)
- char *buf __cleanup(kfree) = kmalloc(SZ_4K, GFP_NOWAIT);
+ char *buf __free(kfree) = kmalloc(SZ_4K, GFP_NOWAIT);
if (buf && stack_depot_snprint(ct->fast_req[slot].stack, buf, SZ_4K, 0))
xe_gt_err(gt, "Fence 0x%x was used by action %#04x sent at:\n%s\n",
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/xe/guc: Fix invalid kfree() call via __cleanup on pointer
2026-06-17 14:26 [PATCH] drm/xe/guc: Fix invalid kfree() call via __cleanup on pointer Wentao Liang
@ 2026-08-12 14:07 ` Thomas Huth
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2026-08-12 14:07 UTC (permalink / raw)
To: Wentao Liang, matthew.brost, thomas.hellstrom, rodrigo.vivi,
airlied, simona
Cc: intel-xe, dri-devel, linux-kernel, stable, Ella Ma
On 17/06/2026 16.26, Wentao Liang wrote:
> The variable `buf` in `fast_req_dump()` is declared with
> `__cleanup(kfree)`, which passes `&buf` (the stack address of the
> pointer variable) to kfree() rather than the heap address stored
> in `buf`. This would cause an invalid free of a stack address,
> leading to memory corruption or a crash.
>
> `__cleanup(func)` is designed for value-typed variables where the
> cleanup function should receive a pointer to the variable. For
> heap-allocated pointers, `__free(kfree)` must be used instead,
> since DEFINE_FREE creates a wrapper that correctly dereferences
> the pointer before passing it to kfree().
>
> This is the same class of bug recorded in CVE-2026-45959 and fixed by
> commit d5abcc33ee76 ("crypto: ccp - Fix a crash due to incorrect
> cleanup usage of kfree").
>
> Fixes: ea944d57eac7 ("drm/xe/guc_ct: Cleanup ifdef'ry")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/gpu/drm/xe/xe_guc_ct.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> index a11cff7a20be..73867a5cbe3a 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> @@ -116,7 +116,7 @@ static void fast_req_dump(struct xe_guc_ct *ct, u16 fence, unsigned int slot)
> {
> struct xe_gt *gt = ct_to_gt(ct);
> #if IS_ENABLED(CONFIG_DRM_XE_DEBUG_GUC)
> - char *buf __cleanup(kfree) = kmalloc(SZ_4K, GFP_NOWAIT);
> + char *buf __free(kfree) = kmalloc(SZ_4K, GFP_NOWAIT);
>
> if (buf && stack_depot_snprint(ct->fast_req[slot].stack, buf, SZ_4K, 0))
> xe_gt_err(gt, "Fence 0x%x was used by action %#04x sent at:\n%s\n",
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-12 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-17 14:26 [PATCH] drm/xe/guc: Fix invalid kfree() call via __cleanup on pointer Wentao Liang
2026-08-12 14:07 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).