When an expiration delta falls into the last level of the wheel, that delta has be compared against the maximum possible delay and reduced to fit in if necessary. However instead of comparing the delta against the maximum, the code compares the actual expiry against the maximum. Then instead of fixing the delta to fit in, it sets the maximum delta as the expiry value. This can result in various undesired outcomes, the worst possible one being a timer expiring 15 days ahead to fire immediately.
Unified · Split
| @@ -521,8 +521,8 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk) · 520 unmodified lines | |||
| 521 | * Force expire obscene large timeouts to expire at the | 521 | * Force expire obscene large timeouts to expire at the |
| 522 | * capacity limit of the wheel. | 522 | * capacity limit of the wheel. |
| 523 | */ | 523 | */ |
| 524 | if (expires >= WHEEL_TIMEOUT_CUTOFF) | 524 | if (delta >= WHEEL_TIMEOUT_CUTOFF) |
| 525 | expires = WHEEL_TIMEOUT_MAX; | 525 | expires = clk + WHEEL_TIMEOUT_MAX; |
| 526 | 526 | ||
| 527 | idx = calc_index(expires, LVL_DEPTH - 1); | 527 | idx = calc_index(expires, LVL_DEPTH - 1); |
| 528 | } | 528 | } |