Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1119304ybi; Fri, 2 Aug 2019 09:35:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLl1MAY08veZis6Lf1KD9JCL2n+vnORvutdcNrokiBK1AE5NN8R3fMcuuEg6FIoDjy+wcg X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr2987142plq.223.1564763720311; Fri, 02 Aug 2019 09:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564763720; cv=none; d=google.com; s=arc-20160816; b=q3q6nTf1EFqxP/OfWA5B5DE+gWhyRaM8ekAY/kHnK/7oYS+IXdaX7vMiT4hWrQh0FC cedHv2UhV9T4wRxiTRYg0UQVmfA93W+e2muPv9vfHhaRCFvTCTSFdB+yv7cqdI1vuIQc G/A5XCTz8GgA9IAlI0AsSOPcBUE5vRPf2fj4HjHLA0gJisofrwIX2c+fNHV+2yCWzvu8 x+aH/QeZKLA6civSIqtRZYtWuYR3R7CqTFR/oft+AA2lQUt/PRz1qcrB4O7HLSzGkmv0 vfyR1rr8CesKCK5dvE2mLTxBGVP0gU/b8b8IsMlco43JTEm95+L8vtvny8ytIck3jbLu l4YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=r1v7goHhDBq3jRQ6dAIa9REvFe75p7jKGfUoW5UprYQ=; b=KZxsx1Env5kTABnz0rCFKdgG7xfoWnPEI5aWLT85O8P5oG9QB4F814F+DGBfL+MPFG zIvuEIxosEAL3SXmW8iOK1o83CcpUHkTL+aIZfX1f9uxbZqfeujVa8W4e7cRdCia/Gie dFlNp9VHonQTdEgRZFPP+ymlw+IX+r/ZcMobPofo7xsLebU7/2FFP9RVuM5JhMX3kqJX GfOSsgs7E8eF0aUxaZSv4bWZmlBIgYglnxKPkXmsoKjFdFjV/jpHHpiXv34wdUptmkp+ B9VoHBrrBibafywusgdcTVDZf0UyXiPuVfAoejCuP/gbBfNY8my84tkTH7R5v9wcpGnb 2j8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hb9cihbu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b22si7107944pjb.82.2019.08.02.09.35.05; Fri, 02 Aug 2019 09:35:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hb9cihbu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391855AbfHBJmX (ORCPT + 99 others); Fri, 2 Aug 2019 05:42:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:44636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391528AbfHBJmV (ORCPT ); Fri, 2 Aug 2019 05:42:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 8E6AD2086A; Fri, 2 Aug 2019 09:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738941; bh=QbOzhcvweciA9gWRmPyRlKa3MlVNXQiRlmUhiobmx3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hb9cihbuUa89Xa50BPb2D1LvVjv4h8MpPWundt1odfdN4JHelPEwo1JvfgzE0fq0a lsHQdTTwvweNzxBvZBgcAFrJRJ7f88p5LrWFXnpex+PcZWT0K1FmOKtGaD13JyFIFr SknnVciFqM0lmc02vk9nsl3SXws7Z0yjWgGlEeM0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Weikang shi , Miroslav Lichvar , Thomas Gleixner , John Stultz , Prarit Bhargava , Richard Cochran , Stephen Boyd , Sasha Levin Subject: [PATCH 4.9 047/223] ntp: Limit TAI-UTC offset Date: Fri, 2 Aug 2019 11:34:32 +0200 Message-Id: <20190802092241.975022524@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d897a4ab11dc8a9fda50d2eccc081a96a6385998 ] Don't allow the TAI-UTC offset of the system clock to be set by adjtimex() to a value larger than 100000 seconds. This prevents an overflow in the conversion to int, prevents the CLOCK_TAI clock from getting too far ahead of the CLOCK_REALTIME clock, and it is still large enough to allow leap seconds to be inserted at the maximum rate currently supported by the kernel (once per day) for the next ~270 years, however unlikely it is that someone can survive a catastrophic event which slowed down the rotation of the Earth so much. Reported-by: Weikang shi Signed-off-by: Miroslav Lichvar Signed-off-by: Thomas Gleixner Cc: John Stultz Cc: Prarit Bhargava Cc: Richard Cochran Cc: Stephen Boyd Link: https://lkml.kernel.org/r/20190618154713.20929-1-mlichvar@redhat.com Signed-off-by: Sasha Levin --- kernel/time/ntp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 0a16419006f3..4bdb59604526 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -42,6 +42,7 @@ static u64 tick_length_base; #define MAX_TICKADJ 500LL /* usecs */ #define MAX_TICKADJ_SCALED \ (((MAX_TICKADJ * NSEC_PER_USEC) << NTP_SCALE_SHIFT) / NTP_INTERVAL_FREQ) +#define MAX_TAI_OFFSET 100000 /* * phase-lock loop variables @@ -639,7 +640,8 @@ static inline void process_adjtimex_modes(struct timex *txc, time_constant = max(time_constant, 0l); } - if (txc->modes & ADJ_TAI && txc->constant >= 0) + if (txc->modes & ADJ_TAI && + txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET) *time_tai = txc->constant; if (txc->modes & ADJ_OFFSET) -- 2.20.1