Linux deadline scheduler fixes cover crash and use-after-free
Thirty-two SCHED_DEADLINE bugs can crash the kernel, read freed memory, or admit real-time tasks beyond what a CPU set can guarantee.
Mathieu Desnoyers has sent fixes for 32 bugs in the Linux kernel's SCHED_DEADLINE scheduler, the class that reserves CPU time for tasks that must finish by a deadline. One can take the kernel down. Three can leave a lock owner reading freed memory after a priority-inheritance donor exits. Another can leave a task that never runs again. Most of the rest leave the bandwidth totals wrong, so a set of CPUs either admits deadline work beyond what it can guarantee or refuses every new deadline task.
Those totals are the admission gate for real-time reservations. They have to survive CPU hotplug, cpuset moves, isolated CPUs, and rebuilds of scheduling domains. Desnoyers wrote on the kernel mailing list that departing tasks can lose their bandwidth across a rebuild, a cpuset attach can fail to move or reserve bandwidth correctly, and a task can be counted in a different domain from the one it runs in. The recorded load then no longer matches the tasks actually present.
Priority inheritance is the other severe hole. A deadline waiter can boost the owner of a lock, and that boost can follow a chain of owners. Walks can stop one lock too early, so an owner keeps a donor that is free to exit. The owner's next runtime refill then reads the donor's freed task structure. Separate fixes cover waiters that enter the deadline class while blocked and are treated as having a deadline of zero, so they jump the queue and can boost an owner whose own deadline is earlier.
Parameter changes have a quieter overrun. The kernel keeps leftover runtime when a task leaves the deadline class, so hopping out and back cannot mint a fresh budget. Admission control still counts the new reservation at once. Juri Lelli found that a task reserved 50 milliseconds every 100 could return, via the ordinary scheduler, with a 10 millisecond reservation and still run 39 milliseconds of the next window. Shrinking a reservation in place has the same shape: other tasks can be admitted into bandwidth the shrinking task is still using. The fix applies the check a wakeup already uses, so leftover runtime that does not fit the new parameters is cut back or starts a new period.
Constrained-deadline tasks, whose deadline is shorter than their period, have related gaps. One can be taken off the deadline runqueue and still keep the CPU, because nothing asks for a reschedule and the tick no longer charges or preempts it. Changing the deadline length mid-period can also throttle a task against the wrong start of the next period. A throttled owner can fail to inherit an earlier waiter's deadline and hold the lock until its own next period. Several of these were found in an automated review of the previous revision.
The fixes are marked for stable kernels. One of the use-after-free fixes depends on a change present only since Linux 6.17, so older stable trees need that change first. Desnoyers also extended the deadline bandwidth selftest for hotplug, cpuset partitions, class changes, and the lock chains, and said the new cases pass with the fixes where they can run. The work sits on an earlier set of deadline fixes and includes one of Lelli's that had been dropped from the urgent scheduler branch.