_chardev.c:3244). - No architectural changes, no new UAPI or features, and no functional change for supported ioctls. - Potential regression risk is low: only the errno for “unsupported ioctl” changes from -EINVAL to -ENOTTY. Well-behaved user space should treat -ENOTTY (not -EINVAL) as the indicator for an unsupported ioctl. This is correcting an API bug rather than changing intended behavior. - Security impact is nil; control flow and data handling are unchanged. - Stable backport criteria - Fixes a real user-visible bug: ambiguous errno on unsupported ioctls made feature detection and fallback logic in userland unreliable. - Minimal, self-contained patch limited to amdkfd. - No side effects beyond improving errno correctness for unsupported ioctls. - Consistent with prior amdkfd errno cleanups (e.g., “Return proper error code for gws alloc API”) and general kernel ioctl practices. Given these points, this is a good, low-risk candidate for stable backport. drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 828a9ceef1e76..79ed3be63d0dd 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -3252,8 +3252,10 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) int retcode = -EINVAL; bool ptrace_attached = false; - if (nr >= AMDKFD_CORE_IOCTL_COUNT) + if (nr >= AMDKFD_CORE_IOCTL_COUNT) { + retcode = -ENOTTY; goto err_i1; + } if ((nr >= AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END)) { u32 amdkfd_size; @@ -3266,8 +3268,10 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) asize = amdkfd_size; cmd = ioctl->cmd; - } else + } else { + retcode = -ENOTTY; goto err_i1; + } dev_dbg(kfd_device, "ioctl cmd 0x%x (#0x%x), arg 0x%lx\n", cmd, nr, arg); -- 2.51.0[PATCH AUTOSEL 6.17-5.4] drm/amdkfd: return -ENOTTY for unsupported IOCTLsSasha Levin undefinedpatches@lists.linux.dev, stable@vger.kernel.org undefined undefined undefined undefined undefined undefined(