Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Bommu Krishnaiah <krishnaiah.bommu@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Subject: Re: drm/xe/oa: Zero OA buffer at allocation
Date: Tue, 6 Oct 2026 11:08:18 +0530	[thread overview]
Message-ID: <b848ad69-0bb9-4b73-bb7f-5cd22a43feb3@intel.com> (raw)
In-Reply-To: <20261006020314.2711762-1-krishnaiah.bommu@intel.com>



On 06-10-2026 07:33, Bommu Krishnaiah wrote:
> ttm_bo_type_kernel BOs are not guaranteed to be zeroed on allocation and
> may contain data from previously freed pages. Since the OA buffer is
> mmap'able by userspace, this can expose stale kernel memory contents.
> 
> Streams opened with DRM_XE_OA_PROPERTY_OA_DISABLED allocate the OA
> buffer without calling xe_oa_init_oa_buffer(). Zero the buffer at
> allocation to prevent information disclosure through mmap.
> 
> The existing zeroing in xe_oa_init_oa_buffer() remains necessary for
> zero report-id/timestamp detection on enable/re-enable.
> 
> Fixes: 392bf22238ff ("drm/xe/oa/uapi: OA buffer mmap")
> Assisted-by: LLM
> Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> Cc: Ghimiray, Himal Prasad <himal.prasad.ghimiray@intel.com>
> Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>

Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>

> ---
>   drivers/gpu/drm/xe/xe_oa.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> index a3484e943c55..3bb8bbef4c37 100644
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
> @@ -914,6 +914,13 @@ static int xe_oa_alloc_oa_buffer(struct xe_oa_stream *stream, size_t size)
>   	if (IS_ERR(bo))
>   		return PTR_ERR(bo);
>   
> +	/*
> +	 * ttm_bo_type_kernel BOs are not zeroed on allocation, so the buffer can
> +	 * hold stale data from previously freed pages. Since the OA buffer is
> +	 * mmap'able by userspace, clear it here to avoid leaking kernel memory.
> +	 */
> +	xe_map_memset(stream->oa->xe, &bo->vmap, 0, 0, xe_bo_size(bo));
> +
>   	stream->oa_buffer.bo = bo;
>   
>   	stream->oa_buffer.bounce = kmalloc(stream->oa_buffer.format->size, GFP_KERNEL);


  parent reply	other threads:[~2026-10-06  5:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  2:03 drm/xe/oa: Zero OA buffer at allocation Bommu Krishnaiah
2026-10-06  1:59 ` ✓ CI.KUnit: success for drm/xe/oa: Zero OA buffer at allocation (rev2) Patchwork
2026-10-06  2:43 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-06  5:38 ` Ghimiray, Himal Prasad [this message]
2026-10-06 12:24 ` ✓ Xe.CI.FULL: " Patchwork
2026-10-07 16:48 ` drm/xe/oa: Zero OA buffer at allocation Umesh Nerlige Ramappa

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=b848ad69-0bb9-4b73-bb7f-5cd22a43feb3@intel.com \
    --to=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=krishnaiah.bommu@intel.com \
    --cc=umesh.nerlige.ramappa@intel.com \
    /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