diff options
author | Zhaoyang Huang <zhaoyang.huang@unisoc.com> | 2021-06-11 02:29:34 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2021-06-24 09:07:50 +0200 |
commit | 8f91efd870ea5d8bc10b0fcc9740db51cd4c0c83 (patch) | |
tree | 6d89d1b65e335497b1cb3f85296a2e3501fb6633 /kernel/cfi.c | |
parent | sched/fair: Introduce the burstable CFS controller (diff) | |
download | linux-8f91efd870ea5d8bc10b0fcc9740db51cd4c0c83.tar.xz linux-8f91efd870ea5d8bc10b0fcc9740db51cd4c0c83.zip |
psi: Fix race between psi_trigger_create/destroy
Race detected between psi_trigger_destroy/create as shown below, which
cause panic by accessing invalid psi_system->poll_wait->wait_queue_entry
and psi_system->poll_timer->entry->next. Under this modification, the
race window is removed by initialising poll_wait and poll_timer in
group_init which are executed only once at beginning.
psi_trigger_destroy() psi_trigger_create()
mutex_lock(trigger_lock);
rcu_assign_pointer(poll_task, NULL);
mutex_unlock(trigger_lock);
mutex_lock(trigger_lock);
if (!rcu_access_pointer(group->poll_task)) {
timer_setup(poll_timer, poll_timer_fn, 0);
rcu_assign_pointer(poll_task, task);
}
mutex_unlock(trigger_lock);
synchronize_rcu();
del_timer_sync(poll_timer); <-- poll_timer has been reinitialized by
psi_trigger_create()
So, trigger_lock/RCU correctly protects destruction of
group->poll_task but misses this race affecting poll_timer and
poll_wait.
Fixes: 461daba06bdc ("psi: eliminate kthread_worker from psi trigger scheduling mechanism")
Co-developed-by: ziwei.dai <ziwei.dai@unisoc.com>
Signed-off-by: ziwei.dai <ziwei.dai@unisoc.com>
Co-developed-by: ke.wang <ke.wang@unisoc.com>
Signed-off-by: ke.wang <ke.wang@unisoc.com>
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Link: https://lkml.kernel.org/r/1623371374-15664-1-git-send-email-huangzhaoyang@gmail.com
Diffstat (limited to 'kernel/cfi.c')
0 files changed, 0 insertions, 0 deletions