From nobody Tue Aug 09 20:01:21 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 4M2P8f0bsTz3j8bf; Tue, 9 Aug 2022 20:01:22 +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 4M2P8d6wvWz3mC5; Tue, 9 Aug 2022 20:01:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660075282; 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=lvZFRiDk3gRE2zrJY/KJZQOKmCYvzkRX+tXGV5hGs5E=; b=p0ykKKkhlG/H6s0kkS17/lUccFgHzY+YQUemPrr1v7guFZmYqocOJXxMVW6T4f76GIb3rj zf6HImHtqCgrBaFqgvITeW8HPQMUYTIQu9RJttu7liACBzihx5yr2sS/UdIfv9DJiztTmJ kxCMmLmKGKMegMY5rvhqnKAuR4omMrQZcPTecw96KvpgnN2/O7rYR1BHnaeGZh8vAXmHRf eyVU6vtrM7xa8o1wpb0YDV9bvmf0LJNB8eedJpGLTxUWP3DAVFsxyazMR+LMPlGJ56p7fV pknV41CTWgMf1JKGqvtisKVXy/L3SL/QvgwwgcidQuGNJp2/ADBVsubDXL88Uw== 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 4M2P8d619szkd5; Tue, 9 Aug 2022 20:01:21 +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 279K1Ll9031334; Tue, 9 Aug 2022 20:01:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 279K1Lha031333; Tue, 9 Aug 2022 20:01:21 GMT (envelope-from git) Date: Tue, 9 Aug 2022 20:01:21 GMT Message-Id: <202208092001.279K1Lha031333@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: c48048ebdbed - releng/13.1 - 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/releng/13.1 X-Git-Reftype: branch X-Git-Commit: c48048ebdbed0901dacf1632af3b3db600533e64 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660075282; 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=lvZFRiDk3gRE2zrJY/KJZQOKmCYvzkRX+tXGV5hGs5E=; b=Txnnb/YanF7ztl1Oj0Tz3r+wAy3hH/54NxX0A+GRaOf3cpNnxUk1BmZFMtcMxtxPNlorqG 5UAECx6agJ1eun3qFtAXAZ2TH2+SnHqbHwbsK/+0Zyz7jfWL8Er+A0g5Vqwo87KR7sp3hP QzJceTu0aEWWhBdbrEkK0YcJ6kijXgs+7VK5yxrgvrdGAWdoywSfUh9nSFE1sHlYQOr1L6 d6nR3R+ltaAdAJistk59cSVkrTZVJE5FWOizzou3GfnepreppfxlZuuS+ig8407TDUbbwC BQ/L3cpZEhFKU6U9jKZOpwav2NfSspFyYNCujgkeTQkcNi5OTUMo1m22GUHn5A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660075282; a=rsa-sha256; cv=none; b=enojPnN2DwgHDvSVBf419L2fL9rk27QkPvcVkpC36ZUpyu6ft6IpIag0fYkm9hBfOz4b8f n57l5ig2tpBiyiyQaCYAZfBu3BiTKOfyFIadc6JI2iqU4z1l/nZ6iDgVI1cy4EQw0OtZ3o ResLFtJ5kAvEQgIvldXYhB4soq2CVtqSBc+5xpLIa4c8ztdZl2WQs70TDgPlhJX2qZrDb3 FfH9hJe4mZivM6YVgj1V2KUpAJUezHwWac+yutKBhcdipW3qwZSstbzBTihHiegJNAxvzC SYS7X+sagSKyxWNuJxFn7htWJLg7cIsRlGYnon1R1ceRzSwUdzTCCCUCUIA8mA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c48048ebdbed0901dacf1632af3b3db600533e64 commit c48048ebdbed0901dacf1632af3b3db600533e64 Author: Mark Johnston AuthorDate: 2022-05-25 00:14:33 +0000 Commit: Mark Johnston CommitDate: 2022-07-25 21:01:16 +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. Approved by: so Security: FreeBSD-EN-22:16.kqueue 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) (cherry picked from commit 129112f80d2bfe6091ebb8656912fb55d6192e1f) --- 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 2e9773ab5701..e40d4b192dce 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 */