Re: [PATCH 08/16] sched/deadline: Do not replenish a boost from cleared parameters
From: sashiko-bot
Date: Wed Nov 18 2026 - 15:35:57 EST
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] sched/deadline: use-after-free of pi_se via
rt_mutex_adjust_prio_chain() [1]
--
commit 961bc9d5ebb4610c191709612415310c77835eeb
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Do not replenish a boost from cleared parameters
This commit prevents an infinite loop in replenish_dl_entity() when an
rt_mutex donor leaves SCHED_DEADLINE and has its deadline parameters
cleared before the priority-inheritance chain walk deboosts the lock
owner.
Link: https://lore.kernel.org/all/avL8oOtjKqVNR7-l@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index e4d7cbf4861de..71b1c155c2424 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -807,8 +807,38 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)
> {
> struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
> struct rq *rq = rq_of_dl_rq(dl_rq);
> + struct sched_dl_entity *pi_se = pi_of(dl_se);
> + u64 runtime = READ_ONCE(pi_se->dl_runtime);
> + u64 deadline = READ_ONCE(pi_se->dl_deadline);
> + u64 period = READ_ONCE(pi_se->dl_period);
[Severity: High]
This problem wasn't introduced by this patch, but can pi_se point to a
freed task_struct after a nested rt_mutex wait is aborted [1]?
Suppose deadline task M with positive remaining runtime holds lock L1, and
deadline task W with an earlier deadline blocks on L1. rt_mutex_setprio()
sets M->dl.pi_se = &W->dl while replenish_dl_entity() leaves
M->dl.deadline unchanged, and when M blocks on L2 held by O, O->dl.pi_se
becomes &W->dl.
When W aborts its wait on L1, remove_waiter() resets M->dl.pi_se to &M->dl
without changing M->dl.deadline and calls rt_mutex_adjust_prio_chain() on
M:
kernel/locking/rtmutex.c:rt_mutex_adjust_prio_chain() {
...
if (rt_waiter_node_equal(&waiter->tree, task_to_waiter_node(task))) {
if (!detect_deadlock)
goto out_unlock_pi;
...
}
Because rt_waiter_node_equal() compares only prio and deadline, it sees no
change for M's waiter on L2 and stops the walk before reaching O. Once W
exits and is freed, replenishing O here dereferences a dangling O->dl.pi_se
(use-after-free).
[1] https://sashiko.dev/#/bug/linux-e1386e80-9bd4-4219-9441-8f56e84f7735
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795031605.git.mathieu.desnoyers@xxxxxxxxxxxx?part=8