Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
Subsystems (2)
PATCH 1/1 Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
This reverts commit 0cdff8eb31c139dde4716e4aa37198c16364629e.
The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting wait num_fences failed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting wait num_fences failed
MESA: error: amdgpu: getting wait fences failed
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail 0x00000000, type 1, sh 1, priv 0, wave_id 0, simd_id 0, wgp_id 0 [ 122.668504] amdgpu 0000:0a:00.0: sq_intr: error, detail 0x00000000, type 1, sh 1, priv 0, wave_id 0, simd_id 0, wgp_id 0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your /sys/class/drm/card0/device/devcoredump/data [ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout, signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu 0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpu 0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu 0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HW reset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded! [ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, but recovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0: Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0: failed to unmap legacy queue
--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0 -29
@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data, args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles) -return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles =memdup_array_user (u64_to_user_ptr (args->syncobj_handles), num_syncobj_handles,sizeof (u32));
@@ -950,25 +940,6 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, wait_info->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - -if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info->syncobj_timeline_points)) -return -EINVAL ; - -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; - num_syncobj = wait_info->num_syncobj_handles; ptr =u64_to_user_ptr (wait_info->syncobj_handles); syncobj_handles =memdup_array_user (ptr, num_syncobj,sizeof (u32));
Signature · 1 line
2.34.1
Christian König
maintainerQuoted 77 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failedDmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail 0x00000000, type 1, sh 1, priv 0, wave_id 0, simd_id 0, wgp_id 0 [ 122.668504] amdgpu 0000:0a:00.0: sq_intr: error, detail 0x00000000, type 1, sh 1, priv 0, wave_id 0, simd_id 0, wgp_id 0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your /sys/class/drm/card0/device/devcoredump/data [ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout, signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu 0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpu 0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu 0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HW reset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded! [ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, but recovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0: Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0: failed to unmap legacy queueCc Jesse Zhang <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-19@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data, args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles) -return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles =memdup_array_user (u64_to_user_ptr (args->syncobj_handles), num_syncobj_handles,sizeof (u32));@@ -950,25 +940,6 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, wait_info->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - -if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info->syncobj_timeline_points)) -return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, · line 971
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-10- -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -
Mhm, in general such checks look valid to me.
My educated guess is that userspace sets num_fences = 0 to query if it needs to resize the pointer out_fences or not.
If you have time please double check which check fails here.
Apart from that Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0num_syncobj = wait_info->num_syncobj_handles; ptr =u64_to_user_ptr (wait_info->syncobj_handles); syncobj_handles =memdup_array_user (ptr, num_syncobj,sizeof (u32));
Quoted 91 lines · Christian König
Quoted 77 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failedDmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail 0x00000000, type 1, sh 1, priv 0, wave_id 0, simd_id 0, wgp_id 0 [ 122.668504] amdgpu 0000:0a:00.0: sq_intr: error, detail 0x00000000, type 1, sh 1, priv 0, wave_id 0, simd_id 0, wgp_id 0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your /sys/class/drm/card0/device/devcoredump/data [ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout, signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu 0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpu 0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu 0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HW reset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded! [ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, but recovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0: Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0: failed to unmap legacy queueCc Jesse Zhang <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-19@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data, args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles) -return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles =memdup_array_user (u64_to_user_ptr (args->syncobj_handles), num_syncobj_handles,sizeof (u32));@@ -950,25 +940,6 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, wait_info->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - -if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info->syncobj_timeline_points)) -return -EINVAL ;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, · line 971
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-10- -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -Mhm, in general such checks look valid to me.
Quoted 3 lines
My educated guess is that userspace sets
num_fences= 0 to query if it needs to resize the pointerout_fencesor not.If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 9 lines
Apart from that Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0num_syncobj = wait_info->num_syncobj_handles; ptr =u64_to_user_ptr (wait_info->syncobj_handles); syncobj_handles =memdup_array_user (ptr, num_syncobj,sizeof (u32));
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 10 lines
-----Original Message-----
From: Khatri, Sunil <[email protected]>
Sent: Wednesday, March 18, 2026 4:22 PM
To: Koenig, Christian <[email protected]>; Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
Quoted 15 lines
Quoted 14 lines · Christian König
Quoted 12 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
After I reverted this patch, the error still occurs when running glxgears. Does it work fine on your end if you don't apply this patch?
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
Thanks
Jesse
Quoted 109 lines
Quoted 13 lines
Quoted 13 lines
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail
0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 122.668504] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your/sys/class/drm/card0/device/devcoredump/data[ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout, signaledseq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process
Quoted 8 lines
Quoted 8 lines
Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu 0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpu 0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu 0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HW
reset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded!
Quoted 14 lines
Quoted 14 lines
[ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, but recovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0: Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond tomsg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0: failed to unmap legacy queue
Cc Jesse Zhang <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_signal_ioctl(struct drm_device
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct drm_device*dev, void *data,
Quoted 17 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-2args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles = memdup_array_user(u64_to_user_ptr(args-
syncobj_handles),Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0num_syncobj_handles, sizeof(u32)); @@ -950,25 +940,6 @@
Quoted 2 lines
Quoted 2 lines
int amdgpu_userq_wait_ioctl(struct
drm_device*dev, void *data,wait_info->num_bo_read_handles >
AMDGPU_USERQ_MAX_HANDLES)Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - - if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info-
syncobj_timeline_points))drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, · line 971
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-11-return -EINVAL ; - -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -Mhm, in general such checks look valid to me.
Quoted 1 line
My educated guess is that userspace sets
num_fences= 0 to query if it needs toresize the pointer
out_fencesor not.Quoted 2 lines
If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 10 lines
Apart from that Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.Quoted 4 lines
num_syncobj = wait_info->num_syncobj_handles; ptr = u64_to_user_ptr(wait_info->syncobj_handles); syncobj_handles = memdup_array_user(ptr, num_syncobj,sizeof(u32));
Quoted 26 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 10 lines
-----Original Message-----
From: Khatri, Sunil <[email protected]>
Sent: Wednesday, March 18, 2026 4:22 PM
To: Koenig, Christian <[email protected]>; Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"Quoted 14 lines
Quoted 13 lines · Christian König
Quoted 12 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
Quoted 6 lines
After I reverted this patch, the error still occurs when running glxgears. Does it work fine on your end if you don't apply this patch?
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
Yes, it works. You might need to update mesa too. I am using the latest mesa with ubuntu and i dont see those error. with your patch they do show.
Regards
Sunil Khatri
Quoted 110 lines
Thanks
JesseQuoted 105 lines
Quoted 12 lines
Quoted 12 lines
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail
0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 122.668504] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your/sys/class/drm/card0/device/devcoredump/data[ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout, signaledseq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process
Quoted 8 lines
Quoted 8 lines
Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu 0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpu 0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu 0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HW
reset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded!
Quoted 14 lines
Quoted 14 lines
[ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, but recovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0: Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond tomsg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0: failed to unmap legacy queue
Cc Jesse Zhang <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_signal_ioctl(struct drm_device
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct drm_device*dev, void *data,
Quoted 17 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-2args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)return -EINVAL ; -/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles = memdup_array_user(u64_to_user_ptr(args-
syncobj_handles),Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0num_syncobj_handles, sizeof(u32)); @@ -950,25 +940,6 @@
Quoted 2 lines
Quoted 2 lines
int amdgpu_userq_wait_ioctl(struct
drm_device*dev, void *data,wait_info->num_bo_read_handles >
AMDGPU_USERQ_MAX_HANDLES)Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - - if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info-
syncobj_timeline_points))drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, · line 971
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-11-return -EINVAL ; - -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -Mhm, in general such checks look valid to me.
Quoted 1 line
My educated guess is that userspace sets
num_fences= 0 to query if it needs toresize the pointer
out_fencesor not.Quoted 1 line
If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 9 lines
Apart from that Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.Quoted 4 lines
num_syncobj = wait_info->num_syncobj_handles; ptr = u64_to_user_ptr(wait_info->syncobj_handles); syncobj_handles = memdup_array_user(ptr, num_syncobj,sizeof(u32));
[Public]
Add @Mohan Marimuthu, Yogesh/@Olsak, Marek
It looks like the validation in several places doesn’t match how Mesa allocates these buffers. i.e when num_syncobj_handles is zero, syncobj_handles must not be required to be NULL, because Mesa leaves it uninitialized when allocating it on the stack. We should either implement a proper fix in Mesa for this case or drop the known broken validation check.
Regards,
Prike
Quoted 168 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Khatri, Sunil
Sent: Wednesday, March 18, 2026 5:39 PM
To: Zhang, Jesse(Jie) <[email protected]>; Khatri, Sunil <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"Quoted 28 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 12 lines
-----Original Message-----
From: Khatri, Sunil <[email protected]>
Sent: Wednesday, March 18, 2026 4:22 PM
To: Koenig, Christian <[email protected]>; Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"Quoted 14 lines
Quoted 13 lines · Christian König
Quoted 12 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failedQuoted 6 lines
After I reverted this patch, the error still occurs when running glxgears. Does it work fine on your end if you don't apply this patch?
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
amdgpu: getting wait fences failedYes, it works. You might need to update mesa too. I am using the latest mesa with ubuntu and i dont see those error. with your patch they do show.
Regards
Sunil KhatriQuoted 116 lines
Thanks
JesseQuoted 111 lines
Quoted 15 lines
Quoted 15 lines
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail
0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 122.668504] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your/sys/class/drm/card0/device/devcoredump/data[ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout,signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu
0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpuQuoted 8 lines
Quoted 8 lines
0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu
0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HWreset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded!
Quoted 14 lines
Quoted 14 lines
[ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, butrecovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0:
Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0:
failed to unmap legacy queueCc Jesse Zhang <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct
drm_device*dev, void *data,
Quoted 18 lines
Quoted 5 lines
args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-2-/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles = memdup_array_user(u64_to_user_ptr(args-
syncobj_handles),Quoted 2 lines
num_syncobj_handles,
sizeof(u32)); @@ -950,25 +940,6 @@
Quoted 2 lines
Quoted 2 lines
int amdgpu_userq_wait_ioctl(struct
drm_device*dev, void *data,wait_info->num_bo_read_handles >
AMDGPU_USERQ_MAX_HANDLES)Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - - if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info-
syncobj_timeline_points))drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, · line 971
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-11-return -EINVAL ; - -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -Mhm, in general such checks look valid to me.
Quoted 2 lines
My educated guess is that userspace sets
num_fences= 0 to query if it needs toresize the pointer
out_fencesor not.Quoted 1 line
If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 9 lines
Apart from that Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.Quoted 4 lines
num_syncobj = wait_info->num_syncobj_handles; ptr = u64_to_user_ptr(wait_info->syncobj_handles); syncobj_handles = memdup_array_user(ptr, num_syncobj,sizeof(u32));
[Public]
Hi Prike,
Regarding below check in the Kernel patch,
/* Reject non-NULL pointers paired with a zero count. */ if (!args->num_syncobj_handles && args->syncobj_handles)
return -EINVAL;
Mesa uses alloca for args->syncobj_handles, alloca(0) returns non NULL.
I think the check "Reject non-NULL pointers paired with a zero count" in Kernel can be skipped.
Thank you,
Yogesh
________________________________
From: Liang, Prike <[email protected]>
Sent: Thursday, March 19, 2026 8:03 AM
To: Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Khatri, Sunil <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Mohan Marimuthu, Yogesh <[email protected]>; Olsak, Marek <[email protected]>
Cc: [email protected] <[email protected]>
Subject: RE: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
[Public]
Add @Mohan Marimuthu, Yogesh/@Olsak, Marek
It looks like the validation in several places doesn’t match how Mesa allocates these buffers. i.e when num_syncobj_handles is zero, syncobj_handles must not be required to be NULL, because Mesa leaves it uninitialized when allocating it on the stack. We should either implement a proper fix in Mesa for this case or drop the known broken validation check.
Regards,
Prike
Quoted 168 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Khatri, Sunil
Sent: Wednesday, March 18, 2026 5:39 PM
To: Zhang, Jesse(Jie) <[email protected]>; Khatri, Sunil <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"Quoted 28 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 12 lines
-----Original Message-----
From: Khatri, Sunil <[email protected]>
Sent: Wednesday, March 18, 2026 4:22 PM
To: Koenig, Christian <[email protected]>; Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"Quoted 14 lines
Quoted 13 lines · Christian König
Quoted 12 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failedQuoted 6 lines
After I reverted this patch, the error still occurs when running glxgears. Does it work fine on your end if you don't apply this patch?
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
amdgpu: getting wait fences failedYes, it works. You might need to update mesa too. I am using the latest mesa with ubuntu and i dont see those error. with your patch they do show.
Regards
Sunil KhatriQuoted 116 lines
Thanks
JesseQuoted 111 lines
Quoted 15 lines
Quoted 15 lines
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail
0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 122.668504] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your/sys/class/drm/card0/device/devcoredump/data[ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout,signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu
0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpuQuoted 8 lines
Quoted 8 lines
0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu
0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HWreset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded!
Quoted 14 lines
Quoted 14 lines
[ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, butrecovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0:
Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0:
failed to unmap legacy queueCc Jesse Zhang <[email protected]>Signed-off-by Sunil Khatri <[email protected]>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct
drm_device*dev, void *data,
Quoted 18 lines
Quoted 5 lines
args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-2-/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles = memdup_array_user(u64_to_user_ptr(args-
syncobj_handles),Quoted 2 lines
num_syncobj_handles,
sizeof(u32)); @@ -950,25 +940,6 @@
Quoted 2 lines
Quoted 2 lines
int amdgpu_userq_wait_ioctl(struct
drm_device*dev, void *data,wait_info->num_bo_read_handles >
AMDGPU_USERQ_MAX_HANDLES)Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 10 lines
return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - - if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info-
syncobj_timeline_points))drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, · line 971
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-11-return -EINVAL ; - -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -Mhm, in general such checks look valid to me.
Quoted 2 lines
My educated guess is that userspace sets
num_fences= 0 to query if it needs toresize the pointer
out_fencesor not.Quoted 1 line
If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 9 lines
Apart from that Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.Quoted 4 lines
num_syncobj = wait_info->num_syncobj_handles; ptr = u64_to_user_ptr(wait_info->syncobj_handles); syncobj_handles = memdup_array_user(ptr, num_syncobj,sizeof(u32));
[Public]
Thanks for the confirmation. If Mesa doesn't zero the handle buffer, I'm going to drop this validation check in the kernel and then leave a debug message for this case.
Regards,
Prike
From: Mohan Marimuthu, Yogesh <[email protected]>
Sent: Thursday, March 19, 2026 1:31 PM
To: Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Khatri, Sunil <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
[Public]
Hi Prike,
Regarding below check in the Kernel patch,
/* Reject non-NULL pointers paired with a zero count. */ if (!args->num_syncobj_handles && args->syncobj_handles)
return -EINVAL;
Mesa uses alloca for args->syncobj_handles, alloca(0) returns non NULL.
I think the check "Reject non-NULL pointers paired with a zero count" in Kernel can be skipped.
Thank you,
Yogesh
________________________________
From: Liang, Prike <[email protected]<mailto:[email protected]>>
Sent: Thursday, March 19, 2026 8:03 AM
To: Khatri, Sunil <[email protected]<mailto:[email protected]>>; Zhang, Jesse(Jie) <[email protected]<mailto:[email protected]>>; Khatri, Sunil <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>; Mohan Marimuthu, Yogesh <[email protected]<mailto:[email protected]>>; Olsak, Marek <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
[Public]
Add @Mohan Marimuthu, Yogesh/@Olsak, Marek
It looks like the validation in several places doesn't match how Mesa allocates these buffers. i.e when num_syncobj_handles is zero, syncobj_handles must not be required to be NULL, because Mesa leaves it uninitialized when allocating it on the stack. We should either implement a proper fix in Mesa for this case or drop the known broken validation check.
Regards,
Prike
Quoted 168 lines
-----Original Message-----
From: amd-gfx <[email protected]<mailto:[email protected]>> On Behalf Of Khatri, Sunil
Sent: Wednesday, March 18, 2026 5:39 PM
To: Zhang, Jesse(Jie) <[email protected]<mailto:[email protected]>>; Khatri, Sunil <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument
validation"Quoted 28 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 12 lines
-----Original Message-----
From: Khatri, Sunil <[email protected]<mailto:[email protected]>>
Sent: Wednesday, March 18, 2026 4:22 PM
To: Koenig, Christian <[email protected]<mailto:[email protected]>>; Khatri, Sunil <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; Zhang, Jesse(Jie) <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl
argument validation"Quoted 14 lines
Quoted 13 lines · Christian König
Quoted 12 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failedQuoted 6 lines
After I reverted this patch, the error still occurs when running glxgears. Does it work fine on your end if you don't apply this patch?
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
amdgpu: getting wait fences failedYes, it works. You might need to update mesa too. I am using the latest mesa with ubuntu and i dont see those error. with your patch they do show.
Regards
Sunil KhatriQuoted 116 lines
Thanks
JesseQuoted 111 lines
Quoted 15 lines
Quoted 15 lines
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail
0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 122.668504] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your/sys/class/drm/card0/device/devcoredump/data[ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout,signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu
0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpuQuoted 8 lines
Quoted 8 lines
0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu
0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HWreset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded!
Quoted 14 lines
Quoted 14 lines
[ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, butrecovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0:
Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0:
failed to unmap legacy queueCc Jesse Zhang <[email protected]<mailto:[email protected]>>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct
drm_device*dev, void *data,
Quoted 18 lines
Quoted 5 lines
args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-2-/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles = memdup_array_user(u64_to_user_ptr(args-
syncobj_handles),Quoted 2 lines
num_syncobj_handles,
sizeof(u32)); @@ -950,25 +940,6 @@
Quoted 2 lines
Quoted 2 lines
int amdgpu_userq_wait_ioctl(struct
drm_device*dev, void *data,wait_info->num_bo_read_handles >
AMDGPU_USERQ_MAX_HANDLES)Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
Quoted 10 lines
return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - - if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info-
syncobj_timeline_points))drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-11-return -EINVAL ; - -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -Mhm, in general such checks look valid to me.
Quoted 2 lines
My educated guess is that userspace sets
num_fences= 0 to query if it needs toresize the pointer
out_fencesor not.Quoted 1 line
If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 9 lines
Apart from that Reviewed-by: Christian König <[email protected]<mailto:[email protected]>>.
Regards,
Christian.Quoted 4 lines
num_syncobj = wait_info->num_syncobj_handles; ptr = u64_to_user_ptr(wait_info->syncobj_handles); syncobj_handles = memdup_array_user(ptr, num_syncobj,sizeof(u32));
Christian König
maintainerHi guys,
well when mesa leaves some fields in the structure uninitialized then that is a pretty bad idea and we should eventually fix that.
But always setting the pointers to valid arrays and just setting the number of array elements to zero is perfectly valid.
That doesn't even needs a debug message.
Regards,
Christian.
Quoted 247 lines · Prike
[Public]
Thanks for the confirmation. If Mesa doesn’t zero the handle buffer, I’m going to drop this validation check in the kernel and then leave a debug message for this case.
Regards,
Prike
*From:*Mohan Marimuthu, Yogesh <[email protected]>
*Sent:* Thursday, March 19, 2026 1:31 PM
*To:* Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Khatri, Sunil <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]> *Cc:* [email protected]
*Subject:* Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"[Public]
Hi Prike,
Regarding below check in the Kernel patch,
/* Reject non-NULL pointers paired with a zero count. */
if (!args->num_syncobj_handles &&
args->syncobj_handles)return
-EINVAL;Mesa uses alloca for
args->syncobj_handles, alloca(0) returns non NULL.I think the check "Reject non-NULL pointers paired with a zero count" in Kernel can be skipped.
Thank you,
Yogesh
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*From:* Liang, Prike <[email protected] <mailto:[email protected]>>
*Sent:* Thursday, March 19, 2026 8:03 AM
*To:* Khatri, Sunil <[email protected] <mailto:[email protected]>>; Zhang, Jesse(Jie) <[email protected] <mailto:[email protected]>>; Khatri, Sunil <[email protected] <mailto:[email protected]>>; Koenig, Christian <[email protected] <mailto:[email protected]>>; Deucher, Alexander <[email protected] <mailto:[email protected]>>; Mohan Marimuthu, Yogesh <[email protected] <mailto:[email protected]>>; Olsak, Marek <[email protected] <mailto:[email protected]>> *Cc:* [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>>
*Subject:* RE: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"[Public]
Add @Mohan Marimuthu, Yogesh/@Olsak, Marek
It looks like the validation in several places doesn’t match how Mesa allocates these buffers. i.e when
num_syncobj_handlesis zero,syncobj_handlesmust not be required to be NULL, because Mesa leaves it uninitialized when allocating it on the stack. We should either implement a proper fix in Mesa for this case or drop the known broken validation check.Regards,
PrikeQuoted 168 lines
-----Original Message-----
From: amd-gfx <[email protected] <mailto:[email protected]>> On Behalf Of Khatri, Sunil
Sent: Wednesday, March 18, 2026 5:39 PM
To: Zhang, Jesse(Jie) <[email protected] <mailto:[email protected]>>; Khatri, Sunil
<[email protected] <mailto:[email protected]>>; Koenig, Christian <[email protected] <mailto:[email protected]>>; Deucher, Alexander <[email protected] <mailto:[email protected]>>
Cc: [email protected] <mailto:[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument
validation"Quoted 28 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 12 lines
-----Original Message-----
From: Khatri, Sunil <[email protected] <mailto:[email protected]>>
Sent: Wednesday, March 18, 2026 4:22 PM
To: Koenig, Christian <[email protected] <mailto:[email protected]>>; Khatri, Sunil <[email protected] <mailto:[email protected]>>; Deucher, Alexander <[email protected] <mailto:[email protected]>>
Cc: [email protected] <mailto:[email protected]>; Zhang, Jesse(Jie) <[email protected] <mailto:[email protected]>>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl
argument validation"Quoted 14 lines
Quoted 13 lines · Christian König
Quoted 12 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failedQuoted 6 lines
After I reverted this patch, the error still occurs when running glxgears. Does it work fine on your end if you don't apply this patch?
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
amdgpu: getting wait fences failedYes, it works. You might need to update mesa too. I am using the latest mesa with ubuntu and i dont see those error. with your patch they do show.
Regards
Sunil KhatriQuoted 116 lines
Thanks
JesseQuoted 111 lines
Quoted 15 lines
Quoted 15 lines
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 122.668504] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your/sys/class/drm/card0/device/devcoredump/data
[ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout, signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu
0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpuQuoted 8 lines
Quoted 8 lines
0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu
0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HWreset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded!
Quoted 14 lines
Quoted 14 lines
[ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, but recovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0:
Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0:
failed to unmap legacy queueCc Jesse Zhang <[email protected] <mailto:[email protected]>>Signed-off-by Sunil Khatri <[email protected] <mailto:[email protected]>>---
.../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 -------------------1 file changed, 29 deletions(-)Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct
drm_device*dev, void *data,
Quoted 18 lines
Quoted 13 lines
args->num_bo_read_handles>AMDGPU_USERQ_MAX_HANDLES) return-EINVAL;- /* Reject non-NULL pointers paired with a zero count. */ - if (!args->num_syncobj_handles &&
args->syncobj_handles) - return-EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-7- - if (!args->num_bo_read_handles && args->bo_read_handles) - return -EINVAL; - - if (!args->num_bo_write_handles && args->bo_write_handles) - return -EINVAL; -Quoted 2 lines
num_syncobj_handles=args->num_syncobj_handles;syncobj_handles= memdup_array_user(u64_to_user_ptr(args-
syncobj_handles),Quoted 2 lines
num_syncobj_handles, sizeof(u32)); @@ -950,25 +940,6 @@
Quoted 2 lines
Quoted 2 lines
int amdgpu_userq_wait_ioctl(struct
drm_device*dev, void *data,wait_info->num_bo_read_handles>
AMDGPU_USERQ_MAX_HANDLES)Quoted 24 lines
Quoted 10 lines
return
-EINVAL;- /* Reject non-NULL pointers paired with a zero count: the pointer - * is meaningless and indicates inconsistent input from userspace. - */
- if (!wait_info->num_syncobj_handles &&wait_info->syncobj_handles) - return-EINVAL;
-
- if (!wait_info->num_syncobj_timeline_handles &&
- (wait_info->syncobj_timeline_handles|| wait_info-
syncobj_timeline_points))drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
Quoted 11 lines
- return
-EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-10- - if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) - return -EINVAL; - - if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) - return -EINVAL; - - if (!wait_info->num_fences && wait_info->out_fences) - return -EINVAL; -Mhm, in general such checks look valid to me.
Quoted 2 lines
My educated guess is that userspace sets
num_fences= 0 to query if it needs toresize the pointer
out_fencesor not.Quoted 1 line
If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 9 lines
Apart from that Reviewed-by: Christian König <[email protected] <mailto:[email protected]>>.
Regards,
Christian.Quoted 4 lines
num_syncobj=wait_info->num_syncobj_handles; ptr =u64_to_user_ptr(wait_info->syncobj_handles);syncobj_handles=memdup_array_user(ptr, num_syncobj, sizeof(u32));
[AMD Official Use Only - AMD Internal Distribution Only]
Hi,
alloca(0) will point to current top of stack and hence it can be said the field is initialized.
Thank you,
Yogesh
________________________________
From: Koenig, Christian <[email protected]>
Sent: Thursday, March 19, 2026 1:00 PM
To: Liang, Prike <[email protected]>; Mohan Marimuthu, Yogesh <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
Hi guys,
well when mesa leaves some fields in the structure uninitialized then that is a pretty bad idea and we should eventually fix that.
But always setting the pointers to valid arrays and just setting the number of array elements to zero is perfectly valid.
That doesn't even needs a debug message.
Regards,
Christian.
Quoted 247 lines · Prike
[Public]
Thanks for the confirmation. If Mesa doesn’t zero the handle buffer, I’m going to drop this validation check in the kernel and then leave a debug message for this case.
Regards,
Prike
*From:*Mohan Marimuthu, Yogesh <[email protected]>
*Sent:* Thursday, March 19, 2026 1:31 PM
*To:* Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Khatri, Sunil <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]> *Cc:* [email protected]
*Subject:* Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"[Public]
Hi Prike,
Regarding below check in the Kernel patch,
/* Reject non-NULL pointers paired with a zero count. */
if (!args->num_syncobj_handles &&
args->syncobj_handles)return -EINVAL;Mesa uses alloca for
args->syncobj_handles, alloca(0) returns non NULL.I think the check "Reject non-NULL pointers paired with a zero count" in Kernel can be skipped.
Thank you,
Yogesh
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*From:* Liang, Prike <[email protected] <mailto:[email protected]>>
*Sent:* Thursday, March 19, 2026 8:03 AM
*To:* Khatri, Sunil <[email protected] <mailto:[email protected]>>; Zhang, Jesse(Jie) <[email protected] <mailto:[email protected]>>; Khatri, Sunil <[email protected] <mailto:[email protected]>>; Koenig, Christian <[email protected] <mailto:[email protected]>>; Deucher, Alexander <[email protected] <mailto:[email protected]>>; Mohan Marimuthu, Yogesh <[email protected] <mailto:[email protected]>>; Olsak, Marek <[email protected] <mailto:[email protected]>> *Cc:* [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>>
*Subject:* RE: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"[Public]
Add @Mohan Marimuthu, Yogesh/@Olsak, Marek
It looks like the validation in several places doesn’t match how Mesa allocates these buffers. i.e when
num_syncobj_handlesis zero,syncobj_handlesmust not be required to be NULL, because Mesa leaves it uninitialized when allocating it on the stack. We should either implement a proper fix in Mesa for this case or drop the known broken validation check.Regards,
PrikeQuoted 168 lines
-----Original Message-----
From: amd-gfx <[email protected] <mailto:[email protected]>> On Behalf Of Khatri, Sunil
Sent: Wednesday, March 18, 2026 5:39 PM
To: Zhang, Jesse(Jie) <[email protected] <mailto:[email protected]>>; Khatri, Sunil
<[email protected] <mailto:[email protected]>>; Koenig, Christian <[email protected] <mailto:[email protected]>>; Deucher, Alexander <[email protected] <mailto:[email protected]>>
Cc: [email protected] <mailto:[email protected]>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument
validation"Quoted 28 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 12 lines
-----Original Message-----
From: Khatri, Sunil <[email protected] <mailto:[email protected]>>
Sent: Wednesday, March 18, 2026 4:22 PM
To: Koenig, Christian <[email protected] <mailto:[email protected]>>; Khatri, Sunil <[email protected] <mailto:[email protected]>>; Deucher, Alexander <[email protected] <mailto:[email protected]>>
Cc: [email protected] <mailto:[email protected]>; Zhang, Jesse(Jie) <[email protected] <mailto:[email protected]>>
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl
argument validation"Quoted 14 lines
Quoted 13 lines · Christian König
Quoted 12 lines · Sunil Khatri
This reverts commit
0cdff8eb31c139dde4716e4aa37198c16364629e.The patch has caused regression for userqueues where user is stuck and is waiting for fences and a gpu reset is triggered in kernel. Also for any of the parameters when count is zero, the driver does not read from the pointer and having that check is overkill.
Application:
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failed
MESA: error: amdgpu: getting waitnum_fencesfailed
MESA: error: amdgpu: getting wait fences failedQuoted 6 lines
After I reverted this patch, the error still occurs when running glxgears. Does it work fine on your end if you don't apply this patch?
amdgpu: getting wait fences failed
amdgpu: getting wait fences failed
amdgpu: getting wait fences failedYes, it works. You might need to update mesa too. I am using the latest mesa with ubuntu and i dont see those error. with your patch they do show.
Regards
Sunil KhatriQuoted 116 lines
Thanks
JesseQuoted 111 lines
Quoted 15 lines
Quoted 15 lines
Dmesg:
[ 122.668493] amdgpu 0000:0a:00.0: sq_intr: error, detail
0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 122.668504] amdgpu 0000:0a:00.0:sq_intr: error, detail0x00000000, type 1, sh 1, priv 0,wave_id0,simd_id0,wgp_id0 [ 124.687518] amdgpu 0000:0a:00.0: Dumping IP State [ 124.688351] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 124.688355] amdgpu 0000:0a:00.0: [drm] AMDGPU device coredump file has been created [ 124.688357] amdgpu 0000:0a:00.0: [drm] Check your/sys/class/drm/card0/device/devcoredump/data[ 124.688361] amdgpu 0000:0a:00.0: ring gfx_0.0.0 timeout,signaled seq=569, emitted seq=571 [ 124.688366] amdgpu 0000:0a:00.0: Process Xwayland pid 3471 thread Xwayland:cs0 pid 3479 [ 124.688369] amdgpu
0000:0a:00.0: Starting gfx_0.0.0 ring reset [ 126.560451] amdgpuQuoted 8 lines
Quoted 8 lines
0000:0a:00.0: MES(0) failed to respond to msg=RESET [ 126.560456] amdgpu 0000:0a:00.0: failed to detect and reset [ 126.560460] amdgpu
0000:0a:00.0: Failed to detect and reset queues, err (-110) [ 128.789840] amdgpu 0000:0a:00.0: Ring gfx_0.0.0 reset failed [ 128.789848] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 1 [ 128.790161] amdgpu 0000:0a:00.0: Guilty job already signaled, skipping HWreset [ 128.790174] amdgpu 0000:0a:00.0: GPU reset(1) succeeded!
Quoted 14 lines
Quoted 14 lines
[ 128.804538] amdgpu 0000:0a:00.0: [drm] device wedged, butrecovered through reset [ 128.804574] amdgpu 0000:0a:00.0: GPU reset begin!. Source: 6 [ 128.816663] amdgpu 0000:0a:00.0:
Dumping IP State [ 128.817458] amdgpu 0000:0a:00.0: Dumping IP State Completed [ 130.963939] amdgpu 0000:0a:00.0: MES(1) failed to respond to msg=REMOVE_QUEUE [ 130.963949] amdgpu 0000:0a:00.0:
failed to unmap legacy queueCc Jesse Zhang <[email protected] <mailto:[email protected]>>Signed-off-by Sunil Khatri <[email protected] <mailto:[email protected]>>--- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 29 ------------------- 1 file changed, 29 deletions(-)Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -484,16 +484,6 @@ int amdgpu_userq_signal_ioctl(struct
drm_device*dev, void *data,
Quoted 18 lines
Quoted 5 lines
args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-2-/* Reject non-NULL pointers paired with a zero count. */ -if (!args->num_syncobj_handles && args->syncobj_handles)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-return -EINVAL ; - -if (!args->num_bo_read_handles && args->bo_read_handles) -return -EINVAL ; - -if (!args->num_bo_write_handles && args->bo_write_handles) -return -EINVAL ; - num_syncobj_handles = args->num_syncobj_handles; syncobj_handles = memdup_array_user(u64_to_user_ptr(args-
syncobj_handles),Quoted 2 lines
num_syncobj_handles,
sizeof(u32)); @@ -950,25 +940,6 @@
Quoted 2 lines
Quoted 2 lines
int amdgpu_userq_wait_ioctl(struct
drm_device*dev, void *data,wait_info->num_bo_read_handles >
AMDGPU_USERQ_MAX_HANDLES)Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
Quoted 10 lines
return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-8-/* Reject non-NULL pointers paired with a zero count: the pointer -* is meaningless and indicates inconsistent input from userspace. -*/ -if (!wait_info->num_syncobj_handles && wait_info->syncobj_handles) -return -EINVAL ; - - if (!wait_info->num_syncobj_timeline_handles && - (wait_info->syncobj_timeline_handles || wait_info-
syncobj_timeline_points))drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-11-return -EINVAL ; - -if (!wait_info->num_bo_read_handles && wait_info->bo_read_handles) -return -EINVAL ; - -if (!wait_info->num_bo_write_handles && wait_info->bo_write_handles) -return -EINVAL ; - -if (!wait_info->num_fences && wait_info->out_fences) -return -EINVAL ; -Mhm, in general such checks look valid to me.
Quoted 2 lines
My educated guess is that userspace sets
num_fences= 0 to query if it needs toresize the pointer
out_fencesor not.Quoted 1 line
If you have time please double check which check fails here.
Sure, i will check on that but for now i have pushed this revert.
regards
sunil khatri
Quoted 9 lines
Apart from that Reviewed-by: Christian König <[email protected] <mailto:[email protected]>>.
Regards,
Christian.Quoted 4 lines
num_syncobj = wait_info->num_syncobj_handles; ptr = u64_to_user_ptr(wait_info->syncobj_handles); syncobj_handles = memdup_array_user(ptr, num_syncobj,sizeof(u32));
Quoted 7 lines · Christian König
Hi guys,
well when mesa leaves some fields in the structure uninitialized then that is a pretty bad idea and we should eventually fix that.
But always setting the pointers to valid arrays and just setting the number of array elements to zero is perfectly valid.
That doesn't even needs a debug message.
As discussed recently for another patch, the "(How to avoid) Botching up ioctls" page of the kernel documentation says under Basics:
* Check all unused fields and flags and all the padding for whether it’s 0, and reject the ioctl if that’s not the case.
That seems to apply here, i.e. the kernel should have these checks and Mesa should initialize the pointer field to 0 when the corresponding num_* field is.
P.S. I agree it probably doesn't make a practical difference in this specific case. I suspect the rule is aimed at when the ioctl struct is extended, in which case Mesa's current behaviour would be indistinguishable from user-space code which actually doesn't properly initialize the newly-added fields.
It seems safer to stick to the rule even in cases like this where it's not strictly required.
Signature · 2 lines
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer https://redhat.com \ Libre software enthusiast
[Public]
Yes, in this case it’s cleaner and more robust to not allocate at all when num == 0, and keep the pointer as NULL. For the mesa driver, how about use the following allocation pattern?
unsigned num_syncobj_dependencies = csc->syncobj_dependencies.num; uint32_t *syncobj_dependencies_list = NULL;
if (num_syncobj_dependencies > 0) {
syncobj_dependencies_list =
alloca(num_syncobj_dependencies * sizeof(uint32_t));
/* fill the buffer */
}Regards,
Prike
Quoted 45 lines
-----Original Message-----
From: Michel Dänzer <[email protected]>
Sent: Thursday, March 19, 2026 6:47 PM
To: Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>; Mohan Marimuthu, Yogesh <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"Quoted 3 lines · Christian König
Hi guys,
well when mesa leaves some fields in the structure uninitialized then that is a
pretty bad idea and we should eventually fix that.
Quoted 2 lines
But always setting the pointers to valid arrays and just setting the number of array
elements to zero is perfectly valid.
Quoted 2 lines
That doesn't even needs a debug message.
As discussed recently for another patch, the "(How to avoid) Botching up ioctls" page of the kernel documentation says under Basics:
* Check all unused fields and flags and all the padding for whether it’s 0, and reject the ioctl if that’s not the case.
That seems to apply here, i.e. the kernel should have these checks and Mesa should initialize the pointer field to 0 when the corresponding num_* field is.
P.S. I agree it probably doesn't make a practical difference in this specific case. I suspect the rule is aimed at when the ioctl struct is extended, in which case Mesa's current behaviour would be indistinguishable from user-space code which actually doesn't properly initialize the newly-added fields.It seems safer to stick to the rule even in cases like this where it's not strictly required.
--
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
https://redhat.com \ Libre software enthusiast
[Public]
Hi,
I studied the documentation at https://docs.kernel.org/process/botching-up-ioctls.html
In this case there is size and a pointer, so it is not strictly required. But good to follow coding guidelines.
@Liang, Prike<mailto:[email protected]> your proposed changes looks good.
Thank you,
Yogesh
________________________________
From: Liang, Prike <[email protected]>
Sent: Friday, March 20, 2026 8:11 AM
To: Michel Dänzer <[email protected]>; Koenig, Christian <[email protected]>; Mohan Marimuthu, Yogesh <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>
Cc: [email protected] <[email protected]>
Subject: RE: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"
[Public]
Yes, in this case it’s cleaner and more robust to not allocate at all when num == 0, and keep the pointer as NULL. For the mesa driver, how about use the following allocation pattern?
unsigned num_syncobj_dependencies = csc->syncobj_dependencies.num; uint32_t *syncobj_dependencies_list = NULL;
if (num_syncobj_dependencies > 0) {
syncobj_dependencies_list =
alloca(num_syncobj_dependencies * sizeof(uint32_t));
/* fill the buffer */
}Regards,
Prike
Quoted 45 lines
-----Original Message-----
From: Michel Dänzer <[email protected]>
Sent: Thursday, March 19, 2026 6:47 PM
To: Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>; Mohan Marimuthu, Yogesh <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Revert "drm/amdgpu: harden SIGNAL/WAIT ioctl argument validation"Quoted 3 lines · Christian König
Hi guys,
well when mesa leaves some fields in the structure uninitialized then that is a
pretty bad idea and we should eventually fix that.
Quoted 2 lines
But always setting the pointers to valid arrays and just setting the number of array
elements to zero is perfectly valid.
Quoted 2 lines
That doesn't even needs a debug message.
As discussed recently for another patch, the "(How to avoid) Botching up ioctls" page of the kernel documentation says under Basics:
* Check all unused fields and flags and all the padding for whether it’s 0, and reject the ioctl if that’s not the case.
That seems to apply here, i.e. the kernel should have these checks and Mesa should initialize the pointer field to 0 when the corresponding num_* field is.
P.S. I agree it probably doesn't make a practical difference in this specific case. I suspect the rule is aimed at when the ioctl struct is extended, in which case Mesa's current behaviour would be indistinguishable from user-space code which actually doesn't properly initialize the newly-added fields.It seems safer to stick to the rule even in cases like this where it's not strictly required.
--
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
https://redhat.com \ Libre software enthusiast