Skip to content
Snippets Groups Projects
Commit 33e518ee authored by Tomasz Grabiec's avatar Tomasz Grabiec Committed by Pekka Enberg
Browse files

sched: change timer state inside atomic context


timer_base is a thread-agnostic interface for per-CPU timers.  The
current code is prone to a race condition involving set() and
cancel(). The latter may attempt to remove the timer before it was
inserted into timer tree.

Found during code inspection.

Reviewed-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarTomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 901e67bc
No related branches found
No related tags found
No related merge requests found
......@@ -1064,10 +1064,11 @@ void timer_base::expire()
void timer_base::set(osv::clock::uptime::time_point time)
{
trace_timer_set(this, time.time_since_epoch().count());
_state = state::armed;
_time = time;
irq_save_lock_type irq_lock;
WITH_LOCK(irq_lock) {
_state = state::armed;
_time = time;
auto& timers = cpu::current()->timers;
timers._list.insert(*this);
_t._active_timers.push_back(*this);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment