Commit
fd8662823caa114a63f07222d2aa448f6ac5e864
drm/xe/oa: Zero OA buffer at allocation
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>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Link: https://patch.msgid.link/20261006020314.2711762-1-krishnaiah.bommu@intel.com
Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
(cherry picked from commit 126c4c5388f9311a390b9b254a835b0cf0f55331)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Bommu Krishnaiah <krishnaiah.bommu@intel.com> · 2026-10-06 02:03 UTC · committed by Rodrigo Vivi
1 file changed,
+7
−0
modified 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) | |||
| 914 | 914 | if (IS_ERR(bo)) | |
| 915 | 915 | return PTR_ERR(bo); | |
| 916 | 916 | ||
| 917 | + | /* | |
| 918 | + | * ttm_bo_type_kernel BOs are not zeroed on allocation, so the buffer can | |
| 919 | + | * hold stale data from previously freed pages. Since the OA buffer is | |
| 920 | + | * mmap'able by userspace, clear it here to avoid leaking kernel memory. | |
| 921 | + | */ | |
| 922 | + | xe_map_memset(stream->oa->xe, &bo->vmap, 0, 0, xe_bo_size(bo)); | |
| 923 | + | ||
| 917 | 924 | stream->oa_buffer.bo = bo; | |
| 918 | 925 | ||
| 919 | 926 | stream->oa_buffer.bounce = kmalloc(stream->oa_buffer.format->size, GFP_KERNEL); | |