Commit 4a6f3df
drm/xe: Prevent BIT() overflow when handling invalid prefetch region
[ Upstream commit d52dea485cd3c98cfeeb474cf66cf95df2ab142f ]
If user provides a large value (such as 0x80) for parameter
prefetch_mem_region_instance in vm_bind ioctl, it will cause
BIT(prefetch_region) overflow as below:
"
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in drivers/gpu/drm/xe/xe_vm.c:3414:7
shift exponent 128 is too large for 64-bit type 'long unsigned int'
CPU: 8 UID: 0 PID: 53120 Comm: xe_exec_system_ Tainted: G W 6.18.0-rc1-lgci-xe-kernel+ #200 PREEMPT(voluntary)
Tainted: [W]=WARN
Hardware name: ASUS System Product Name/PRIME Z790-P WIFI, BIOS 0812 02/24/2023
Call Trace:
<TASK>
dump_stack_lvl+0xa0/0xc0
dump_stack+0x10/0x20
ubsan_epilogue+0x9/0x40
__ubsan_handle_shift_out_of_bounds+0x10e/0x170
? mutex_unlock+0x12/0x20
xe_vm_bind_ioctl.cold+0x20/0x3c [xe]
...
"
Fix it by validating prefetch_region before the BIT() usage.
v2: Add Closes and Cc stable kernels. (Matt)
Reported-by: Koen Koning <[email protected]>
Reported-by: Peter Senna Tschudin <[email protected]>
Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6478
Cc: <[email protected]> # v6.8+
Reviewed-by: Matthew Auld <[email protected]>
Signed-off-by: Shuicheng Lin <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Link: https://patch.msgid.link/[email protected]
(cherry picked from commit 8f565bdd14eec5611cc041dba4650e42ccdf71d9)
Signed-off-by: Lucas De Marchi <[email protected]>
(cherry picked from commit d52dea485cd3c98cfeeb474cf66cf95df2ab142f)
Signed-off-by: Shuicheng Lin <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>1 parent 7f04be0 commit 4a6f3df
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3475 | 3475 | | |
3476 | 3476 | | |
3477 | 3477 | | |
3478 | | - | |
3479 | | - | |
| 3478 | + | |
| 3479 | + | |
3480 | 3480 | | |
3481 | 3481 | | |
3482 | 3482 | | |
| |||
0 commit comments