From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F5CBC433E2 for ; Fri, 17 Jul 2020 14:06:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D94A22B49 for ; Fri, 17 Jul 2020 14:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594994762; bh=JESx7qOGoSMwajK8A+uKWD0Dl16XVysyJGtAAJzP2UU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NA6Q5zAZN29K8AQuPw1Rvqq4U31ND38QVKhqITit4lX5/dpTH8kv9vQXWUVL1B5cy LLa0ndf8X1RrYW4xz6NQJ7PbCbjEdK/Lh31Cg9UcgtTa1Ng0WCFIhypT5PSVtNVBad wJaFRdu00qskuMjLXwnKD+7/D8C/X0QHGuActwhc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbgGQOGC (ORCPT ); Fri, 17 Jul 2020 10:06:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:54044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgGQOF7 (ORCPT ); Fri, 17 Jul 2020 10:05:59 -0400 Received: from lenoir.home (lfbn-ncy-1-317-216.w83-196.abo.wanadoo.fr [83.196.152.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB22122B48; Fri, 17 Jul 2020 14:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594994759; bh=JESx7qOGoSMwajK8A+uKWD0Dl16XVysyJGtAAJzP2UU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PvbyXeSQOJxoCb3JTLslF1ngeA1wHueZ2VlP1YLKBvtG5X8RM5CXRGNi1vANgRzfY 0+6daIZtP0aiOp8OCzKyhL09FO/S4tNT1Y0wNRWsAf4dq9zkt8suvPJgsJLfYinHs6 8rzPcjju3xXHFOy8aqvUZR//0dpojz+mu9hT4UEw= From: Frederic Weisbecker To: Thomas Gleixner , Anna-Maria Behnsen Cc: LKML , Frederic Weisbecker , Peter Zijlstra , Juri Lelli , stable@vger.kernel.org Subject: [PATCH 01/12] timer: Fix wheel index calculation on last level Date: Fri, 17 Jul 2020 16:05:40 +0200 Message-Id: <20200717140551.29076-2-frederic@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200717140551.29076-1-frederic@kernel.org> References: <20200717140551.29076-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org When an expiration delta falls into the last level of the wheel, we want to compare that delta against the maximum possible delay and reduce our delta to fit in if necessary. However instead of comparing the delta against the maximum, we are comparing the actual expiry against the maximum. Then instead of fixing the delta to fit in, we set 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. Fixes: 500462a9de65 ("timers: Switch to a non-cascading wheel") Signed-off-by: Frederic Weisbecker Cc: Peter Zijlstra Cc: Anna-Maria Behnsen Cc: Juri Lelli Cc: Thomas Gleixner Cc: stable@vger.kernel.org --- kernel/time/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 9a838d38dbe6..df1ff803acc4 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -521,8 +521,8 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk) * Force expire obscene large timeouts to expire at the * capacity limit of the wheel. */ - if (expires >= WHEEL_TIMEOUT_CUTOFF) - expires = WHEEL_TIMEOUT_MAX; + if (delta >= WHEEL_TIMEOUT_CUTOFF) + expires = clk + WHEEL_TIMEOUT_MAX; idx = calc_index(expires, LVL_DEPTH - 1); } -- 2.26.2