Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751166AbdHAHMB (ORCPT ); Tue, 1 Aug 2017 03:12:01 -0400 Received: from mail-ve1eur01on0139.outbound.protection.outlook.com ([104.47.1.139]:28642 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750763AbdHAHL7 (ORCPT ); Tue, 1 Aug 2017 03:11:59 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matija.glavinic-pecotic.ext@nokia.com; To: khilman@baylibre.com, tglx@linutronix.de, mingo@kernel.org, akpm@linux-foundation.org, hpa@zytor.com, linux-kernel@vger.kernel.org From: Matija Glavinic Pecotic Subject: [PATCH] timers: Fix overflow in get_next_timer_interrupt Cc: "Sverdlin, Alexander (Nokia - DE/Ulm)" Message-ID: Date: Tue, 1 Aug 2017 09:11:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [94.253.243.240] X-ClientProxiedBy: VI1PR0801CA0085.eurprd08.prod.outlook.com (2603:10a6:800:7d::29) To HE1PR07MB1098.eurprd07.prod.outlook.com (2a01:111:e400:535f::20) X-MS-Office365-Filtering-Correlation-Id: 3a8b9b79-9a63-4e77-171a-08d4d8ac9896 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:HE1PR07MB1098; X-Microsoft-Exchange-Diagnostics: 1;HE1PR07MB1098;3:/ZiIqzodH8yPaZwZhUA9y9wD08hgjJzBJp1+b5l4QzWzTu2HasmaY/Wy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QCI3jbGUAJNKZtYr+bLs9ocaIO2mVOwKgk1E8iSYxYHk9eTjYg6uasLa1ovnAhD48lze8vEy4BAi9N0etRQev5n9Q6J4mZfJPAv6gTSLByBQyQkvHxfXBuuVAu91F53OdXj/0ShHFrGVWvPvzxVmT32p8qIjowzxYEYfv120K7fo94f293v7Jd4qamfJzMqnNmryrIbTZsury4RTgBkN+u0OrBZBM4K2gElczR1de3e0bdUVANoeD1sP7j3AHPsDAqknfZM2+pXXtIZ4kBVyW9mZUoH3WNyBsp/m1G2I7o9Ig;4:ioBiu4c62iB1lgaW8CDDWhkJ8rvdT5FCrf6JJLgaqD4m9K98Xtqte8Bp7Apt+8OAahpGKzW1QMOiO3ByZSx3ujdUEzgONGWvi3u+vjvmSC+j6p5xTdjRB8pRxkx5RAZFDoY9ZBINoaJQFS+9w/pMN6b+4Gxx+Yz7/jeH5OYpO3reDH0RusDQwITv6YXeSBabLJLPwEovSmRiD0G/9A50lYvEeBZGrqzMl7sknFieQ+i/tSWE50bNXjwFTOAdheTpfqNgYCFitbPGfLL8/zYuTEIP1cS9cj560QJA9N2zPJE= X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(20161123555025)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR07MB1098;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR07MB1098; X-Forefront-PRVS: 0386B406AA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6049001)(6009001)(39450400003)(39860400002)(39410400002)(39850400002)(39840400002)(39400400002)(199003)(189002)(6116002)(3846002)(53936002)(6306002)(42186005)(77096006)(4001350100001)(83506001)(6486002)(6666003)(68736007)(64126003)(31686004)(2906002)(50986999)(117156002)(31696002)(105586002)(36756003)(86362001)(189998001)(101416001)(305945005)(4326008)(66066001)(478600001)(7736002)(966005)(5660300001)(23676002)(106356001)(47776003)(7350300001)(25786009)(33646002)(97736004)(50466002)(81156014)(81166006)(107886003)(110136004)(8676002)(38730400002)(230700001)(54356999);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR07MB1098;H:[192.168.0.13];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA3TUIxMDk4OzIzOkxRR2ZSRVBHMndHVk9FWG5uazdoQUo5SHAx?= =?utf-8?B?cjdQK1dzc214UDJlRlk1QWNQRkkxT1FJdUZheDEyVEtneEV2OVdhVGdMS21M?= =?utf-8?B?R0ZLVldJeHpiV2pBQ09kR2tsNzZ3d1JQK2FjMlRGcHlGVG94VmVzOVpRdkU4?= =?utf-8?B?R3diUHVFQlFkYzdNanh5cWN5bjgwOEVUTUdIV0tlb2FEd1doMWtsZW1PK1RN?= =?utf-8?B?THpvbXNONHpCeEdKTUp1RFY1VUNvZ285T2p6T1pWRWtabGRIaE9uVFJrRi9w?= =?utf-8?B?cUZFalFEZFJJUHJ1RTdpZEE2YmpPR2lMK3gyUU5YeWFpUStkVTRVbXhyYTRZ?= =?utf-8?B?bThiLy95UkdyMytkc0FvK2lDY0l5M3JrekdUZ3pQWmllYklCVW1KSk9ldjJP?= =?utf-8?B?MmNDZkpqTlRBRVRaZGdyWjRITmk1YXhaQnRSakQyRXZEVzlRYzNwQnlJdEdY?= =?utf-8?B?NlpRNnh3QUZ5THFGYmpYWGxIT3JIdFhhODJWM1QzSXZ0TzU5dzgyOWJkWkJv?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8a8/VlPYkYAkwJ3AeyrRSxhKBV07QCgGdhRrD1N5A==;24:J2g3HkM1qA4NDoW/yJdIyQIwvkBuUiym+yL18xh0mVdkEPd/hX1EtzVJ6jq1lKwV2i9bFEMvO2FRyNJfAYcllcjjCwFECrjIiuEdcVeug5k=;7:ZQn9zEdXPj8FRtAIu6kryTv/agPOYwVVl7iFVDMVWMcwIn33TDp+T6cZ06A25k64EJhyaR4vP77qq1EQzLnUKyfOsFAIbpCi12wNm3RimoLUzc3udfGMkcmKtDkWc1YMUpO/DIqfzONs7tiAQG8ZffU8+tWrHMabdJA5OQ14V72OBMGh2lXToR4rqfgNekyXQ2X9Iph7t0GaAm7a2eT19vFK1BAQOAVQoB+WQ5WdleA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2017 07:11:56.7030 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR07MB1098 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1007 Lines: 29 For e.g. HZ=100, timer being 430 jiffies in the future, and 32 bit unsigned int, there is an overflow on unsigned int right-hand side of the expression which results with wrong values being returned. Problem was observed on tickless core and with following applied: sched/nohz: add debugfs control over sched_tick_max_deferment https://lkml.org/lkml/2013/9/16/499 Signed-off-by: Matija Glavinic Pecotic --- kernel/time/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 71ce3f4..8f5d1bf 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1495,7 +1495,7 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) base->is_idle = false; } else { if (!is_max_delta) - expires = basem + (nextevt - basej) * TICK_NSEC; + expires = basem + (u64)(nextevt - basej) * TICK_NSEC; /* * If we expect to sleep more than a tick, mark the base idle: */ -- 2.1.4