Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iv_timer: Protect against some cases of timer memory corruption.
In one recent report, ivykis was getting into an infinite loop in iv_run_timers() because of a registered iv_timer struct having become corrupted. Specifically, this timer was actually on the timer heap, but with a heap index (->index) of zero, which normally indicates that the timer is on the expired list, and ->list_expired.{next,prev} pointing to writeable memory. When this timer would then get to the root of the heap, we would get into an infinite loop calling iv_timer_unregister() on this timer, which ought to remove the timer from the heap, but in this case wouldn't, as its heap index was already zero. We can catch this case by making sure that whenever a timer expires and we try to remove it from the heap, its heap index is equal to 1, which signifies the root position, and abort if otherwise. Signed-off-by: Lennert Buytenhek <[email protected]>
- Loading branch information