mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Wentao Liang <vulab@iscas.ac.cn>,
	matthew.brost@intel.com, thomas.hellstrom@linux.intel.com,
	rodrigo.vivi@intel.com, airlied@gmail.com, simona@ffwll.ch
Cc: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Ella Ma <alansnape3058@gmail.com>
Subject: Re: [PATCH] drm/xe/guc: Fix invalid kfree() call via __cleanup on pointer
Date: Wed, 12 Aug 2026 16:07:14 +0200	[thread overview]
Message-ID: <ffebbb7b-a4f9-488e-8834-199da3073b96@redhat.com> (raw)
In-Reply-To: <20260617142632.3298984-1-vulab@iscas.ac.cn>

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>


      reply	other threads:[~2026-08-12 14:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17 14:26 Wentao Liang
2026-08-12 14:07 ` Thomas Huth [this message]

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=ffebbb7b-a4f9-488e-8834-199da3073b96@redhat.com \
    --to=thuth@redhat.com \
    --cc=airlied@gmail.com \
    --cc=alansnape3058@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=vulab@iscas.ac.cn \
    /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®