Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1210219pxb; Thu, 16 Sep 2021 02:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK4cvAYK8ynLgnhPOYuWbS7cP743EWdvBhQ4mqBRW8ZcoK99XnNNxn/0iYfva1rdM4uGtB X-Received: by 2002:a92:2e0d:: with SMTP id v13mr3194353ile.111.1631783657980; Thu, 16 Sep 2021 02:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631783657; cv=none; d=google.com; s=arc-20160816; b=U0j0GSX4LuFEeGfie7dM2QE+AL6alPGv3OHGmXPQ+BJmKbyX9R1ACcdMj5mbA5rlbe YuV+8s8RPSncJFnJLEVZfzmh4Gt+4z43BgAx2Vxi7yVGeKk9574oPwNusyG4scYrnN1v oymiusVfKF+f7NGh6c75xpXr2fLt2DnMsuEJGNSzhQ5ZHoF9z2sQil4FXFiUGZsm+Qdu RYaQjHUY3lUUpNdoZSfbxVPM4++BjtqSMy0csAQMoQT66iVLso5WKMZX2/NRFE9uOg01 atEFpYomJbrt7HGa52WY9qvqoGAd3CLV7qua95fNejKGJZh+tjzdpI6xMbXbodJ7RbTY P14w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eU6+l6WTGJvWA7aBUXZooDWotmOFj1kLS/xbgPUxdpU=; b=vzoQxV5TK3OYY3JAxJiFg3f21Brep2wq5gp/XAkpXpeB2gwiZaTe3tHGgGNNd84yUP y8kRGPp2DFVwepIgTcEzDg2IqhJc9jrtATxKmW7mcHcnZFNkUnPhtt9mGpDeM7WRGW3K +gfUowwuQ0/0BycpLPa5nTl0kJQcwEmcfYQDzKPhUQJsmfSR08PXzGJY/BLQAMSnRngZ J00sngpathWgKvW5Fheyw1yADgYJjD2tyGFMVKevxWqCNFNbTVQtIO8CuXJFvZ0gmN4K RkLJGcUufZW3etGRm3VyYipxD0BUawoAIiGSVaPFqnzdWgh8RQ2SRwaFTSgdsin9zIuN M5NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ojr0p/6i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si2252137ilj.89.2021.09.16.02.14.05; Thu, 16 Sep 2021 02:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b="ojr0p/6i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235250AbhIPJNk (ORCPT + 99 others); Thu, 16 Sep 2021 05:13:40 -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: linux-kernel@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