Message ID | 20201117122113.240871219@linuxfoundation.org |
---|---|
State | New |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp4189214ils; Tue, 17 Nov 2020 06:00:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrOrw9Q01CIy1MIQQMUKecWruOYrLiYP6MSHmH/Srcm/5My1eR2YI/aOcuHe4gP84s6hQr X-Received: by 2002:a17:906:1390:: with SMTP id f16mr19490106ejc.504.1605621599905; Tue, 17 Nov 2020 05:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621599; cv=none; d=google.com; s=arc-20160816; b=GLtAksj3O1uWzLC1v2Q7c6WYvxkek6+K/MuDxfPfroCe9X2uW5xhgW+2M3COF0OYqZ /lykBCxGPl4ba9YvupzSqd4qYDPxenurCVVN4tebApN/qZ0eSD3cxuzbwHlG0hvbsFBd cv9ZqkQ1GuezHaBUOEPR4wgzsMszOnx0L3dDWZvGZWYHwHEEki5nQLwLoS+j2wKQR/kx iFjJA4vfvOta7cH0M5KbBQJuvljp0jzweOBvVT9EiZ9wBaxdmdAABfUWMowDccPzHasC /xAFb7fb1g59RqJZLtQjrMH3aeKDawmBNnsnmK0fSnV4VnMBeX3L5Fij7aLsfEPufmmF Gv6g== 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=BO7u13kV7rMt6gdMOHUtuH3aD++jLMuxOyxSXetQ5Uw=; b=XX1hh3G8J50FQ0f9ihj0Y4N7zg6zG8aTMtCWos21l20mEJ3hKPMKWqwy6vP/y3KjzR 2YdziDXEPO9IOwoVH88t/M1S+5/l+4WjrmOAtLxC8W55bESMmUquwZlla8/mZh6N6qlD 2iIKWEY9YkPFdJ6kTJBOVpQVMkT6dYUonR0rX19WH4VfphMFUhH1ORK9L5OhZKd/baqD OL6OV3a62VDuKdcHB885FOk0/t8f6+AEbG7w7lAtKwR7X+yYrHCuabuw7CCxzR1+UHqn htSjS4n/GYk3blOQ+SJGVwmHwxXQmatnVYIr9YinpvQX76L1JUJ3AWgOoC2QA0+UIlDz /olg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=abl63Hpj; 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 jz19si3146998ejb.238.2020.11.17.05.59.59; Tue, 17 Nov 2020 05:59:59 -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=abl63Hpj; 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 S1730560AbgKQNR1 (ORCPT <rfc822;semen.protsenko@linaro.org> + 14 others); Tue, 17 Nov 2020 08:17:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:49716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730557AbgKQNR1 (ORCPT <rfc822;stable@vger.kernel.org>); Tue, 17 Nov 2020 08:17:27 -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 EF738206D5; Tue, 17 Nov 2020 13:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619046; bh=QgDgQ4frAwnB+dR6pI1lZLkBY0lciBNMnTt8BjZaNog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abl63HpjTdlQwx04jSe/YLSzyrHUJG5hlqt8MRSjgPmIvRIc9lkY05uCb8wkQKn24 q1FhnW9725Qq89brzzmEfsh4Ekn2fhUWf3VQE2U/fQTeJtMiLJqTqm+sASV1ThHgPM 3gHMOMShS0DGKBWNBNjSzba3h4Nv/MDLJPUHakmg= 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.19 002/101] time: Prevent undefined behaviour in timespec64_to_ns() Date: Tue, 17 Nov 2020 14:04:29 +0100 Message-Id: <20201117122113.240871219@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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 4a45aea0f96e9..8dbdf6cae3e8b 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -138,6 +138,10 @@ static inline bool timespec64_valid_settod(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 9a65713c83093..2e2b335ef1018 100644 --- a/kernel/time/itimer.c +++ b/kernel/time/itimer.c @@ -154,10 +154,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));