[PATCH 4/4] sched/deadline: Reject SCHED_DEADLINE on exited tasks
From: Juri Lelli
Date: Tue Nov 03 2026 - 07:52:38 EST
sched_setattr(SCHED_DEADLINE) on a zombie task succeeds and charges
total_bw via sched_dl_overflow(), but the task has already done its
final schedule() and will never run again. Nothing releases the reserved
bandwidth. Repeating this fills total_bw to the admission cap, after
which sched_setattr(SCHED_DEADLINE) and CPU offline fail with -EBUSY.
Reject sched_setattr(SCHED_DEADLINE) on exited tasks with -ESRCH.
Reported-by: Weiheng Qiu <weihengqiuu@xxxxxxxxx>
Closes: https://lore.kernel.org/all/3f6e6c87-645b-45fd-8fc6-8da5bc5b82d8@xxxxxxxxx/
Signed-off-by: Juri Lelli <juri.lelli@xxxxxxxxxx>
---
kernel/sched/syscalls.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index 014697d454525..af9ba357a2956 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -583,6 +583,16 @@ int __sched_setscheduler(struct task_struct *p,
if (retval)
goto unlock;
+ /*
+ * Reject SCHED_DEADLINE on exited tasks. A zombie will never be
+ * scheduled again, so sched_dl_overflow() would charge total_bw
+ * that nothing will ever release.
+ */
+ if (dl_policy(policy) && p->exit_state) {
+ retval = -ESRCH;
+ goto unlock;
+ }
+
/*
* If not changing anything there's no need to proceed further,
* but store a possible modification of reset_on_fork.
--
2.56.0