2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/drivers/gpu/drm/v3d
Maíra Canal 497d370a64
drm/v3d: Fix out-of-bounds read in v3d_csd_job_run()
When enabling UBSAN on Raspberry Pi 5, we get the following warning:

[  387.894977] UBSAN: array-index-out-of-bounds in drivers/gpu/drm/v3d/v3d_sched.c:320:3
[  387.903868] index 7 is out of range for type '__u32 [7]'
[  387.909692] CPU: 0 PID: 1207 Comm: kworker/u16:2 Tainted: G        WC         6.10.3-v8-16k-numa #151
[  387.919166] Hardware name: Raspberry Pi 5 Model B Rev 1.0 (DT)
[  387.925961] Workqueue: v3d_csd drm_sched_run_job_work [gpu_sched]
[  387.932525] Call trace:
[  387.935296]  dump_backtrace+0x170/0x1b8
[  387.939403]  show_stack+0x20/0x38
[  387.942907]  dump_stack_lvl+0x90/0xd0
[  387.946785]  dump_stack+0x18/0x28
[  387.950301]  __ubsan_handle_out_of_bounds+0x98/0xd0
[  387.955383]  v3d_csd_job_run+0x3a8/0x438 [v3d]
[  387.960707]  drm_sched_run_job_work+0x520/0x6d0 [gpu_sched]
[  387.966862]  process_one_work+0x62c/0xb48
[  387.971296]  worker_thread+0x468/0x5b0
[  387.975317]  kthread+0x1c4/0x1e0
[  387.978818]  ret_from_fork+0x10/0x20
[  387.983014] ---[ end trace ]---

This happens because the UAPI provides only seven configuration
registers and we are reading the eighth position of this u32 array.

Therefore, fix the out-of-bounds read in `v3d_csd_job_run()` by
accessing only seven positions on the '__u32 [7]' array. The eighth
register exists indeed on V3D 7.1, but it isn't currently used. That
being so, let's guarantee that it remains unused and add a note that it
could be set in a future patch.

Fixes: 0ad5bc1ce4 ("drm/v3d: fix up register addresses for V3D 7.x")
Reported-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240809152001.668314-1-mcanal@igalia.com
2024-08-12 11:14:21 -03:00
..
Kconfig drm/v3d: Add support for bcm2711 2022-06-12 22:10:50 -01:00
Makefile drm/v3d: Detach job submissions IOCTLs to a new specific file 2023-12-01 09:34:01 -03:00
v3d_bo.c fix missing vmalloc.h includes 2024-04-25 20:55:49 -07:00
v3d_debugfs.c drm/v3d: Enable V3D to use different PAGE_SIZE 2024-02-23 16:37:20 -03:00
v3d_drv.c drm/v3d: Add V3D tech revision to the device information 2024-07-15 12:45:59 -03:00
v3d_drv.h Merge drm/drm-fixes into drm-misc-fixes 2024-07-30 09:09:23 +02:00
v3d_fence.c
v3d_gem.c drm/v3d: Fix race-condition between sysfs/fdinfo and interrupt handler 2024-04-23 19:32:49 -03:00
v3d_irq.c drm/v3d: Create two functions to update all GPU stats variables 2024-04-23 19:32:45 -03:00
v3d_mmu.c drm/v3d: Enable V3D to use different PAGE_SIZE 2024-02-23 16:37:20 -03:00
v3d_perfmon.c drm/v3d: Fix perfmon build error/warning 2024-06-05 10:44:51 +02:00
v3d_performance_counters.h drm/v3d: Fix perfmon build error/warning 2024-06-05 10:44:51 +02:00
v3d_regs.h drm/v3d: fix up register addresses for V3D 7.x 2023-11-02 08:54:39 -03:00
v3d_sched.c drm/v3d: Fix out-of-bounds read in v3d_csd_job_run() 2024-08-12 11:14:21 -03:00
v3d_submit.c drm/v3d: Validate passed in drm syncobj handles in the performance extension 2024-07-18 15:50:08 +02:00
v3d_sysfs.c drm/v3d: Decouple stats calculation from printing 2024-04-23 19:32:48 -03:00
v3d_trace_points.c
v3d_trace.h drm/v3d: Create tracepoints to track the CPU job 2023-12-01 09:37:48 -03:00