Skip to content

Commit 0b91ea4

Browse files
jbmoore61gregkh
authored andcommitted
drm/amdgpu/sdma4: replace BUG_ON with WARN_ON in fence emission
commit 78d2e62 upstream. sdma_v4_0_ring_emit_fence() contains two BUG_ON(addr & 0x3) assertions that verify fence writeback addresses are dword-aligned. These assertions can be reached from unprivileged userspace via crafted DRM_IOCTL_AMDGPU_CS submissions, causing a fatal kernel panic in a scheduler worker thread. Replace both BUG_ON() calls with WARN_ON() to log the condition without crashing the kernel. A misaligned fence address at this point indicates a driver bug, but crashing the kernel is never the correct response when the assertion is reachable from userspace. The CS IOCTL path is the correct place to filter invalid submissions; the ring emission callback is too late to do anything about it. Fixes: 2130f89 ("drm/amdgpu: add SDMA v4.0 implementation (v2)") Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: John B. Moore <jbmoore61@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit b90250b) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6fbd52d commit 0b91ea4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ static void sdma_v4_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
890890
/* write the fence */
891891
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_FENCE));
892892
/* zero in first two bits */
893-
BUG_ON(addr & 0x3);
893+
WARN_ON(addr & 0x3);
894894
amdgpu_ring_write(ring, lower_32_bits(addr));
895895
amdgpu_ring_write(ring, upper_32_bits(addr));
896896
amdgpu_ring_write(ring, lower_32_bits(seq));
@@ -900,7 +900,7 @@ static void sdma_v4_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
900900
addr += 4;
901901
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_FENCE));
902902
/* zero in first two bits */
903-
BUG_ON(addr & 0x3);
903+
WARN_ON(addr & 0x3);
904904
amdgpu_ring_write(ring, lower_32_bits(addr));
905905
amdgpu_ring_write(ring, upper_32_bits(addr));
906906
amdgpu_ring_write(ring, upper_32_bits(seq));

0 commit comments

Comments
 (0)