From nobody Wed Jun 08 00:44:59 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 B09538425C1; Wed, 8 Jun 2022 00:44:59 +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 4LHpQz2z9Zz4nt7; Wed, 8 Jun 2022 00:44:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654649099; 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=gwf4uWHORenRHP5w0UX77u2Uk2eV7EkEEAXjKH3s0Io=; b=wZ1q2Tp4XqRPMO/Z8LxF8Bz91Mu0H/kJoV/sDGQPUphFtYeaxoMylHlgS5ZoYGaFOEeZhO fQnzDruI4sKSjwBbBB/pK0I1oGJaXw0G0FlCvp+ZuIFqxMRM9+ap8MXKO8y4s7HeTTOqe3 7QRxSDJlYDxX3rQFolCg+Mqboz7y0AThrHoavPvoyTYAbwiS5J4Pgj1HXPTtfBbH99lSP9 BuKa9bwMI3AEUOWYRzDMWNk0q0LQit7Yuc/trPqJvjex9zfTHX8pi4AKx2xc5As0j+GlF4 NyNLgDXnrBbHieKaRiPhjBxLI99K90oAsZroa/Ww0CK5ew0lgUMkxVZcJ8mPuQ== 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 2B70E255E4; Wed, 8 Jun 2022 00:44:59 +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 2580ixZ3060661; Wed, 8 Jun 2022 00:44:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2580ixka060660; Wed, 8 Jun 2022 00:44:59 GMT (envelope-from git) Date: Wed, 8 Jun 2022 00:44:59 GMT Message-Id: <202206080044.2580ixka060660@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 129112f80d2b - stable/13 - kevent: Fix an off-by-one in filt_timerexpire_l() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 129112f80d2bfe6091ebb8656912fb55d6192e1f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654649099; 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=gwf4uWHORenRHP5w0UX77u2Uk2eV7EkEEAXjKH3s0Io=; b=mdm5xaMsFRFkIM6nBcjr/Gjq/5zGUfSz9jMTOD5LClxPzS6CMuoXuawDdz4Urs1Y7G2wUg ns5FNWSdnxIDGbmK7wOI19C43QB7hQ1mpAMJhPlsIWlU32IpsT8IpC6t8g3NaeT+DReFUx F+NP6HgyZXHVVhQmemjCQysCZ2GSOEgzgWsE6EbgqrutSmUOWfZhtFDIDMfCSES802T/Tq GpEr0MitTJEr+LS5jJzjdTuTGsrtRW9rc1ykzlVCay/vPmATULv5vdGzwcxSG47aRiQeuR Cl8ybKOmFqJgZsqhJU0J2rYUvQiB5rE1yS9KhrPpq+6Skgi3k4ocb7qzZCXIpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654649099; a=rsa-sha256; cv=none; b=LWqcZyBziNDkXb8a/UiLO5DnIcqABBXkziSkdrGVJB5hWeoopPDBQBFNiQPsGLDSsbJwLf kmD37u8rXAX4/zU3FeiMOJUeeLYazfJwTvWAe9SHTOypg/Uy7qgd7OKnJE5lx7zFPS+FTw MnpoiPdgA2JMNmTJpOSDX+wNzAOBsPBDqSeT8jrwixQnhRrIMAMx0psKDivYEeyhXp7hC1 vIUn3CsDHBJ2w8ufYa0uy6csXUKw5a8B4dvme22GK7mQWappKvnnkWl9xzrH1TrS5x1cNs XF5B2/UeqU7yk445ckai1k7aXmFzjFOW0Yoj4JdhdtZ4DGNq0o7/6CCOEjcydQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=129112f80d2bfe6091ebb8656912fb55d6192e1f commit 129112f80d2bfe6091ebb8656912fb55d6192e1f Author: Mark Johnston AuthorDate: 2022-05-25 00:14:33 +0000 Commit: Mark Johnston CommitDate: 2022-06-08 00:42:21 +0000 kevent: Fix an off-by-one in filt_timerexpire_l() Suppose a periodic kevent timer fires close to its deadline, so that now - kc->next is small. Then delta ends up being 1, and the next timer deadline is set to (delta + 1) * kc->to, where kc->to is the timer period. This means that the timer fires at half of the requested rate, and the value returned in kn_data is similarly inaccurate. PR: 264131 Fixes: 7cb40543e964 ("filt_timerexpire: do not iterate over the interval") Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 524dadf7a8725dea144571843e611dbdbd59d668) --- sys/kern/kern_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 1e6968326b6c..832962d42a4d 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -739,7 +739,7 @@ filt_timerexpire_l(struct knote *kn, bool proc_locked) if (delta == 0) delta = 1; kn->kn_data += delta; - kc->next += (delta + 1) * kc->to; + kc->next += delta * kc->to; if (now >= kc->next) /* overflow */ kc->next = now + kc->to; KNOTE_ACTIVATE(kn, 0); /* XXX - handle locking */