Skip to contentSkip to conversation

drm/sched: Don't crash kernel on wrong params

PATCH In review Philipp Stanner 3 participants 3 messages Nov 12, 2025

Subsystems (3)
lore
Share & tools
lore

Philipp Stanner

author maintainer
#0 lore raw

PATCH v2 1/1 drm/sched: Don't crash kernel on wrong params

drm_sched_job_arm() just panics the kernel with BUG_ON() in case of an entity being NULL. If the entity is NULL, subsequent accesses will crash the particular CPU anyways with a NULL pointer exception backtrace.

Remove the BUG_ON().

---
Changes in v2:
- Drop BUG_ON() instead of replacing it. (Tvrtko)

---
 drivers/gpu/drm/scheduler/sched_main.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -1
index 1d4f1b822e7b..05eb50d4cf08 100644
@@ -857,7 +857,6 @@ void drm_sched_job_arm(struct drm_sched_job *job)
 	struct drm_gpu_scheduler *sched;
 	struct drm_sched_entity *entity = job->entity;
 
-	BUG_ON(!entity);
 	drm_sched_entity_select_rq(entity);
 	sched = entity->rq->sched;
 
Signature · 1 line
2.49.0
#1 lore raw
Quoted 10 lines · Philipp Stanner

drm_sched_job_arm() just panics the kernel with BUG_ON() in case of an entity being NULL. If the entity is NULL, subsequent accesses will crash the particular CPU anyways with a NULL pointer exception backtrace.

Remove the BUG_ON().

---
Changes in v2:
- Drop BUG_ON() instead of replacing it. (Tvrtko)

The option of removing the BUG_ON was conditional on brainstorming a bit whether we think the null pointer dereference is the worst that can happen or not.

Other option was "WARN_ON_ONCE() return" in arm and push.

Problem being, if we allow it to continue, are we opening up the possibly to mess up the kernel in a worse way.

For example push job writes to the entity. Okay offsets are low so is the zero page always safe to write? I don't know but sounds scary. From that point of view BUG_ON or WARN_ON_ONCE with exit are safer options.

Regards,

Tvrtko

Quoted 16 lines
---
  drivers/gpu/drm/scheduler/sched_main.c | 1 -
  1 file changed, 1 deletion(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -1
index 1d4f1b822e7b..05eb50d4cf08 100644
@@ -857,7 +857,6 @@ void drm_sched_job_arm(struct drm_sched_job *job)
  	struct drm_gpu_scheduler *sched;
  	struct drm_sched_entity *entity = job->entity;
 
-	BUG_ON(!entity);
  	drm_sched_entity_select_rq(entity);
  	sched = entity->rq->sched;
 
#2 lore raw
Quoted 13 lines · Tvrtko Ursulin
Quoted 10 lines · Philipp Stanner

drm_sched_job_arm() just panics the kernel with BUG_ON() in case of an entity being NULL. If the entity is NULL, subsequent accesses will crash the particular CPU anyways with a NULL pointer exception backtrace.

Remove the BUG_ON().

---
Changes in v2:
   - Drop BUG_ON() instead of replacing it. (Tvrtko)

Quoted 6 lines

The option of removing the BUG_ON was conditional on brainstorming a bit whether we think the null pointer dereference is the worst that can happen or not.

Other option was "WARN_ON_ONCE() return" in arm and push.

Maybe even WARN_ON() is OK to make it noticable.

I mostly care about getting rid of BUG_ON().

P.