From patchwork Tue Nov 25 04:35:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 41449 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 427D225AEA for ; Tue, 25 Nov 2014 04:40:30 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id k14sf6109525wgh.0 for ; Mon, 24 Nov 2014 20:40:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=sJP0XJhLWZzlsKdGd4TNMe60r+Ei7wkH5V6AUXaqJFo=; b=LbEKHGtAVyAxfAi2enuVKufg4ROkXXdwGtsk+DARIdnOjfhfXLrf7uZ5+p5jPA3YPo bfVeALfykfbTOf7QFqe5s3D6bAmiuQKe/pZIP/7KczGywDPJFinsP6+2i6YzDN+6dfBA E71Iy8C4t6Cm35HXpNIgl2MWx3etjCPD4yI6nGvKeZRvWmWrMtfy1ASy9BeW3p0wLzrA CTV+AZLM5Ezkc7O1uo0z7x/B4amdwFipdemsDIuVhz0v+gHkPPEq+fKwVhBIOGyaGlFA MqSnhTV63ZQD6NvdFg2hvYjGTCK/vDsazAyOwjSH2S0boTBZ+0e/gCrquwou0XGLiH8K ViCA== X-Gm-Message-State: ALoCoQlNvbTngj5JdK1uaIjEFpOdCFbj+HT+jqxm0SMuYqvgp2bjHVpGsOsAw9do3RK4al9/7QVO X-Received: by 10.194.133.39 with SMTP id oz7mr7114210wjb.3.1416890429591; Mon, 24 Nov 2014 20:40:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.193 with SMTP id d1ls486526lah.85.gmail; Mon, 24 Nov 2014 20:40:28 -0800 (PST) X-Received: by 10.112.235.135 with SMTP id um7mr23112140lbc.96.1416890428791; Mon, 24 Nov 2014 20:40:28 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id p7si56316lae.87.2014.11.24.20.40.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 20:40:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so5571534lbd.20 for ; Mon, 24 Nov 2014 20:40:28 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr23595093lbc.66.1416890428668; Mon, 24 Nov 2014 20:40:28 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp377062lbc; Mon, 24 Nov 2014 20:40:27 -0800 (PST) X-Received: by 10.70.51.232 with SMTP id n8mr27133480pdo.9.1416890174222; Mon, 24 Nov 2014 20:36:14 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fn7si88502pad.65.2014.11.24.20.36.04 for ; Mon, 24 Nov 2014 20:36:13 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752053AbaKYEgC (ORCPT + 26 others); Mon, 24 Nov 2014 23:36:02 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:55522 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbaKYEgA (ORCPT ); Mon, 24 Nov 2014 23:36:00 -0500 Received: by mail-pa0-f53.google.com with SMTP id kq14so10977080pab.12 for ; Mon, 24 Nov 2014 20:36:00 -0800 (PST) X-Received: by 10.68.189.100 with SMTP id gh4mr17427708pbc.17.1416890153600; Mon, 24 Nov 2014 20:35:53 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id se3sm124135pbc.24.2014.11.24.20.35.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Nov 2014 20:35:52 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , "pang.xunlei" , Fengguang Wu , Thomas Gleixner , Ingo Molnar Subject: [PATCH] time: Fix sign bug in ntp mult overflow warning Date: Mon, 24 Nov 2014 20:35:45 -0800 Message-Id: <1416890145-30048-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20141122184506.GC29361@wfg-t540p.sh.intel.com> References: <20141122184506.GC29361@wfg-t540p.sh.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In commit 6067dc5a8c2b ("time: Avoid possible NTP adjustment mult overflow") a new check was added to watch for adjustments that could cause a mult overflow. Unfortunately the check compares a signed with unsigned value and ignored the case where the adjustment was negative, which causes spurious warn-ons on some systems (and seems like it would result in problematic time adjustments there as well, due to the early return). Thus this patch adds a check to make sure the adjustment is positive before we check for an overflow, and resovles the issue in my testing. Cc: pang.xunlei Cc: Fengguang Wu Cc: Thomas Gleixner Cc: Ingo Molnar Reported-by: Fengguang Wu Debugged-by: pang.xunlei Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 29a7d67..2dc0646 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1330,7 +1330,7 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk, * * XXX - TODO: Doc ntp_error calculation. */ - if (tk->tkr.mult + mult_adj < mult_adj) { + if ((mult_adj > 0) && (tk->tkr.mult + mult_adj < mult_adj)) { /* NTP adjustment caused clocksource mult overflow */ WARN_ON_ONCE(1); return;