zephyr/kernel
Andy Ross d8d5ec3f91 kernel: Fix double-list-removal corruption case in timeout handling
This fixes #8669, and is distressingly subtle for a one-line patch:

The list iteration code in _handle_expired_timeouts() would remove the
timeout from our (temporary -- the dlist header is on the stack of our
calling function) list of expired timeouts before invoking the
handler.  But sys_dlist_remove() only fixes up the containing list
pointers, leaving garbage in the node.  If the action of that handler
is to re-add the timeout (which is very common!) then that will then
try to remove it AGAIN from the same list.

Even then, the common case is that the expired list contains only one
item, so the result is a perfectly valid empty list that affects
nothing.  But if you have more than one, you get a corrupt cycle in
the iteration list and things get weird.

As it happens, there's no value in trying to remove this timeout from
the temporary list at all.  Just iterate over it naturally.

Really, this design is fragile: we shouldn't be reusing the list nodes
in struct _timeout for this purpose and should figure out some other
mechanism.  But this fix should be good for now.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-08-26 19:39:52 -07:00
..
include kernel: Fix double-list-removal corruption case in timeout handling 2018-08-26 19:39:52 -07:00
alert.c syscalls: remove policy from handler checks 2018-05-17 23:34:03 +03:00
atomic_c.c
CMakeLists.txt kernel: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for kernel files. 2018-05-15 17:48:18 +03:00
compiler_stack_protect.c kernel: add CODE_UNREACHABLE in _StackCheckHandler 2018-04-17 10:50:12 -07:00
device.c kernel: device: Only compare strings if pointer comparison fails 2018-02-15 17:31:59 -08:00
errno.c kernel: userspace: reserve stack space to store local data 2018-08-17 09:40:52 -07:00
idle.c kernel: idle: Define _sys_soc_resume functions conditionally 2018-07-19 17:12:58 -04:00
init.c tracing: support generic tracing hooks 2018-08-21 05:45:47 -07:00
int_latency_bench.c Convert remaining code to using newly introduced integer sized types 2017-04-21 11:38:23 -05:00
Kconfig kernel: event_logger: remove kernel_event_logger 2018-08-21 05:45:47 -07:00
Kconfig.power_mgmt subsys: power: Add OS managed Power Management framework 2018-08-22 08:07:14 -07:00
mailbox.c kernel: Explicitly ignoring memcpy return 2018-08-16 19:47:41 -07:00
mem_domain.c kernel: mem_domain: Fix compile issues 2018-03-05 10:47:00 -06:00
mem_slab.c kernel: mem_slab: Reschedule in k_mem_slab_free only when necessary. 2018-05-18 20:16:50 +03:00
mempool.c kernel: Explicitly ignoring memcpy return 2018-08-16 19:47:41 -07:00
msg_q.c kernel: Explicitly ignoring memcpy return 2018-08-16 19:47:41 -07:00
mutex.c tracing: support generic tracing hooks 2018-08-21 05:45:47 -07:00
pipes.c kernel: Wait queues aren't dlists anymore 2018-05-19 07:00:55 +03:00
poll.c kernel: Explicitly ignoring memcpy return 2018-08-16 19:47:41 -07:00
queue.c kernel: Explicitly ignoring results of queue_insert 2018-08-16 19:47:41 -07:00
sched.c tracing: support generic tracing hooks 2018-08-21 05:45:47 -07:00
sem.c tracing: support generic tracing hooks 2018-08-21 05:45:47 -07:00
smp.c irq: Fix irq_lock api usage 2018-08-16 19:47:41 -07:00
stack.c kernel: Wait queues aren't dlists anymore 2018-05-19 07:00:55 +03:00
sys_clock.c kernel: Remove unused variable 2018-08-26 19:39:52 -07:00
system_work_q.c kernel: introduce stack definition macros 2017-06-09 18:53:28 -04:00
thread_abort.c syscalls: remove policy from handler checks 2018-05-17 23:34:03 +03:00
thread.c kernel: event_logger: remove kernel_event_logger 2018-08-21 05:45:47 -07:00
timer.c irq: Fix irq_lock api usage 2018-08-16 19:47:41 -07:00
userspace_handler.c syscalls: remove policy from handler checks 2018-05-17 23:34:03 +03:00
userspace.c kernel: Explicitly ignoring memcpy return 2018-08-16 19:47:41 -07:00
version.c kernel: version: no need to store version in RAM 2017-09-07 16:34:50 -07:00
work_q.c irq: Fix irq_lock api usage 2018-08-16 19:47:41 -07:00