From: sashiko-bot@kernel.org
To: "Matt Turner" <mattst88@gmail.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/amdgpu: fix IB content read in the devcoredump
Date: Wed, 02 Dec 2026 22:53:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-246699@kernel.org> (raw)
In-Reply-To: <20261202-amdgpu-devcoredump-fixes-v1-1-59f622a29769@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/amdgpu: unaligned VRAM IB read in
amdgpu_devcoredump_print_ibs()
--
commit 14b3e312c2b66e1a7d6ed65ad219c71a4c22a7ca
Author: Matt Turner <mattst88@gmail.com>
drm/amdgpu: fix IB content read in the devcoredump
This commit reworks IB content dumping in amdgpu_devcoredump_print_ibs() to
validate mappings and BO resources, account for mapping->offset, read VRAM
via amdgpu_device_vram_access(), and map non-VRAM pages into a local
ttm_bo_kmap_obj.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
> index 30a8b4c5591dd..0c6533b950f60 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
[ ... ]
> @@ -271,6 +281,7 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
> }
>
> for (int i = 0; i < coredump->num_ibs; i++) {
> + u64 size = (u64)coredump->ibs[i].ib_size_dw * 4;
> bool emit_content = false;
>
> ib_content = kvmalloc_array(coredump->ibs[i].ib_size_dw, 4,
> @@ -280,41 +291,55 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
>
> va_start = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK;
> mapping = amdgpu_vm_bo_lookup_mapping(vm, va_start);
> - if (!mapping)
> + abo = amdgpu_devcoredump_mapping_bo(mapping);
> + if (!abo || !abo->tbo.resource)
> goto output_ib_content;
>
> - abo = mapping->bo_va->base.bo;
> - offset = va_start - mapping->start * AMDGPU_GPU_PAGE_SIZE;
> + if (va_start + size >
> + (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE)
> + goto output_ib_content;
>
> - if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) {
> + offset = va_start - mapping->start * AMDGPU_GPU_PAGE_SIZE +
> + mapping->offset;
> +
> + if (abo->tbo.resource->mem_type == TTM_PL_VRAM) {
> struct amdgpu_res_cursor cursor;
>
> off = 0;
> -
> - if (abo->tbo.resource->mem_type != TTM_PL_VRAM)
> - goto output_ib_content;
> -
> - amdgpu_res_first(abo->tbo.resource, offset,
> - coredump->ibs[i].ib_size_dw * 4, &cursor);
> + amdgpu_res_first(abo->tbo.resource, offset, size,
> + &cursor);
> while (cursor.remaining) {
> - amdgpu_device_mm_access(adev, cursor.start,
> - &ib_content[off], cursor.size,
> - false);
> + amdgpu_device_vram_access(adev, cursor.start,
> + &ib_content[off],
> + cursor.size, false);
> off += cursor.size / 4;
> amdgpu_res_next(&cursor, cursor.size);
> }
> emit_content = true;
[Severity: Medium]
Can an unaligned IB address cause amdgpu_devcoredump_print_ibs() to print
uninitialized kernel memory from ib_content?
amdgpu_cs_p2_ib() copies userspace's chunk_ib->va_start into ib->gpu_addr
without checking 4-byte alignment. When va_start is not 4-byte aligned,
offset, cursor.start, and cursor.size are unaligned as well. For
CPU-invisible VRAM, amdgpu_device_vram_access() falls back to
amdgpu_device_mm_access(), which aborts without writing to the buffer:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:amdgpu_device_mm_access() {
if (!drm_dev_enter(adev_to_drm(adev), &idx))
return;
if (!IS_ALIGNED(pos, 4) || !IS_ALIGNED(size, 4)) {
dev_err(adev->dev, "unaligned pos/size (pos=0x%llx, size=0x%zx)\n",
pos, size);
drm_dev_exit(idx);
return;
}
Since ib_content is allocated without __GFP_ZERO and emit_content is set to
true unconditionally, the devcoredump formats uninitialized memory. Even in
CPU-visible VRAM, if an unaligned IB crosses a buddy block boundary,
cursor.size on the first block is not a multiple of 4, so off +=
cursor.size / 4 misaligns subsequent block reads and leaves the trailing
bytes of ib_content unwritten.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-amdgpu-devcoredump-fixes-v1-0-59f622a29769@gmail.com?part=1
next prev parent reply other threads:[~2026-12-02 22:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 22:34 [PATCH 0/3] drm/amdgpu: devcoredump and reset fixes Matt Turner
2026-12-02 22:34 ` [PATCH 1/3] drm/amdgpu: fix IB content read in the devcoredump Matt Turner
2026-12-02 22:53 ` sashiko-bot [this message]
2026-12-02 22:34 ` [PATCH 2/3] drm/amdgpu: clear stale JPEG and VCN1 IP dump pointers Matt Turner
2026-12-02 22:34 ` [PATCH 3/3] drm/amdgpu: don't unmap legacy queues through MES during reset Matt Turner
2026-12-02 22:48 ` sashiko-bot
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=sashiko-outbox-246699@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mattst88@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.