• Fei Yang's avatar
    drm/xe: timeout needs to be a signed value · e2e2d963
    Fei Yang authored
    In xe_wait_user_fence_ioctl, the timeout is currently defined as
    unsigned long. That could potentially pass a negative value to
    the schedule_timeout() call because nsecs_to_jiffies() returns an
    unsigned long which gets used as signed long.
    
    [ 187.732238] schedule_timeout: wrong timeout value fffffffffffffc18
    [ 187.733180] CPU: 0 PID: 792 Comm: test_thread_dim Tainted: G U 6.4.0-xe #1
    [ 187.734251] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
    [ 187.735019] Call Trace:
    [ 187.735373] <TASK>
    [ 187.735687] dump_stack_lvl+0x92/0xb0
    [ 187.736193] schedule_timeout+0x348/0x430
    [ 187.736739] ? __might_fault+0x67/0xd0
    [ 187.737255] ? check_chain_key+0x224/0x2d0
    [ 187.737812] ? __pfx_schedule_timeout+0x10/0x10
    [ 187.738429] ? __might_fault+0x6b/0xd0
    [ 187.738946] ? __pfx_lock_release+0x10/0x10
    [ 187.739512] ? __pfx_lock_release+0x10/0x10
    [ 187.740080] wait_woken+0x86/0x100
    [ 187.740556] xe_wait_user_fence_ioctl+0x34b/0xe00 [xe]
    [ 187.741281] ? __pfx_xe_wait_user_fence_ioctl+0x10/0x10 [xe]
    [ 187.742075] ? lock_acquire+0x169/0x3d0
    [ 187.742601] ? check_chain_key+0x224/0x2d0
    [ 187.743158] ? drm_dev_enter+0x9/0xe0 [drm]
    [ 187.743740] ? __pfx_woken_wake_function+0x10/0x10
    [ 187.744388] ? drm_dev_exit+0x11/0x50 [drm]
    [ 187.744969] ? __pfx_lock_release+0x10/0x10
    [ 187.745536] ? __might_fault+0x67/0xd0
    [ 187.746052] ? check_chain_key+0x224/0x2d0
    [ 187.746610] drm_ioctl_kernel+0x172/0x250 [drm]
    [ 187.747242] ? __pfx_xe_wait_user_fence_ioctl+0x10/0x10 [xe]
    [ 187.748037] ? __pfx_drm_ioctl_kernel+0x10/0x10 [drm]
    [ 187.748729] ? __pfx_xe_wait_user_fence_ioctl+0x10/0x10 [xe]
    [ 187.749524] ? __pfx_xe_wait_user_fence_ioctl+0x10/0x10 [xe]
    [ 187.750319] drm_ioctl+0x35e/0x620 [drm]
    [ 187.750871] ? __pfx_drm_ioctl+0x10/0x10 [drm]
    [ 187.751495] ? restore_fpregs_from_fpstate+0x99/0x140
    [ 187.752172] ? __pfx_restore_fpregs_from_fpstate+0x10/0x10
    [ 187.752901] ? mark_held_locks+0x24/0x90
    [ 187.753438] __x64_sys_ioctl+0xb4/0xf0
    [ 187.753954] do_syscall_64+0x3f/0x90
    [ 187.754450] entry_SYSCALL_64_after_hwframe+0x72/0xdc
    [ 187.755127] RIP: 0033:0x7f4e6651aaff
    [ 187.755623] Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <41> 89 c0 3d 00 f0 ff ff 77 1f 48 8b 44 24 18 64 48 2b 04 25 28 00
    [ 187.757995] RSP: 002b:00007fff05f37a50 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
    [ 187.758995] RAX: ffffffffffffffda RBX: 000055eca47c8130 RCX: 00007f4e6651aaff
    [ 187.759935] RDX: 00007fff05f37b60 RSI: 00000000c050644b RDI: 0000000000000004
    [ 187.760874] RBP: 0000000000000017 R08: 0000000000000017 R09: 7fffffffffffffff
    [ 187.761814] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
    [ 187.762753] R13: 0000000000000000 R14: 0000000000000000 R15: 00007f4e65d19ce0
    [ 187.763694] </TASK>
    
    Fixes: 5572a004 ("drm/xe: Use nanoseconds instead of jiffies in uapi for user fence")
    Signed-off-by: default avatarFei Yang <fei.yang@intel.com>
    Cc: Andi Shyti <andi.shyti@linux.intel.com>
    Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
    Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
    Link: https://lore.kernel.org/r/20230921220500.994558-2-fei.yang@intel.comSigned-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
    Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
    e2e2d963
xe_wait_user_fence.c 6.25 KB