From: jbmoore <jbmoore61@gmail.com>
To: alexander.deucher@amd.com, christian.koenig@amd.com
Cc: "John B. Moore" <jbmoore61@gmail.com>, stable@vger.kernel.org
Subject: [PATCH 3/4] drm/amdgpu/gfx9: replace BUG_ON with WARN_ON_ONCE for KIQ 64-bit fence flag
Date: Sun, 26 Apr 2026 16:52:52 -0500 [thread overview]
Message-ID: <20260426215256.50722-4-jbmoore@nooks.dev> (raw)
In-Reply-To: <20260426215256.50722-1-jbmoore@nooks.dev>
From: "John B. Moore" <jbmoore61@gmail.com>
gfx_v9_0_ring_emit_fence_kiq() contains a BUG_ON() that fires when
the AMDGPU_FENCE_FLAG_64BIT flag is passed. The KIQ (Kernel
Interface Queue) ring only allocates 32-bit writeback buffer
addresses for fence sequence numbers. A 64-bit fence write would
overflow the allocated writeback slot, potentially corrupting
adjacent kernel memory.
Replace BUG_ON() with WARN_ON_ONCE() and mask off the unsupported
flag. This prevents the kernel panic while still logging the
unexpected condition and falling back to a safe 32-bit fence write.
This is separated from the main gfx9 BUG_ON conversion patch
because it addresses a different security concern (potential buffer
overflow in kernel-managed writeback memory) rather than the address
alignment assertions in the ring emission paths.
Found by a custom amdgpu DRM ioctl fuzzer.
Fixes: b1023571479020e9 ("drm/amdgpu: implement GFX 9.0 support (v2)")
Signed-off-by: John B. Moore <jbmoore61@gmail.com>
Cc: stable@vger.kernel.org
---
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 47e81c33d..fb2a0f1af 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -5679,7 +5679,8 @@ static void gfx_v9_0_ring_emit_fence_kiq(struct amdgpu_ring *ring, u64 addr,
struct amdgpu_device *adev = ring->adev;
/* we only allocate 32bit for each seq wb address */
- BUG_ON(flags & AMDGPU_FENCE_FLAG_64BIT);
+ if (WARN_ON_ONCE(flags & AMDGPU_FENCE_FLAG_64BIT))
+ flags &= ~AMDGPU_FENCE_FLAG_64BIT;
/* write fence seq to the "addr" */
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
--
2.43.0
next prev parent reply other threads:[~2026-04-26 21:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260426215256.50722-1-jbmoore@nooks.dev>
2026-04-26 21:52 ` [PATCH 1/4] drm/amdgpu/sdma4: replace BUG_ON with WARN_ON_ONCE in fence emission jbmoore
2026-04-26 21:52 ` [PATCH 2/4] drm/amdgpu/gfx9: replace BUG_ON/BUG with WARN_ON_ONCE in ring emission jbmoore
2026-04-26 21:52 ` jbmoore [this message]
2026-04-26 21:52 ` [PATCH 4/4] drm/amdgpu/vcn: prevent silent fence drop on 64-bit flag mismatch jbmoore
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=20260426215256.50722-4-jbmoore@nooks.dev \
--to=jbmoore61@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=stable@vger.kernel.org \
/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