Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3514804yba; Tue, 16 Apr 2019 13:02:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqznSdz1pEUHTl7sOJDDEqtUyy7brDbuDYF3mD300bY/7nPFCf7tt8qFOigOGsc/J+OkU76Y X-Received: by 2002:a62:6504:: with SMTP id z4mr85252179pfb.202.1555444926222; Tue, 16 Apr 2019 13:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555444926; cv=none; d=google.com; s=arc-20160816; b=mSAElNUrRRb8XsTRQDnYbCPXdJTPmW9htnYHg+9E7DyGH2L57uOeVvAHCwVqmsHS+f n4qhmubag09+PlClqQY79BrOHuJvdUSFuR61Y5lFGmd2rqgrv/I+LF5RkYNId7PItqyD ZPlH0wVA9fuE9k0bPBuXu6e5ByPppW3SqHxuI05BHmBB59iCGQ0KavG5dHGsR0FB6FTR tu79Y5VqXtsPtr+RL6Yukhk56k9LO6OM+b1aOaR05jg+h9Nx7y1+zVd0Bar6wXB20gKp EDKWZ6xl1K+YQOQ45VNneKRv/uz6mXz94CyNgVQqqL5cz2JAJDAoh3ZZhNUbgNrbMTpt hxdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=KgESMitoEOHH6GkInJyO3YSkEH7XwwlMPN3n+NFZ94A=; b=H49m35+dPKdPSJH1FZJQ0yC6ivvE6qmApRIWyIlVGXMLdGOrWOf2mZFbZTsPDCsAUf +GR8NJ7hvL+jTZ0A/b0nOK+mAch+ogq55C0XGFDNf55NcOnKVB4MliysB6XuItZcCbq8 /xJKl4SRG6LzraTIgKcmdaK+cVfPnP3wvQsZwS2mJfiqFrbvIzMcxzEWor+epIDPXOZA CZ1rTEzVfvbXz09RZZ+MWjs7DWsiSoyn90LV+FiHmBe4u7l5tfMuA/h8wodSFkLi/dkt MqXptQY5SAIWP9W12OsrIF655+sbGn1DDzbDYxksUVyUenoMBDhVBEH+4YsQFFKraEDz DIyQ== ARC-Authentication-Results: i=1; mx.google.com; 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 x2si47822994pgh.231.2019.04.16.13.01.49; Tue, 16 Apr 2019 13:02:06 -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; 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 S1730293AbfDPT7x (ORCPT + 99 others); Tue, 16 Apr 2019 15:59:53 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:50480 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbfDPT7x (ORCPT ); Tue, 16 Apr 2019 15:59:53 -0400 Received: from pd9ef12d2.dip0.t-ipconnect.de ([217.239.18.210] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hGUFB-0002zU-7U; Tue, 16 Apr 2019 21:59:49 +0200 Date: Tue, 16 Apr 2019 21:59:48 +0200 (CEST) From: Thomas Gleixner To: Miroslav Lichvar cc: Ondrej Mosnacek , Roman Zippel , John Stultz , Stephen Boyd , Andrew Morton , Linux kernel mailing list Subject: Re: kernel/time/ntp.c: Possible off-by-one error in TAI range check? In-Reply-To: <20190415085641.GI28203@localhost> Message-ID: References: <20190415085641.GI28203@localhost> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Apr 2019, Miroslav Lichvar wrote: > On Mon, Apr 15, 2019 at 10:09:43AM +0200, Thomas Gleixner wrote: > > > On Mon, Apr 8, 2019 at 10:47 AM Ondrej Mosnacek wrote: > > > > Commit 153b5d054ac2 ("ntp: support for TAI") added a possibility to > > > > change the TAI offset from userspace via adjtimex(2). The code checks > > > > if the input value (txc->constant) is greater than 0 and if it is not, > > > > then it doesn't modify the value. Ignoring the fact that this check > > > > should probably be in timekeeping_validate_timex() and cause -EINVAL > > > > to be returned when false, I find it strange that the check doesn't > > > > allow to set the value to 0, which seems to be the default value... > > > > > > > > Was this behavior intended or should the code actually check for > > > > txc->constant >= 0 instead of txc->constant > 0? > > I guess zero here means "unknown" and maybe the intention was to not > allow setting the offset to an unknown value once it has been set to a > valid value. The trouble is that after inserting a leap second the > offset may change from zero to one. > > I think it should be changed to allow setting the offset to zero. Can someone please send a patch with a coherent changelog? Thanks, tglx