Skip to contentSkip to conversation

drm/amdgpu: guard atom_context in devcoredump VBIOS dump

PATCH Superseded Jesse.Zhang 3 participants 7 messages Mar 23 – Mar 24

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/amdgpu: guard atom_context in devcoredump VBIOS dump

During GPU reset coredump generation, amdgpu_devcoredump_fw_info() unconditionally dereferences adev->mode_info.atom_context to print VBIOS fields. On reset/teardown paths this pointer can be NULL, causing a kernel page fault from the deferred coredump workqueue.

Fix by checking ctx before printing VBIOS fields:

if ctx is valid, print full VBIOS information as before; otherwise print a fallback line:
vbios info : unavailable (atom_context is NULL).
This prevents NULL-dereference crashes while preserving coredump output.

Observed page fault log:

[  667.933329] RIP: 0010:amdgpu_devcoredump_format+0x780/0xc00 [amdgpu]
[  667.941517] amdgpu 0002:01:00.0: Dumping IP State
[  667.949660] Code: 8d 57 74 48 c7 c6 01 65 9f c2 48 8d 7d 98 e8 97 96 7a ff 49 8d 97 b4 00 00 00 48 c7 c6 18 65 9f c2 48 8d 7d 98 e8 80 96 7a ff <41> 8b 97 f4 00 00 00 48 c7 c6 2f 65 9f c2 48 8d 7d 98 e8 69 96 7a
[  667.949666] RSP: 0018:ffffc9002302bd50 EFLAGS: 00010246
[  667.949673] RAX: 0000000000000000 RBX: ffff888110600000 RCX: 0000000000000000
[  667.949676] RDX: 000000000000a9b5 RSI: 0000000000000405 RDI: 000000000000a999
[  667.949680] RBP: ffffc9002302be00 R08: ffffffffc09c3084 R09: ffffffffc09c3085
[  667.949684] R10: 0000000000000000 R11: 0000000000000004 R12: 00000000000048e0
[  667.993908] amdgpu 0002:01:00.0: Dumping IP State Completed
[  667.994229] R13: 0000000000000025 R14: 000000000000000c R15: 0000000000000000
[  667.994233] FS:  0000000000000000(0000) GS:ffff88c44c2c9000(0000) knlGS:0000000000000000
[  668.000076] amdgpu 0002:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.008025] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  668.008030] CR2: 00000000000000f4 CR3: 000000011195f001 CR4: 0000000000770ef0
[  668.008035] PKRU: 55555554
[  668.008040] Call Trace:
[  668.008045]  <TASK>
[  668.016010] amdgpu 0002:01:00.0: [drm] Check your /sys/class/drm/card16/device/devcoredump/data
[  668.023967]  ? srso_alias_return_thunk+0x5/0xfbef5
[  668.023988]  ? __pfx___drm_printfn_coredump+0x10/0x10 [drm]
[  668.031950] amdgpu 0003:01:00.0: Dumping IP State
[  668.038159]  ? __pfx___drm_puts_coredump+0x10/0x10 [drm]
[  668.083017] amdgpu 0003:01:00.0: Dumping IP State Completed
[  668.083824]  amdgpu_devcoredump_deferred_work+0x26/0xc0 [amdgpu]
[  668.086163] amdgpu 0003:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.095863]  process_scheduled_works+0xa6/0x420
[  668.095880]  worker_thread+0x12a/0x270
[  668.101223] amdgpu 0003:01:00.0: [drm] Check your /sys/class/drm/card24/device/devcoredump/data
[  668.107441]  kthread+0x10d/0x230
[  668.107451]  ? __pfx_worker_thread+0x10/0x10
[  668.107458]  ? __pfx_kthread+0x10/0x10
[  668.112709] amdgpu 0000:01:00.0: ring vcn_unified_1 timeout, signaled seq=9, emitted seq=10
[  668.118630]  ret_from_fork+0x17c/0x1f0
[  668.118640]  ? __pfx_kthread+0x10/0x10
[  668.118647]  ret_from_fork_asm+0x1a/0x30

v2: add check !adev->bios and chang the log (Lijo)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +10 -6
index bbb5afd67b49..29078c08f264 100644
@@ -192,12 +192,16 @@ static void amdgpu_devcoredump_fw_info(struct amdgpu_device *adev,
 	drm_printf(p, "VPE feature version: %u, fw version: 0x%08x\n",
 		   adev->vpe.feature_version, adev->vpe.fw_version);
 
-	drm_printf(p, "\nVBIOS Information\n");
-	drm_printf(p, "vbios name       : %s\n", ctx->name);
-	drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
-	drm_printf(p, "vbios version    : %d\n", ctx->version);
-	drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
-	drm_printf(p, "vbios date       : %s\n", ctx->date);
+	if (ctx) {
+		drm_printf(p, "\nVBIOS Information\n");
+		drm_printf(p, "vbios name       : %s\n", ctx->name);
+		drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
+		drm_printf(p, "vbios version    : %d\n", ctx->version);
+		drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
+		drm_printf(p, "vbios date       : %s\n", ctx->date);
+	} else if (adev->bios) {
+		drm_printf(p, "\nVBIOS Information: NA\n");
+	}
 }
 
 static ssize_t
Signature · 1 line
2.49.0
#1 lore raw
Quoted 68 lines · Jesse.Zhang

During GPU reset coredump generation, amdgpu_devcoredump_fw_info() unconditionally dereferences adev->mode_info.atom_context to print VBIOS fields. On reset/teardown paths this pointer can be NULL, causing a kernel page fault from the deferred coredump workqueue.

Fix by checking ctx before printing VBIOS fields:

if ctx is valid, print full VBIOS information as before; otherwise print a fallback line:
vbios info : unavailable (atom_context is NULL).
This prevents NULL-dereference crashes while preserving coredump output.

Observed page fault log:

[  667.933329] RIP: 0010:amdgpu_devcoredump_format+0x780/0xc00 [amdgpu]
[  667.941517] amdgpu 0002:01:00.0: Dumping IP State
[  667.949660] Code: 8d 57 74 48 c7 c6 01 65 9f c2 48 8d 7d 98 e8 97 96 7a ff 49 8d 97 b4 00 00 00 48 c7 c6 18 65 9f c2 48 8d 7d 98 e8 80 96 7a ff <41> 8b 97 f4 00 00 00 48 c7 c6 2f 65 9f c2 48 8d 7d 98 e8 69 96 7a
[  667.949666] RSP: 0018:ffffc9002302bd50 EFLAGS: 00010246
[  667.949673] RAX: 0000000000000000 RBX: ffff888110600000 RCX: 0000000000000000
[  667.949676] RDX: 000000000000a9b5 RSI: 0000000000000405 RDI: 000000000000a999
[  667.949680] RBP: ffffc9002302be00 R08: ffffffffc09c3084 R09: ffffffffc09c3085
[  667.949684] R10: 0000000000000000 R11: 0000000000000004 R12: 00000000000048e0
[  667.993908] amdgpu 0002:01:00.0: Dumping IP State Completed
[  667.994229] R13: 0000000000000025 R14: 000000000000000c R15: 0000000000000000
[  667.994233] FS:  0000000000000000(0000) GS:ffff88c44c2c9000(0000) knlGS:0000000000000000
[  668.000076] amdgpu 0002:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.008025] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  668.008030] CR2: 00000000000000f4 CR3: 000000011195f001 CR4: 0000000000770ef0
[  668.008035] PKRU: 55555554
[  668.008040] Call Trace:
[  668.008045]  <TASK>
[  668.016010] amdgpu 0002:01:00.0: [drm] Check your /sys/class/drm/card16/device/devcoredump/data
[  668.023967]  ? srso_alias_return_thunk+0x5/0xfbef5
[  668.023988]  ? __pfx___drm_printfn_coredump+0x10/0x10 [drm]
[  668.031950] amdgpu 0003:01:00.0: Dumping IP State
[  668.038159]  ? __pfx___drm_puts_coredump+0x10/0x10 [drm]
[  668.083017] amdgpu 0003:01:00.0: Dumping IP State Completed
[  668.083824]  amdgpu_devcoredump_deferred_work+0x26/0xc0 [amdgpu]
[  668.086163] amdgpu 0003:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.095863]  process_scheduled_works+0xa6/0x420
[  668.095880]  worker_thread+0x12a/0x270
[  668.101223] amdgpu 0003:01:00.0: [drm] Check your /sys/class/drm/card24/device/devcoredump/data
[  668.107441]  kthread+0x10d/0x230
[  668.107451]  ? __pfx_worker_thread+0x10/0x10
[  668.107458]  ? __pfx_kthread+0x10/0x10
[  668.112709] amdgpu 0000:01:00.0: ring vcn_unified_1 timeout, signaled seq=9, emitted seq=10
[  668.118630]  ret_from_fork+0x17c/0x1f0
[  668.118640]  ? __pfx_kthread+0x10/0x10
[  668.118647]  ret_from_fork_asm+0x1a/0x30

v2: add check !adev->bios and chang the log (Lijo)

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16 ++++++++++------
  1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +0 -4
index bbb5afd67b49..29078c08f264 100644
@@ -192,12 +192,16 @@ static void amdgpu_devcoredump_fw_info(struct amdgpu_device *adev,
  	drm_printf(p, "VPE feature version: %u, fw version: 0x%08x\n",
  		   adev->vpe.feature_version, adev->vpe.fw_version);
 
-	drm_printf(p, "\nVBIOS Information\n");
-	drm_printf(p, "vbios name       : %s\n", ctx->name);
-	drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
-	drm_printf(p, "vbios version    : %d\n", ctx->version);

drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c static void amdgpu_devcoredump_fw_info(struct amdgpu_device *adev, · line 202

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +8 -2
-	drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
-	drm_printf(p, "vbios date       : %s\n", ctx->date);
+	if (ctx) {
+		drm_printf(p, "\nVBIOS Information\n");
+		drm_printf(p, "vbios name       : %s\n", ctx->name);
+		drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
+		drm_printf(p, "vbios version    : %d\n", ctx->version);
+		drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
+		drm_printf(p, "vbios date       : %s\n", ctx->date);
+	} else if (adev->bios) {

In that case, we only need

	if (adev->bios) {
		// print vbios info - ctxt expected to be present always in this case.
	} else {
	}

Thanks,
Lijo

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +2 -0
+		drm_printf(p, "\nVBIOS Information: NA\n");
+	}
  }
 
  static ssize_t
maintainer
#2 lore raw
In reply to Jesse.Zhang
Quoted 4 lines · Jesse.Zhang

During GPU reset coredump generation, amdgpu_devcoredump_fw_info() unconditionally dereferences adev->mode_info.atom_context to print VBIOS fields. On reset/teardown paths this pointer can be NULL, causing a kernel page fault from the deferred coredump workqueue.

I don't think that this is correct, just checking for NULL doesn't fix the issue.

We should rather make sure that we don't release the VBIOS information during teardown before the dump is completed.

Otherwise it can be that we manage to grab the pointer but free it a moment later and then try to print freed up memory here.

Regards,
Christian.

Quoted 79 lines

Fix by checking ctx before printing VBIOS fields:

if ctx is valid, print full VBIOS information as before; otherwise print a fallback line:
vbios info : unavailable (atom_context is NULL).
This prevents NULL-dereference crashes while preserving coredump output.

Observed page fault log:

[  667.933329] RIP: 0010:amdgpu_devcoredump_format+0x780/0xc00 [amdgpu]
[  667.941517] amdgpu 0002:01:00.0: Dumping IP State
[  667.949660] Code: 8d 57 74 48 c7 c6 01 65 9f c2 48 8d 7d 98 e8 97 96 7a ff 49 8d 97 b4 00 00 00 48 c7 c6 18 65 9f c2 48 8d 7d 98 e8 80 96 7a ff <41> 8b 97 f4 00 00 00 48 c7 c6 2f 65 9f c2 48 8d 7d 98 e8 69 96 7a
[  667.949666] RSP: 0018:ffffc9002302bd50 EFLAGS: 00010246
[  667.949673] RAX: 0000000000000000 RBX: ffff888110600000 RCX: 0000000000000000
[  667.949676] RDX: 000000000000a9b5 RSI: 0000000000000405 RDI: 000000000000a999
[  667.949680] RBP: ffffc9002302be00 R08: ffffffffc09c3084 R09: ffffffffc09c3085
[  667.949684] R10: 0000000000000000 R11: 0000000000000004 R12: 00000000000048e0
[  667.993908] amdgpu 0002:01:00.0: Dumping IP State Completed
[  667.994229] R13: 0000000000000025 R14: 000000000000000c R15: 0000000000000000
[  667.994233] FS:  0000000000000000(0000) GS:ffff88c44c2c9000(0000) knlGS:0000000000000000
[  668.000076] amdgpu 0002:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.008025] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  668.008030] CR2: 00000000000000f4 CR3: 000000011195f001 CR4: 0000000000770ef0
[  668.008035] PKRU: 55555554
[  668.008040] Call Trace:
[  668.008045]  <TASK>
[  668.016010] amdgpu 0002:01:00.0: [drm] Check your /sys/class/drm/card16/device/devcoredump/data
[  668.023967]  ? srso_alias_return_thunk+0x5/0xfbef5
[  668.023988]  ? __pfx___drm_printfn_coredump+0x10/0x10 [drm]
[  668.031950] amdgpu 0003:01:00.0: Dumping IP State
[  668.038159]  ? __pfx___drm_puts_coredump+0x10/0x10 [drm]
[  668.083017] amdgpu 0003:01:00.0: Dumping IP State Completed
[  668.083824]  amdgpu_devcoredump_deferred_work+0x26/0xc0 [amdgpu]
[  668.086163] amdgpu 0003:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.095863]  process_scheduled_works+0xa6/0x420
[  668.095880]  worker_thread+0x12a/0x270
[  668.101223] amdgpu 0003:01:00.0: [drm] Check your /sys/class/drm/card24/device/devcoredump/data
[  668.107441]  kthread+0x10d/0x230
[  668.107451]  ? __pfx_worker_thread+0x10/0x10
[  668.107458]  ? __pfx_kthread+0x10/0x10
[  668.112709] amdgpu 0000:01:00.0: ring vcn_unified_1 timeout, signaled seq=9, emitted seq=10
[  668.118630]  ret_from_fork+0x17c/0x1f0
[  668.118640]  ? __pfx_kthread+0x10/0x10
[  668.118647]  ret_from_fork_asm+0x1a/0x30

v2: add check !adev->bios and chang the log (Lijo)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +10 -6
index bbb5afd67b49..29078c08f264 100644
@@ -192,12 +192,16 @@ static void amdgpu_devcoredump_fw_info(struct amdgpu_device *adev,
 	drm_printf(p, "VPE feature version: %u, fw version: 0x%08x\n",
 		   adev->vpe.feature_version, adev->vpe.fw_version);
 
-	drm_printf(p, "\nVBIOS Information\n");
-	drm_printf(p, "vbios name       : %s\n", ctx->name);
-	drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
-	drm_printf(p, "vbios version    : %d\n", ctx->version);
-	drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
-	drm_printf(p, "vbios date       : %s\n", ctx->date);
+	if (ctx) {
+		drm_printf(p, "\nVBIOS Information\n");
+		drm_printf(p, "vbios name       : %s\n", ctx->name);
+		drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
+		drm_printf(p, "vbios version    : %d\n", ctx->version);
+		drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
+		drm_printf(p, "vbios date       : %s\n", ctx->date);
+	} else if (adev->bios) {
+		drm_printf(p, "\nVBIOS Information: NA\n");
+	}
 }
 
 static ssize_t
#3 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 15 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Monday, March 23, 2026 5:57 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH v3] drm/amdgpu: guard atom_context in devcoredump VBIOS dump

Quoted 4 lines · Jesse.Zhang

During GPU reset coredump generation, amdgpu_devcoredump_fw_info() unconditionally dereferences adev->mode_info.atom_context to print VBIOS fields. On reset/teardown paths this pointer can be NULL, causing a kernel page fault from the deferred coredump workqueue.

Quoted 7 lines

I don't think that this is correct, just checking for NULL doesn't fix the issue.

We should rather make sure that we don't release the VBIOS information during teardown before the dump is completed.

Otherwise it can be that we manage to grab the pointer but free it a moment later and then try to print freed up memory here.

Thanks Christian, good point.

Agreed that a NULL check alone does not fully address the race and can still allow use-after-free if atom_context is released after we take the pointer.

I reworked the fix to snapshot VBIOS information when coredump is created (in amdgpu_coredump), and the deferred formatter now prints from the snapshot instead of dereferencing adev->mode_info.atom_context.

This keeps coredump output stable across teardown and avoids both NULL-deref and potential UAF in the VBIOS section.

I’ll send v4 with this change.

Regards,
Jesse

Quoted 89 lines

Regards,
Christian.

Quoted 10 lines

Fix by checking ctx before printing VBIOS fields:

if ctx is valid, print full VBIOS information as before; otherwise print a fallback line:
vbios info : unavailable (atom_context is NULL).
This prevents NULL-dereference crashes while preserving coredump output.

Observed page fault log:

[  667.933329] RIP: 0010:amdgpu_devcoredump_format+0x780/0xc00
Quoted 15 lines

[amdgpu] [ 667.941517] amdgpu 0002:01:00.0: Dumping IP State [ 667.949660] Code: 8d 57 74 48 c7 c6 01 65 9f c2 48 8d 7d 98 e8 97 96 7a ff 49 8d 97 b4 00 00 00 48 c7 c6 18 65 9f c2 48 8d 7d 98 e8 80 96 7a ff <41> 8b 97 f4 00 00 00 48 c7 c6 2f 65 9f c2 48 8d 7d 98 e8 69 96 7a [ 667.949666] RSP: 0018:ffffc9002302bd50 EFLAGS: 00010246 [ 667.949673] RAX: 0000000000000000 RBX: ffff888110600000 RCX:
0000000000000000 [ 667.949676] RDX: 000000000000a9b5 RSI:
0000000000000405 RDI: 000000000000a999 [ 667.949680] RBP:
ffffc9002302be00 R08: ffffffffc09c3084 R09: ffffffffc09c3085 [ 667.949684] R10: 0000000000000000 R11: 0000000000000004 R12:
00000000000048e0 [ 667.993908] amdgpu 0002:01:00.0: Dumping IP State Completed [ 667.994229] R13: 0000000000000025 R14: 000000000000000c
R15: 0000000000000000 [ 667.994233] FS: 0000000000000000(0000) GS:ffff88c44c2c9000(0000) knlGS:0000000000000000 [ 668.000076] amdgpu 0002:01:00.0: [drm] AMDGPU device coredump file has been created

[  668.008025] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  668.008030] CR2: 00000000000000f4 CR3: 000000011195f001 CR4:

0000000000770ef0 [ 668.008035] PKRU: 55555554 [ 668.008040] Call Trace:

drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c static void amdgpu_devcoredump_fw_info(struct

Quoted 35 lines
[  668.008045]  <TASK>
[  668.016010] amdgpu 0002:01:00.0: [drm] Check your
/sys/class/drm/card16/device/devcoredump/data
[  668.023967]  ? srso_alias_return_thunk+0x5/0xfbef5
[  668.023988]  ? __pfx___drm_printfn_coredump+0x10/0x10 [drm] [

668.031950] amdgpu 0003:01:00.0: Dumping IP State [ 668.038159] ? __pfx___drm_puts_coredump+0x10/0x10 [drm] [ 668.083017] amdgpu 0003:01:00.0: Dumping IP State Completed [ 668.083824] amdgpu_devcoredump_deferred_work+0x26/0xc0 [amdgpu] [ 668.086163] amdgpu 0003:01:00.0: [drm] AMDGPU device coredump file has been created [ 668.095863] process_scheduled_works+0xa6/0x420

[  668.095880]  worker_thread+0x12a/0x270 [  668.101223] amdgpu
0003:01:00.0: [drm] Check your
/sys/class/drm/card24/device/devcoredump/data
[  668.107441]  kthread+0x10d/0x230
[  668.107451]  ? __pfx_worker_thread+0x10/0x10 [  668.107458]  ?
__pfx_kthread+0x10/0x10 [  668.112709] amdgpu 0000:01:00.0: ring
vcn_unified_1 timeout, signaled seq=9, emitted seq=10 [  668.118630]
ret_from_fork+0x17c/0x1f0 [  668.118640]  ? __pfx_kthread+0x10/0x10 [
668.118647]  ret_from_fork_asm+0x1a/0x30

v2: add check !adev->bios and chang the log (Lijo)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16
++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +0 -0
index bbb5afd67b49..29078c08f264 100644
@@ -192,12 +192,16 @@ static void amdgpu_devcoredump_fw_info(struct

amdgpu_device *adev,

Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +10 -6
    drm_printf(p, "VPE feature version: %u, fw version: 0x%08x\n",
               adev->vpe.feature_version, adev->vpe.fw_version);
 
-   drm_printf(p, "\nVBIOS Information\n");
-   drm_printf(p, "vbios name       : %s\n", ctx->name);
-   drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
-   drm_printf(p, "vbios version    : %d\n", ctx->version);
-   drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
-   drm_printf(p, "vbios date       : %s\n", ctx->date);
+   if (ctx) {
+           drm_printf(p, "\nVBIOS Information\n");
+           drm_printf(p, "vbios name       : %s\n", ctx->name);
+           drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
+           drm_printf(p, "vbios version    : %d\n", ctx->version);
+           drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
+           drm_printf(p, "vbios date       : %s\n", ctx->date);
+   } else if (adev->bios) {
+           drm_printf(p, "\nVBIOS Information: NA\n");
+   }
 }
 
 static ssize_t
#4 lore raw
Quoted 25 lines · Jesse(Jie)

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 15 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Monday, March 23, 2026 5:57 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH v3] drm/amdgpu: guard atom_context in devcoredump VBIOS dump

Quoted 4 lines · Jesse.Zhang

During GPU reset coredump generation, amdgpu_devcoredump_fw_info() unconditionally dereferences adev->mode_info.atom_context to print VBIOS fields. On reset/teardown paths this pointer can be NULL, causing a kernel page fault from the deferred coredump workqueue.

Quoted 7 lines

I don't think that this is correct, just checking for NULL doesn't fix the issue.

We should rather make sure that we don't release the VBIOS information during teardown before the dump is completed.

Otherwise it can be that we manage to grab the pointer but free it a moment later and then try to print freed up memory here.

Quoted 8 lines

Thanks Christian, good point.

Agreed that a NULL check alone does not fully address the race and can still allow use-after-free if atom_context is released after we take the pointer.

I reworked the fix to snapshot VBIOS information when coredump is created (in amdgpu_coredump), and the deferred formatter now prints from the snapshot instead of dereferencing adev->mode_info.atom_context.

Snapshot shouldn't be taken. Atom context will be valid till sw fini - i.e., till driver unload. Need to first figure out if a coredump during unload is expected. Now, if at all a coredump is happening, then driver should wait for the coredump to finish and then proceed with sw fini

Thanks,
Lijo

Quoted 100 lines

This keeps coredump output stable across teardown and avoids both NULL-deref and potential UAF in the VBIOS section.

I’ll send v4 with this change.

Regards,
Jesse

Quoted 89 lines

Regards,
Christian.

Quoted 10 lines

Fix by checking ctx before printing VBIOS fields:

if ctx is valid, print full VBIOS information as before; otherwise print a fallback line:
vbios info : unavailable (atom_context is NULL).
This prevents NULL-dereference crashes while preserving coredump output.

Observed page fault log:

[  667.933329] RIP: 0010:amdgpu_devcoredump_format+0x780/0xc00
Quoted 15 lines

[amdgpu] [ 667.941517] amdgpu 0002:01:00.0: Dumping IP State [ 667.949660] Code: 8d 57 74 48 c7 c6 01 65 9f c2 48 8d 7d 98 e8 97 96 7a ff 49 8d 97 b4 00 00 00 48 c7 c6 18 65 9f c2 48 8d 7d 98 e8 80 96 7a ff <41> 8b 97 f4 00 00 00 48 c7 c6 2f 65 9f c2 48 8d 7d 98 e8 69 96 7a [ 667.949666] RSP: 0018:ffffc9002302bd50 EFLAGS: 00010246 [ 667.949673] RAX: 0000000000000000 RBX: ffff888110600000 RCX:
0000000000000000 [ 667.949676] RDX: 000000000000a9b5 RSI:
0000000000000405 RDI: 000000000000a999 [ 667.949680] RBP:
ffffc9002302be00 R08: ffffffffc09c3084 R09: ffffffffc09c3085 [ 667.949684] R10: 0000000000000000 R11: 0000000000000004 R12:
00000000000048e0 [ 667.993908] amdgpu 0002:01:00.0: Dumping IP State Completed [ 667.994229] R13: 0000000000000025 R14: 000000000000000c
R15: 0000000000000000 [ 667.994233] FS: 0000000000000000(0000) GS:ffff88c44c2c9000(0000) knlGS:0000000000000000 [ 668.000076] amdgpu 0002:01:00.0: [drm] AMDGPU device coredump file has been created

[  668.008025] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  668.008030] CR2: 00000000000000f4 CR3: 000000011195f001 CR4:

0000000000770ef0 [ 668.008035] PKRU: 55555554 [ 668.008040] Call Trace:

drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c static void amdgpu_devcoredump_fw_info(struct

Quoted 35 lines
[  668.008045]  <TASK>
[  668.016010] amdgpu 0002:01:00.0: [drm] Check your
/sys/class/drm/card16/device/devcoredump/data
[  668.023967]  ? srso_alias_return_thunk+0x5/0xfbef5
[  668.023988]  ? __pfx___drm_printfn_coredump+0x10/0x10 [drm] [

668.031950] amdgpu 0003:01:00.0: Dumping IP State [ 668.038159] ? __pfx___drm_puts_coredump+0x10/0x10 [drm] [ 668.083017] amdgpu 0003:01:00.0: Dumping IP State Completed [ 668.083824] amdgpu_devcoredump_deferred_work+0x26/0xc0 [amdgpu] [ 668.086163] amdgpu 0003:01:00.0: [drm] AMDGPU device coredump file has been created [ 668.095863] process_scheduled_works+0xa6/0x420

[  668.095880]  worker_thread+0x12a/0x270 [  668.101223] amdgpu
0003:01:00.0: [drm] Check your
/sys/class/drm/card24/device/devcoredump/data
[  668.107441]  kthread+0x10d/0x230
[  668.107451]  ? __pfx_worker_thread+0x10/0x10 [  668.107458]  ?
__pfx_kthread+0x10/0x10 [  668.112709] amdgpu 0000:01:00.0: ring
vcn_unified_1 timeout, signaled seq=9, emitted seq=10 [  668.118630]
ret_from_fork+0x17c/0x1f0 [  668.118640]  ? __pfx_kthread+0x10/0x10 [
668.118647]  ret_from_fork_asm+0x1a/0x30

v2: add check !adev->bios and chang the log (Lijo)

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16
++++++++++------
  1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +0 -0
index bbb5afd67b49..29078c08f264 100644
@@ -192,12 +192,16 @@ static void amdgpu_devcoredump_fw_info(struct

amdgpu_device *adev,

Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +10 -6
     drm_printf(p, "VPE feature version: %u, fw version: 0x%08x\n",
                adev->vpe.feature_version, adev->vpe.fw_version);
 
-   drm_printf(p, "\nVBIOS Information\n");
-   drm_printf(p, "vbios name       : %s\n", ctx->name);
-   drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
-   drm_printf(p, "vbios version    : %d\n", ctx->version);
-   drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
-   drm_printf(p, "vbios date       : %s\n", ctx->date);
+   if (ctx) {
+           drm_printf(p, "\nVBIOS Information\n");
+           drm_printf(p, "vbios name       : %s\n", ctx->name);
+           drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
+           drm_printf(p, "vbios version    : %d\n", ctx->version);
+           drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
+           drm_printf(p, "vbios date       : %s\n", ctx->date);
+   } else if (adev->bios) {
+           drm_printf(p, "\nVBIOS Information: NA\n");
+   }
  }
 
  static ssize_t
#5 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 43 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 23, 2026 6:40 PM
To: Zhang, Jesse(Jie) <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH v3] drm/amdgpu: guard atom_context in devcoredump VBIOS dump

Quoted 31 lines · Jesse(Jie)

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 16 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Monday, March 23, 2026 5:57 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH v3] drm/amdgpu: guard atom_context in devcoredump VBIOS dump

Quoted 4 lines · Jesse.Zhang

During GPU reset coredump generation, amdgpu_devcoredump_fw_info() unconditionally dereferences adev->mode_info.atom_context to print VBIOS fields. On reset/teardown paths this pointer can be NULL, causing a kernel page fault from the deferred coredump workqueue.

Quoted 7 lines

I don't think that this is correct, just checking for NULL doesn't fix the issue.

We should rather make sure that we don't release the VBIOS information during teardown before the dump is completed.

Otherwise it can be that we manage to grab the pointer but free it a moment later and then try to print freed up memory here.

Thanks Christian, good point.

Agreed that a NULL check alone does not fully address the race and can still allow use-after-free if atom_context is released after we take the pointer.

Quoted 8 lines
Quoted 3 lines

I reworked the fix to snapshot VBIOS information when coredump is created (in amdgpu_coredump), and the deferred formatter now prints from the snapshot instead of dereferencing adev->mode_info.atom_context.

Snapshot shouldn't be taken. Atom context will be valid till sw fini - i.e., till driver unload. Need to first figure out if a coredump during unload is expected. Now, if at all a coredump is happening, then driver should wait for the coredump to finish and then proceed with sw fini

Thanks Lijo, ACK.

I dropped the snapshot approach and reworked it as suggested:
- keep VBIOS section printing based on adev->bios (otherwise print VBIOS Information: NA);
- ensure teardown waits for deferred coredump formatting to complete before sw_fini by flushing coredump work in amdgpu_device_fini_sw().

This addresses the race concern without introducing VBIOS snapshot state.

Thanks,
Jesse

Quoted 106 lines

Thanks,
Lijo

Quoted 102 lines

This keeps coredump output stable across teardown and avoids both NULL-deref and potential UAF in the VBIOS section.

I’ll send v4 with this change.

Regards,
Jesse

Quoted 91 lines

Regards,
Christian.

Quoted 19 lines

Fix by checking ctx before printing VBIOS fields:

if ctx is valid, print full VBIOS information as before; otherwise print a fallback line:
vbios info : unavailable (atom_context is NULL).
This prevents NULL-dereference crashes while preserving coredump output.

Observed page fault log:

[  667.933329] RIP: 0010:amdgpu_devcoredump_format+0x780/0xc00

[amdgpu] [ 667.941517] amdgpu 0002:01:00.0: Dumping IP State [ 667.949660] Code: 8d 57 74 48 c7 c6 01 65 9f c2 48 8d 7d 98 e8 97 96 7a ff 49 8d 97 b4 00 00 00 48 c7 c6 18 65 9f c2 48 8d 7d 98 e8 80 96 7a ff <41> 8b 97 f4 00 00 00 48 c7 c6 2f 65 9f c2 48 8d 7d 98 e8 69 96 7a [ 667.949666] RSP: 0018:ffffc9002302bd50 EFLAGS: 00010246 [ 667.949673] RAX: 0000000000000000 RBX: ffff888110600000 RCX:
0000000000000000 [ 667.949676] RDX: 000000000000a9b5 RSI:
0000000000000405 RDI: 000000000000a999 [ 667.949680] RBP:
ffffc9002302be00 R08: ffffffffc09c3084 R09: ffffffffc09c3085 [

Quoted 8 lines

667.949684] R10: 0000000000000000 R11: 0000000000000004 R12:
00000000000048e0 [ 667.993908] amdgpu 0002:01:00.0: Dumping IP State Completed [ 667.994229] R13: 0000000000000025 R14:
000000000000000c
R15: 0000000000000000 [ 667.994233] FS: 0000000000000000(0000) GS:ffff88c44c2c9000(0000) knlGS:0000000000000000 [ 668.000076] amdgpu
0002:01:00.0: [drm] AMDGPU device coredump file has been created

[  668.008025] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [

668.008030] CR2: 00000000000000f4 CR3: 000000011195f001 CR4:
0000000000770ef0 [ 668.008035] PKRU: 55555554 [ 668.008040] Call Trace:

drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c static void amdgpu_devcoredump_fw_info(struct

Quoted 35 lines
[  668.008045]  <TASK>
[  668.016010] amdgpu 0002:01:00.0: [drm] Check your
/sys/class/drm/card16/device/devcoredump/data
[  668.023967]  ? srso_alias_return_thunk+0x5/0xfbef5
[  668.023988]  ? __pfx___drm_printfn_coredump+0x10/0x10 [drm] [

668.031950] amdgpu 0003:01:00.0: Dumping IP State [ 668.038159] ? __pfx___drm_puts_coredump+0x10/0x10 [drm] [ 668.083017] amdgpu 0003:01:00.0: Dumping IP State Completed [ 668.083824] amdgpu_devcoredump_deferred_work+0x26/0xc0 [amdgpu] [ 668.086163] amdgpu 0003:01:00.0: [drm] AMDGPU device coredump file has been created [ 668.095863] process_scheduled_works+0xa6/0x420

[  668.095880]  worker_thread+0x12a/0x270 [  668.101223] amdgpu
0003:01:00.0: [drm] Check your
/sys/class/drm/card24/device/devcoredump/data
[  668.107441]  kthread+0x10d/0x230
[  668.107451]  ? __pfx_worker_thread+0x10/0x10 [  668.107458]  ?
__pfx_kthread+0x10/0x10 [  668.112709] amdgpu 0000:01:00.0: ring
vcn_unified_1 timeout, signaled seq=9, emitted seq=10 [  668.118630]
ret_from_fork+0x17c/0x1f0 [  668.118640]  ? __pfx_kthread+0x10/0x10
[ 668.118647]  ret_from_fork_asm+0x1a/0x30

v2: add check !adev->bios and chang the log (Lijo)

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16
++++++++++------
  1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +0 -0
index bbb5afd67b49..29078c08f264 100644
@@ -192,12 +192,16 @@ static void amdgpu_devcoredump_fw_info(struct

amdgpu_device *adev,

Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +10 -6
     drm_printf(p, "VPE feature version: %u, fw version: 0x%08x\n",
                adev->vpe.feature_version, adev->vpe.fw_version);
 
-   drm_printf(p, "\nVBIOS Information\n");
-   drm_printf(p, "vbios name       : %s\n", ctx->name);
-   drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
-   drm_printf(p, "vbios version    : %d\n", ctx->version);
-   drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
-   drm_printf(p, "vbios date       : %s\n", ctx->date);
+   if (ctx) {
+           drm_printf(p, "\nVBIOS Information\n");
+           drm_printf(p, "vbios name       : %s\n", ctx->name);
+           drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
+           drm_printf(p, "vbios version    : %d\n", ctx->version);
+           drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
+           drm_printf(p, "vbios date       : %s\n", ctx->date);
+   } else if (adev->bios) {
+           drm_printf(p, "\nVBIOS Information: NA\n");
+   }
  }
 
  static ssize_t
#6 lore raw
In reply to Christian König
Quoted 9 lines · Christian König
Quoted 4 lines · Jesse.Zhang

During GPU reset coredump generation, amdgpu_devcoredump_fw_info() unconditionally dereferences adev->mode_info.atom_context to print VBIOS fields. On reset/teardown paths this pointer can be NULL, causing a kernel page fault from the deferred coredump workqueue.

I don't think that this is correct, just checking for NULL doesn't fix the issue.

We should rather make sure that we don't release the VBIOS information during teardown before the dump is completed.

Atom context will be released only during software fini. A core dump during that process doesn't look correct in the first place.

Thanks,
Lijo

Quoted 86 lines

Otherwise it can be that we manage to grab the pointer but free it a moment later and then try to print freed up memory here.

Regards,
Christian.

Quoted 79 lines

Fix by checking ctx before printing VBIOS fields:

if ctx is valid, print full VBIOS information as before; otherwise print a fallback line:
vbios info : unavailable (atom_context is NULL).
This prevents NULL-dereference crashes while preserving coredump output.

Observed page fault log:

[  667.933329] RIP: 0010:amdgpu_devcoredump_format+0x780/0xc00 [amdgpu]
[  667.941517] amdgpu 0002:01:00.0: Dumping IP State
[  667.949660] Code: 8d 57 74 48 c7 c6 01 65 9f c2 48 8d 7d 98 e8 97 96 7a ff 49 8d 97 b4 00 00 00 48 c7 c6 18 65 9f c2 48 8d 7d 98 e8 80 96 7a ff <41> 8b 97 f4 00 00 00 48 c7 c6 2f 65 9f c2 48 8d 7d 98 e8 69 96 7a
[  667.949666] RSP: 0018:ffffc9002302bd50 EFLAGS: 00010246
[  667.949673] RAX: 0000000000000000 RBX: ffff888110600000 RCX: 0000000000000000
[  667.949676] RDX: 000000000000a9b5 RSI: 0000000000000405 RDI: 000000000000a999
[  667.949680] RBP: ffffc9002302be00 R08: ffffffffc09c3084 R09: ffffffffc09c3085
[  667.949684] R10: 0000000000000000 R11: 0000000000000004 R12: 00000000000048e0
[  667.993908] amdgpu 0002:01:00.0: Dumping IP State Completed
[  667.994229] R13: 0000000000000025 R14: 000000000000000c R15: 0000000000000000
[  667.994233] FS:  0000000000000000(0000) GS:ffff88c44c2c9000(0000) knlGS:0000000000000000
[  668.000076] amdgpu 0002:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.008025] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  668.008030] CR2: 00000000000000f4 CR3: 000000011195f001 CR4: 0000000000770ef0
[  668.008035] PKRU: 55555554
[  668.008040] Call Trace:
[  668.008045]  <TASK>
[  668.016010] amdgpu 0002:01:00.0: [drm] Check your /sys/class/drm/card16/device/devcoredump/data
[  668.023967]  ? srso_alias_return_thunk+0x5/0xfbef5
[  668.023988]  ? __pfx___drm_printfn_coredump+0x10/0x10 [drm]
[  668.031950] amdgpu 0003:01:00.0: Dumping IP State
[  668.038159]  ? __pfx___drm_puts_coredump+0x10/0x10 [drm]
[  668.083017] amdgpu 0003:01:00.0: Dumping IP State Completed
[  668.083824]  amdgpu_devcoredump_deferred_work+0x26/0xc0 [amdgpu]
[  668.086163] amdgpu 0003:01:00.0: [drm] AMDGPU device coredump file has been created
[  668.095863]  process_scheduled_works+0xa6/0x420
[  668.095880]  worker_thread+0x12a/0x270
[  668.101223] amdgpu 0003:01:00.0: [drm] Check your /sys/class/drm/card24/device/devcoredump/data
[  668.107441]  kthread+0x10d/0x230
[  668.107451]  ? __pfx_worker_thread+0x10/0x10
[  668.107458]  ? __pfx_kthread+0x10/0x10
[  668.112709] amdgpu 0000:01:00.0: ring vcn_unified_1 timeout, signaled seq=9, emitted seq=10
[  668.118630]  ret_from_fork+0x17c/0x1f0
[  668.118640]  ? __pfx_kthread+0x10/0x10
[  668.118647]  ret_from_fork_asm+0x1a/0x30

v2: add check !adev->bios and chang the log (Lijo)

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16 ++++++++++------
  1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +10 -6
index bbb5afd67b49..29078c08f264 100644
@@ -192,12 +192,16 @@ static void amdgpu_devcoredump_fw_info(struct amdgpu_device *adev,
  	drm_printf(p, "VPE feature version: %u, fw version: 0x%08x\n",
  		   adev->vpe.feature_version, adev->vpe.fw_version);
 
-	drm_printf(p, "\nVBIOS Information\n");
-	drm_printf(p, "vbios name       : %s\n", ctx->name);
-	drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
-	drm_printf(p, "vbios version    : %d\n", ctx->version);
-	drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
-	drm_printf(p, "vbios date       : %s\n", ctx->date);
+	if (ctx) {
+		drm_printf(p, "\nVBIOS Information\n");
+		drm_printf(p, "vbios name       : %s\n", ctx->name);
+		drm_printf(p, "vbios pn         : %s\n", ctx->vbios_pn);
+		drm_printf(p, "vbios version    : %d\n", ctx->version);
+		drm_printf(p, "vbios ver_str    : %s\n", ctx->vbios_ver_str);
+		drm_printf(p, "vbios date       : %s\n", ctx->date);
+	} else if (adev->bios) {
+		drm_printf(p, "\nVBIOS Information: NA\n");
+	}
  }
 
  static ssize_t