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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 BF313C433F5 for ; Thu, 16 Sep 2021 09:12:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2462610A4 for ; Thu, 16 Sep 2021 09:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235175AbhIPJNj (ORCPT ); Thu, 16 Sep 2021 05:13:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:40106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235165AbhIPJNj (ORCPT ); Thu, 16 Sep 2021 05:13:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CCACD61108; Thu, 16 Sep 2021 09:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631783539; bh=jQYIRqs2aOJnPuLh7/xWhgGZj1/WGuhO3shpVt0IrBk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ojr0p/6iFYpEBqQJcGzCy250PQmsyBHJ92oSUn4Sfp41wMkIGqBFvfzJKP9U77omi 3fM63VG7ziMoUiGnw919DNrgVbP4qq4YKoHEX9Y4xLn4nlXXw0IVBD10Puf88TukD6 HO2LWeZiETDE3nUbkl71Ae54P0F2R1CwR+Iw6ywk= Date: Thu, 16 Sep 2021 11:12:17 +0200 From: Greg Kroah-Hartman To: Arnd Bergmann Cc: Linux Kernel Mailing List , "# 3.4.x" , Lukas Hannen , Thomas Gleixner Subject: Re: [PATCH 5.14 298/334] time: Handle negative seconds correctly in timespec64_to_ns() Message-ID: References: <20210913131113.390368911@linuxfoundation.org> <20210913131123.500712780@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, Sep 15, 2021 at 09:00:32PM +0200, Arnd Bergmann wrote: > On Tue, Sep 14, 2021 at 1:22 AM Greg Kroah-Hartman > wrote: > > /* > > * Limits for settimeofday(): > > @@ -124,10 +126,13 @@ static inline bool timespec64_valid_sett > > */ > > static inline s64 timespec64_to_ns(const struct timespec64 *ts) > > { > > - /* Prevent multiplication overflow */ > > - if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX) > > + /* Prevent multiplication overflow / underflow */ > > + if (ts->tv_sec >= KTIME_SEC_MAX) > > return KTIME_MAX; > > > > + if (ts->tv_sec <= KTIME_SEC_MIN) > > + return KTIME_MIN; > > + > > I just saw this get merged for the stable kernels, and had not seen this when > Thomas originally merged it. > > I can see how this helps the ptp_clock_adjtime() users, but I just > double-checked > what other callers exist, and I think it introduces a regression in setitimer(), > which does > > nval = timespec64_to_ns(&value->it_value); > ninterval = timespec64_to_ns(&value->it_interval); > > without any further range checking that I could find. Setting timers > with negative intervals sounds like a bad idea, and interpreting negative > it_value as a past time instead of KTIME_SEC_MAX sounds like an > unintended interface change. > > I haven't done any proper analysis of the changes, so maybe it's all > good, but I think we need to double-check this, and possibly revert > it from the stable kernels until a final conclusion. I will revert it now from all stable kernels, thanks. greg k-h