From da30fdf96a9cea38ca4fe8ffad92896a901af002 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 5 Jan 2018 22:22:02 +0100 Subject: [PATCH] kernel: Fix overflow in load tracking for very large deltas. The scheduler uses the load tracking logic to compute the load of threads to be enqueued into the run queue. The time delta between the last enqueue and the next enqueue may grow very large for threads that mostly wait on conditions. In such cases the int "n" period count variable would become too small and wrap around, leading to an assertion failure. For this to happen, the thread in question would have to have slept for at least ~25 days and then wake up. Threads often affected would be ones waiting for some other process to end, for example shell threads waiting for a long running process to exit. Fixes #13558. --- headers/private/kernel/load_tracking.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headers/private/kernel/load_tracking.h b/headers/private/kernel/load_tracking.h index 1c68a46de5..d82ab552be 100644 --- a/headers/private/kernel/load_tracking.h +++ b/headers/private/kernel/load_tracking.h @@ -39,7 +39,7 @@ compute_load(bigtime_t& measureTime, bigtime_t& measureActiveTime, int32& load, measureTime = now; deltaTime += kIntervalInaccuracy; - int n = deltaTime / kLoadMeasureInterval; + bigtime_t n = deltaTime / kLoadMeasureInterval; ASSERT(n > 0); if (n > 10)