Message ID | 20201117122111.239433205@linuxfoundation.org |
---|---|
State | Superseded |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a17:906:d156:0:0:0:0 with SMTP id br22csp4948804ejb; Tue, 17 Nov 2020 05:15:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDoN9j4wJshJJX0a75wpZMNQA67vvnAZ+MQsrZo1uNz0klIH0Ncx00WS4/QhkPSv6ubdGI X-Received: by 2002:a17:906:e285:: with SMTP id gg5mr19623147ejb.7.1605618939253; Tue, 17 Nov 2020 05:15:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605618939; cv=none; d=google.com; s=arc-20160816; b=QojwVdM83nCsbN2IeSd3//iX6k70FJ5PkDZXJwLBhS6XPyHDsYXlpj8TuqS52tkUxa GofKLYnh4+we4onV7v2UZGzth85wTxEC2Of/8nahN4nBc2B3MLj7xFEHGpVQ7RmXjEGo FaHTxKWOgAM86syBq/OCvfy6OKQSZq9QBaBOUKd5A+duCnHXhEqubzkerOgn27iEBVxg yWPhx0SOvA7YUH1bkdwDyf1o6qvxkZmL989SisVUyhU0z5RKPDXcl25Inc8LK2EHIaef 54e4ksVULozIH7Na6uh+vwVO1jd5Dg21Saw2sUhTvLO/+0Ypv+qO92p+NRKdzsTfBmdr cpSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9rAdvwsLPcaeP46DGRlP1kVkbq2Fage/o4B6S3j5wsk=; b=gIQzJDGMpoGIf3+HaF1vb2Rf80C24Yl9L0KhHWXQ3vbeaV8zuwt0gFVtAUnq37j+Q/ lHgX71MK6JiROsQ49fGcc+edoi7b4SK28OjIz/VRt9lbJMBGd0b72VjmnTAzRgjKXeS4 zYujqXt5mhOKjAACk4nWwUCg1NFjgTF5RimYKvxUPaSx+q1rajpsXVoMWJeHrilLwI9o AjPJ+Nhu3J/n3tp2NlbOfb1nNht8btzT/hOzKj8zjWKaLak1/6+x+fV7iXRFV9P0YP/l s4kFDnplHDVqIfFtgSV23ppHPDiVAI7/cz8BL68j7ckU9XSmBtXG/1LhRfyU8jFpuOCc D8cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fE5NMp3W; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: <stable-owner@vger.kernel.org> Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si13271516ejc.81.2020.11.17.05.15.38; Tue, 17 Nov 2020 05:15:39 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fE5NMp3W; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728955AbgKQNOa (ORCPT <rfc822;semen.protsenko@linaro.org> + 14 others); Tue, 17 Nov 2020 08:14:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:45286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730049AbgKQNOZ (ORCPT <rfc822;stable@vger.kernel.org>); Tue, 17 Nov 2020 08:14:25 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E5C2124199; Tue, 17 Nov 2020 13:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618864; bh=nDLzIC3PMwi5RFCptIFIID9du6F4ViMDbe2cyj0h2FY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fE5NMp3W6PY9GqpjaKrIDI7LkKLIlTsow4zzjyODSYmK0KdAUH8osaqGl+Bhg6vpB //M9wuJ9Vy7tPTu/kQKzKq9dm8Zc+A6MMmttZmCTDV+29VxVhmC9KZWRTo8fZAGAXd TfXyEqKVS1c1rQMA9s4TlaWqPG65cVQ6+mYOnbSY= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Zeng Tao <prime.zeng@hisilicon.com>, Thomas Gleixner <tglx@linutronix.de>, Arnd Bergmann <arnd@arndb.de>, Sasha Levin <sashal@kernel.org> Subject: [PATCH 4.14 04/85] time: Prevent undefined behaviour in timespec64_to_ns() Date: Tue, 17 Nov 2020 14:04:33 +0100 Message-Id: <20201117122111.239433205@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
diff --git a/include/linux/time64.h b/include/linux/time64.h index ad33260618f76..99ab4a686c301 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -189,6 +189,10 @@ static inline bool timespec64_valid_strict(const struct timespec64 *ts) */ static inline s64 timespec64_to_ns(const struct timespec64 *ts) { + /* Prevent multiplication overflow */ + if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX) + return KTIME_MAX; + return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec; } diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c index f26acef5d7b48..7f718565507b5 100644 --- a/kernel/time/itimer.c +++ b/kernel/time/itimer.c @@ -153,10 +153,6 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, u64 oval, nval, ointerval, ninterval; struct cpu_itimer *it = &tsk->signal->it[clock_id]; - /* - * Use the to_ktime conversion because that clamps the maximum - * value to KTIME_MAX and avoid multiplication overflows. - */ nval = ktime_to_ns(timeval_to_ktime(value->it_value)); ninterval = ktime_to_ns(timeval_to_ktime(value->it_interval));