From patchwork Mon Feb 10 21:16:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 24430 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 871FF20143 for ; Mon, 10 Feb 2014 21:16:53 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf14359305qac.8 for ; Mon, 10 Feb 2014 13:16:52 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=w4lwdraf/RZTrho2PrHedfVWpfiPjsKL17nCPcRFPAk=; b=Xam+HKFYLMRo9y3y+ICx36nsWMWsdGHqWkA45uG0WGh69kT1iAcGpo5I7QTnyFZskY 2RVtKOWL2bzj4q/VOD9L1eMSWOuJSEdA8ny1rbLXUnxWvlPBQi8HZU9RpRGBRASsX14A cqB+EUT8p7I6A/u3LXBCK5CP0HEGyYSSW/iS1dUCGii9rdy5nCmuvBi1DtrSHkrhR8aW MHhmICglgM7GgAfbPqnMIUDhrG1INj386ZhDvT2zF6bADyoWJgIlwPt6XYHpBDfNcGeT ndsDPiaAnKqAMnKsdAWyt+uG7TZlRcTUfnznyy/BoEiVqyjOUPG9f4cSEZPbMPC7QMTA Visg== X-Gm-Message-State: ALoCoQnFe3NWZvg8bwt3B3uWL9EPLE3c4tPr6ERraYLMIvdhMuAKUPGcpxTCBQV7XUEpoDh0nlJa X-Received: by 10.236.137.12 with SMTP id x12mr10301557yhi.17.1392067012504; Mon, 10 Feb 2014 13:16:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.133 with SMTP id n5ls2213845qgd.64.gmail; Mon, 10 Feb 2014 13:16:52 -0800 (PST) X-Received: by 10.52.164.39 with SMTP id yn7mr6769045vdb.25.1392067012344; Mon, 10 Feb 2014 13:16:52 -0800 (PST) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id tt2si5147926vdc.87.2014.02.10.13.16.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 13:16:52 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id c14so5523193vea.3 for ; Mon, 10 Feb 2014 13:16:52 -0800 (PST) X-Received: by 10.52.155.66 with SMTP id vu2mr63078vdb.50.1392067012197; Mon, 10 Feb 2014 13:16:52 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp198282vcz; Mon, 10 Feb 2014 13:16:51 -0800 (PST) X-Received: by 10.66.102.39 with SMTP id fl7mr27804987pab.43.1392067002398; Mon, 10 Feb 2014 13:16:42 -0800 (PST) Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by mx.google.com with ESMTPS id n8si16635884pax.189.2014.02.10.13.16.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 13:16:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.178 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.178; Received: by mail-pd0-f178.google.com with SMTP id y13so6596671pdi.23 for ; Mon, 10 Feb 2014 13:16:42 -0800 (PST) X-Received: by 10.66.218.234 with SMTP id pj10mr1067212pac.156.1392067001962; Mon, 10 Feb 2014 13:16:41 -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 bc4sm45674905pbb.2.2014.02.10.13.16.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 13:16:41 -0800 (PST) From: John Stultz To: stable Cc: Colin Cross , John Stultz Subject: [PATCH 3/3] 3.4.y: timekeeping: fix 32-bit overflow in get_monotonic_boottime Date: Mon, 10 Feb 2014 13:16:29 -0800 Message-Id: <1392066989-5113-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392066989-5113-1-git-send-email-john.stultz@linaro.org> References: <1392066989-5113-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Colin Cross get_monotonic_boottime adds three nanonsecond values stored in longs, followed by an s64. If the long values are all close to 1e9 the first three additions can overflow and become negative when added to the s64. Cast the first value to s64 so that all additions are 64 bit. Signed-off-by: Colin Cross [jstultz: Fished this out of the AOSP commong.git tree. This was fixed upstream in v3.6 by ec145babe754f9ea1079034a108104b6001e001c] 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 59b8966..32f0cb8 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1197,7 +1197,7 @@ void get_monotonic_boottime(struct timespec *ts) } while (read_seqretry(&timekeeper.lock, seq)); set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec, - ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec + nsecs); + (s64)ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec + nsecs); } EXPORT_SYMBOL_GPL(get_monotonic_boottime);