diff options
| author | Danilo Krummrich <[email protected]> | 2023-04-18 10:04:53 +0000 |
|---|---|---|
| committer | Luben Tuikov <[email protected]> | 2023-04-19 02:09:41 +0000 |
| commit | 96c7c2f4d5bd94b15fe63448c087f01607b56f4a (patch) | |
| tree | 8f493c7c878190eff8cdb5f640c5b336341bb907 /drivers/gpu/drm/scheduler/sched_entity.c | |
| parent | drm/nouveau/therm: Move an assignment statement behind a null pointer check i... (diff) | |
| download | kernel-96c7c2f4d5bd94b15fe63448c087f01607b56f4a.tar.gz kernel-96c7c2f4d5bd94b15fe63448c087f01607b56f4a.zip | |
drm/scheduler: set entity to NULL in drm_sched_entity_pop_job()
It already happend a few times that patches slipped through which
implemented access to an entity through a job that was already removed
from the entities queue. Since jobs and entities might have different
lifecycles, this can potentially cause UAF bugs.
In order to make it obvious that a jobs entity pointer shouldn't be
accessed after drm_sched_entity_pop_job() was called successfully, set
the jobs entity pointer to NULL once the job is removed from the entity
queue.
Moreover, debugging a potential NULL pointer dereference is way easier
than potentially corrupted memory through a UAF.
Signed-off-by: Danilo Krummrich <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Luben Tuikov <[email protected]>
Signed-off-by: Luben Tuikov <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/scheduler/sched_entity.c')
| -rw-r--r-- | drivers/gpu/drm/scheduler/sched_entity.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index e0a8890a62e2..3e2a31d8190e 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -448,6 +448,12 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) drm_sched_rq_update_fifo(entity, next->submit_ts); } + /* Jobs and entities might have different lifecycles. Since we're + * removing the job from the entities queue, set the jobs entity pointer + * to NULL to prevent any future access of the entity through this job. + */ + sched_job->entity = NULL; + return sched_job; } |
