Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1347585

[PATCH 3.14 103/130] cputime: Prevent 32bit overflow in time[val|spec]_to_cputime()

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 3.14 103/130] cputime: Prevent 32bit overflow in time[val|spec]_to_cputime()
Date Wed, 02 Mar 2016 03:00:04 +0100
Message-ID <r84f2-EO-53@gated-at.bofh.it> (permalink)
References <r82dd-7Iy-13@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; s=mandrill; d=linuxfoundation.org; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; i=gregkh@linuxfoundation.org; bh=mhJhpZ5BpwB6HClQ2Zli4P6qJ6A=; b=n0P/8ljf1liy9SLNqAytQPnhmiu0RG9A9a+xisU9DnoHudoyJI/L0zRMnC59PPUsVniP4zGxOmcq YWu+1aK32k/S8dXFjr2lwHK/vUUmjpkBI31qPvDF2jaFesqIU1UWXuuwUc8OH3ZcvVxndiBN453F W2YDZlt4efVOL2B4yU0=
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; i=@mandrillapp.com; q=dns/txt; s=mandrill; t=1456876414; h=From : Subject : To : Cc : Message-Id : In-Reply-To : References : Date : MIME-Version : Content-Type : Content-Transfer-Encoding : From : Subject : Date : X-Mandrill-User : List-Unsubscribe; bh=mtLwNuxX8Ez8M6wyaB4+bSCxbSIE3P8hGetn+PZ/Jok=; b=pwukDzj1+oKcAGc3bTr+7JWbX4jKSjn5MJ9Jn5f6KJgkqWx8o66TJJmmWY8d4KZLZe+NSW eOtap2kj+r0yIZXfNLmqgo5vjU80gbbkGlNflAedbi5clGNqepWOBBa8Ievcrq/IHD+K6pCI 6bApk9SkEAO0v6nN8k17l+kgqJ7ME=
X-Mailer git-send-email 2.7.2
X-Report-Abuse Please forward a copy of this message, including all headers, to abuse@mandrill.com
X-Report-Abuse You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.0cb9b12fd3b84806b29e860d0306b4dd
X-Mandrill-User md_30481620
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 54
Organization linux.* mail to news gateway
X-Original-Cc Greg Kroah-Hartman <gregkh@linuxfoundation.org>, <stable@vger.kernel.org>, zengtao <prime.zeng@huawei.com>, Arnd Bergmann <arnd@arndb.de>, <fweisbec@gmail.com>, Thomas Gleixner <tglx@linutronix.de>
X-Original-Date Tue, 01 Mar 2016 23:53:34 +0000
X-Original-Message-ID <20160301234503.457980886@linuxfoundation.org>
X-Original-References <20160301234459.768886030@linuxfoundation.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1347585

Show key headers only | View raw


3.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: zengtao <prime.zeng@huawei.com>

commit 0f26922fe5dc5724b1adbbd54b21bad03590b4f3 upstream.

The datatype __kernel_time_t is u32 on 32bit platform, so its subject to
overflows in the timeval/timespec to cputime conversion.

Currently the following functions are affected:
1. setitimer()
2. timer_create/timer_settime()
3. sys_clock_nanosleep

This can happen on MIPS32 and ARM32 with "Full dynticks CPU time accounting"
enabled, which is required for CONFIG_NO_HZ_FULL.

Enforce u64 conversion to prevent the overflow.

Fixes: 31c1fc818715 ("ARM: Kconfig: allow full nohz CPU accounting")
Signed-off-by: zengtao <prime.zeng@huawei.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Cc: <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1454384314-154784-1-git-send-email-prime.zeng@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/asm-generic/cputime_nsecs.h |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/include/asm-generic/cputime_nsecs.h
+++ b/include/asm-generic/cputime_nsecs.h
@@ -70,7 +70,7 @@ typedef u64 __nocast cputime64_t;
  */
 static inline cputime_t timespec_to_cputime(const struct timespec *val)
 {
-	u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_nsec;
+	u64 ret = (u64)val->tv_sec * NSEC_PER_SEC + val->tv_nsec;
 	return (__force cputime_t) ret;
 }
 static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
@@ -86,7 +86,8 @@ static inline void cputime_to_timespec(c
  */
 static inline cputime_t timeval_to_cputime(const struct timeval *val)
 {
-	u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_usec * NSEC_PER_USEC;
+	u64 ret = (u64)val->tv_sec * NSEC_PER_SEC +
+			val->tv_usec * NSEC_PER_USEC;
 	return (__force cputime_t) ret;
 }
 static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val)

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 3.14 103/130] cputime: Prevent 32bit overflow in time[val|spec]_to_cputime() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-03-02 03:00 +0100

csiph-web