]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
drm/scheduler: set entity to NULL in drm_sched_entity_pop_job()
authorDanilo Krummrich <dakr@redhat.com>
Tue, 18 Apr 2023 10:04:53 +0000 (12:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Aug 2023 15:32:24 +0000 (17:32 +0200)
commit4bea167169502034e637a009b52b187fa3d8dec8
tree2ec2ceb3de55466aef27c889c1720e0d7d528e9f
parentdd2e5d3f806b15bfb7c519f69ebcbbc8dfcc2a5f
drm/scheduler: set entity to NULL in drm_sched_entity_pop_job()

[ Upstream commit 96c7c2f4d5bd94b15fe63448c087f01607b56f4a ]

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 <dakr@redhat.com>
Link: https://lore.kernel.org/r/20230418100453.4433-1-dakr@redhat.com
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/scheduler/sched_entity.c
drivers/gpu/drm/scheduler/sched_main.c