From nobody Wed Apr 06 03:41:25 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C2FB01A905B3; Wed, 6 Apr 2022 03:41:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KY9Kf34V2z4r03; Wed, 6 Apr 2022 03:41:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649216486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zZ6lEKnCwguE0bypvFxuxyGwukMEWeNnQKy+JehnN6g=; b=pO7lD/+tPQzxyaYiMmaVRj3P/jh9w1l2QMY1vwifPhuQZCqbGSl3pH+8SKOWGwRvy0bmES 7qiQoDu5XP5NvTcPXWWRS40yA/3vqxm1lDh5XrvPID3IzRpKg/MJ7w3kQjSYxjj1gGgceU MVD5C3HeM596bk7+/HC6EM5FUeE7NOZ9XS2N5wFoKbqcxts1MjiVuSvGzlgbs+xZLpaTvc n70dKlztBC3ZzGnSAJX0pKZLaiKvE4wCoaJVp1tzk/RMmatf6vX4dA5TJWZd+pNCMiBqRJ WFnDDnEzRpqvDTbBVlkYKucEQab17BSPger8zVqD0NCjqaxQwZssYB71ajHzEQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0828013676; Wed, 6 Apr 2022 03:41:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2363fPFR088809; Wed, 6 Apr 2022 03:41:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2363fPNr088808; Wed, 6 Apr 2022 03:41:25 GMT (envelope-from git) Date: Wed, 6 Apr 2022 03:41:25 GMT Message-Id: <202204060341.2363fPNr088808@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 4c30b9ecd47a - main - fix integer overflow bugs in *stosbt List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4c30b9ecd47a2d92565731082a6a4f2bd1e6e051 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649216486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zZ6lEKnCwguE0bypvFxuxyGwukMEWeNnQKy+JehnN6g=; b=hYOvhsiqIfPB7ypoAueZkoMNG66PXqI4tBERFwP2gwBTAsI0/Q7qgsfZyjOeZiwxGUZrYv mLgRCA+ZMUc7pKHLxa5hv0WQQorF67Np2lzUNwOa56T6c2xtiw0QjvmIBLOygUpzSMb6ox rdtzyZypQnYUXBTeRYwy7ZaSL2EDnKSD3gvce9upTKPqOm6H4fiu63eMq2GnEaKHe/KVz1 RbK2SsIYC7KWdEyknbPgZuptm++ni8wmf6/E4QmRRD/5W7dgCnX8SVQZ7M2cA1LKXIZKxH Wr8cmFaiUjxhSyLuRZQj2fbo5Q2OnH3lYmYhS+m7w0zIBhI8WJwROuyFA5/DWg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649216486; a=rsa-sha256; cv=none; b=Be1Z7ML8X+LTPGgv4WPY2DiqnlmWaGhfx3BI+XxzA4hTzZ/LfWwZGCj7/+mkoysDpVDCCc NM0DYsgKc8A+vIrzHKvQMK+wPhAEcKSqUxiUUQ6gZWkMYJXbHW+4deBN2hwDRs/pfaJJCv LnZseDKDDCz73jKtiqHxB2qGPz7Xb9AslTexuZeLLwPwkFT/oFaMilPz3Y+1Kf17krxdHM AzB++2kQ/AY0wjwKeyZ7h/7S+X19WsT8Uf5uFqHFis5wjQIpcOLX/wWKbjP97tooVJW8b6 zWDG5iMJGQeTOLwpSI1z/C6ktUjhavEJHWLLNuFlAfPGyvFJ+NvX/vlfCUoS/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4c30b9ecd47a2d92565731082a6a4f2bd1e6e051 commit 4c30b9ecd47a2d92565731082a6a4f2bd1e6e051 Author: Warner Losh AuthorDate: 2022-04-06 03:35:27 +0000 Commit: Warner Losh CommitDate: 2022-04-06 03:36:59 +0000 fix integer overflow bugs in *stosbt 68f57679d660 Fixed another class of integer overflows, but introduced a boundary condition for 2-4s in ns conversion, 2-~4000s in us conversions and 2-~4,000,000s in ms conversions. This was because we bogusly used SBT_1S for the notion of 1 second, instead of the appropriate power of 10. To fix, just use the appropriate power of 10, which avoids these overflows. This caused some sleeps in ZFS to be on the order of an hour. MFC: 1 day PR: 263073 Sponsored by: Netflix Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D34790 --- sys/sys/time.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/sys/time.h b/sys/sys/time.h index 866a9e788cd0..f3a3bc99a0f2 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -207,7 +207,7 @@ nstosbt(int64_t _ns) #ifdef KASSERT KASSERT(_ns >= 0, ("Negative values illegal for nstosbt: %jd", _ns)); #endif - if (_ns >= SBT_1S) { + if (_ns >= 1000000000) { sb = (_ns / 1000000000) * SBT_1S; _ns = _ns % 1000000000; } @@ -231,7 +231,7 @@ ustosbt(int64_t _us) #ifdef KASSERT KASSERT(_us >= 0, ("Negative values illegal for ustosbt: %jd", _us)); #endif - if (_us >= SBT_1S) { + if (_us >= 1000000) { sb = (_us / 1000000) * SBT_1S; _us = _us % 1000000; } @@ -255,7 +255,7 @@ mstosbt(int64_t _ms) #ifdef KASSERT KASSERT(_ms >= 0, ("Negative values illegal for mstosbt: %jd", _ms)); #endif - if (_ms >= SBT_1S) { + if (_ms >= 1000) { sb = (_ms / 1000) * SBT_1S; _ms = _ms % 1000; }