Bug 252539 - [PATCH] kevent(2): wrong EVFILT_TIMER timeouts when using NOTE_NSECONDS
Summary: [PATCH] kevent(2): wrong EVFILT_TIMER timeouts when using NOTE_NSECONDS
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Gordon Bergling
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2021-01-09 09:39 UTC by Jan Kokemüller
Modified: 2021-01-30 23:41 UTC (History)
2 users (show)

See Also:


Attachments
reproducer (1.42 KB, text/plain)
2021-01-09 09:41 UTC, Jan Kokemüller
no flags Details
patch (704 bytes, patch)
2021-01-09 09:41 UTC, Jan Kokemüller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kokemüller 2021-01-09 09:39:53 UTC
There is a typo in "timer2sbintime" (sys/kern/kern_event.c) when converting NOTE_NSECONDS to sbintime_t. For the nanosecond part US_TO_SBT instead of NS_TO_SBT is used. This results in weird timeout values.
Comment 1 Jan Kokemüller 2021-01-09 09:41:08 UTC
Created attachment 221412 [details]
reproducer
Comment 2 Jan Kokemüller 2021-01-09 09:41:45 UTC
Created attachment 221413 [details]
patch
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-01-09 19:08:13 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4d0c33be634a929f323117f04e6b1670776f9e37

commit 4d0c33be634a929f323117f04e6b1670776f9e37
Author:     Jan Kokemüller <jan.kokemueller@gmail.com>
AuthorDate: 2021-01-09 19:00:25 +0000
Commit:     Gordon Bergling <gbe@FreeBSD.org>
CommitDate: 2021-01-09 19:00:25 +0000

    kevent(2): Bugfix for wrong EVFILT_TIMER timeouts

    When using NOTE_NSECONDS in the kevent(2) API, US_TO_SBT should be
    used instead of NS_TO_SBT, otherwise the timeout results are
    misleading.

    PR:             252539
    Reviewed by:    kevans, kib
    Approved by:    kevans
    MFC after:      3 weeks

 sys/kern/kern_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 4 Gordon Bergling freebsd_committer freebsd_triage 2021-01-09 19:10:34 UTC
Commited in 4d0c33be634a929f323117f04e6b1670776f9e37. A MFC is planned for within 3 weeks. Thanks for the patch!
Comment 5 Jan Kokemüller 2021-01-13 09:37:53 UTC
Thank you :)
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-01-30 10:14:26 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6a3ad2d0a7b633bad2bb33f9c4c426dffcc91633

commit 6a3ad2d0a7b633bad2bb33f9c4c426dffcc91633
Author:     Jan Kokemüller <jan.kokemueller@gmail.com>
AuthorDate: 2021-01-09 19:00:25 +0000
Commit:     Gordon Bergling <gbe@FreeBSD.org>
CommitDate: 2021-01-30 10:11:55 +0000

    kevent(2): Bugfix for wrong EVFILT_TIMER timeouts

    When using NOTE_NSECONDS in the kevent(2) API, US_TO_SBT should be
    used instead of NS_TO_SBT, otherwise the timeout results are
    misleading.

    PR:             252539
    Reviewed by:    kevans, kib
    Approved by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D28067

    (cherry picked from commit 4d0c33be634a929f323117f04e6b1670776f9e37)

 sys/kern/kern_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 7 Gordon Bergling freebsd_committer freebsd_triage 2021-01-30 10:16:29 UTC
Committed to HEAD, stable/12 and stable/13.

Thanks for spotting the issue and providing a patch!
Comment 8 commit-hook freebsd_committer freebsd_triage 2021-01-30 23:41:37 UTC
A commit in branch stable/11 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8ce9180c09d93b4ef11859be604ef41173d6dbd1

commit 8ce9180c09d93b4ef11859be604ef41173d6dbd1
Author:     Jan Kokemüller <jan.kokemueller@gmail.com>
AuthorDate: 2021-01-09 19:00:25 +0000
Commit:     Gordon Bergling <gbe@FreeBSD.org>
CommitDate: 2021-01-30 23:39:58 +0000

    kevent(2): Bugfix for wrong EVFILT_TIMER timeouts

    When using NOTE_NSECONDS in the kevent(2) API, US_TO_SBT should be
    used instead of NS_TO_SBT, otherwise the timeout results are
    misleading.

    PR:             252539
    Reviewed by:    kevans, kib
    Approved by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D28067

    (cherry picked from commit 4d0c33be634a929f323117f04e6b1670776f9e37)
    (cherry picked from commit 6a3ad2d0a7b633bad2bb33f9c4c426dffcc91633)

 sys/kern/kern_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)