From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13307C7618F for ; Wed, 24 Jul 2019 19:49:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9E7B21873 for ; Wed, 24 Jul 2019 19:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997751; bh=dDelXPV4V59tF9992+wE0ipVt2XvsPJAg7breuDYKS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0N2tgp/nLUGDzDHSQUDp2IHqlrIeLu3cFdxunNh6krrGl7aZ1o/S9/hXmUmQPtD2w g/xim6yQid6e3MSGLJ3m/qqK8WYXsW4CEZLwb/kQ7nBgpjYpJiSVT4LPB77W1Wb0En wcsVrZt7sLFjANDmuUUj/+WR7RSaLv3Vs59widho= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403946AbfGXTtJ (ORCPT ); Wed, 24 Jul 2019 15:49:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:57100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390638AbfGXTtJ (ORCPT ); Wed, 24 Jul 2019 15:49:09 -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 1F97C205C9; Wed, 24 Jul 2019 19:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997748; bh=dDelXPV4V59tF9992+wE0ipVt2XvsPJAg7breuDYKS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uiQRanXg026V/MqGajtvW71nvQ0qTlEYZPUcpt4PMfIZ6dXzuxdtLazv1L5xRiIF6 JYGerVJLj6ki60um719GatWyhzWotcpFDMK4B/BBgWvJcuzvXybTOkVCiSmsSzdHyq N8pqqVT/5SEqmNcD4KNqGsFrT5AuS7YN+7skAClE= 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 5.1 130/371] ntp: Limit TAI-UTC offset Date: Wed, 24 Jul 2019 21:18:02 +0200 Message-Id: <20190724191734.672735732@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 f43d47c8c3b6..98b3678fd48e 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 @@ -690,7 +691,8 @@ static inline void process_adjtimex_modes(const struct __kernel_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