<div dir="ltr">Hello,<br><br>We would like to report a null-ptr-deref bug in the AMDGPU DRM driver in the linux kernel v6.8-rc4 that we found with our customized Syzkaller.<br>The bug can be triggered by sending two ioctls to the AMDGPU DRM driver in succession.<br><br>The first ioctl amdgpu_ctx_ioctl will create a ctx, and return ctx_id = 1 to the userspace.<br>Second ioctl, actually any ioctl that will eventually call amdgpu_ctx_get_entity, carries this ctx_id and passes the context check.<br>Here, for example, drm_amdgpu_wait_cs.<br>Validations in amdgpu_ctx_get_entity can also be passed by the user-provided values from the ioctl arguments.<br>This eventually leads to drm_sched_entity_init, where the null-ptr-deref will trigger on RCU_INIT_POINTER(entity->last_scheduled, NULL);<br><br>Steps to reproduce are as below.<br>union drm_amdgpu_ctx *arg1;<br>union drm_amdgpu_wait_cs *arg2;<br><br>arg1 = malloc(sizeof(union drm_amdgpu_ctx));<br>arg2 = malloc(sizeof(union drm_amdgpu_wait_cs));<br><br>arg1->in.op = 0x1;<br>ioctl(AMDGPU_renderD128_DEVICE_FILE, 0x140106442, arg1);<br><br>arg2->in.handle = 0x0;<br>arg2->in.timeout = 0x2000000000000;<br>arg2->in.ip_type = 0x9;<br>arg2->in.ip_instance = 0x0;<br>arg2->in.ring = 0x0;<br>arg2->in.ctx_id = 0x1;<br>ioctl(AMDGPU_renderD128_DEVICE_FILE, 0xc0206449, arg2);<br><br>The KASAN report is as follows:<br>general protection fault, probably for non-canonical address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN NOPTI<br>KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]<br>Call Trace:<br> <TASK><br> ? drm_sched_entity_init+0x16e/0x650<br> ? drm_sched_entity_init+0x208/0x650<br> amdgpu_ctx_get_entity+0x944/0xc30<br> amdgpu_cs_wait_ioctl+0x13d/0x3f0<br> drm_ioctl_kernel+0x300/0x410<br> drm_ioctl+0x648/0xb30<br> amdgpu_drm_ioctl+0xc8/0x160<br> </TASK><br><br>Should you need any more information, please do not hesitate to contact us.<br><br>Best regards,<br>Joonkyo Jung<br></div>