Page MenuHomeFreeBSD

timerfd: Use saturating sbintime conversions
ClosedPublic

Authored by jfree on Mar 10 2026, 12:51 AM.
Tags
None
Referenced Files
F161877129: D55792.diff
Tue, Jul 7, 3:56 PM
Unknown Object (File)
Mon, Jul 6, 12:01 AM
Unknown Object (File)
Tue, Jun 30, 9:26 PM
Unknown Object (File)
Mon, Jun 29, 1:12 AM
Unknown Object (File)
Sat, Jun 27, 7:19 AM
Unknown Object (File)
Thu, Jun 25, 5:21 AM
Unknown Object (File)
Jun 7 2026, 9:47 AM
Unknown Object (File)
Jun 4 2026, 10:02 PM
Subscribers

Details

Summary

Some timerfd consumers set expirations with timespec tv_sec components
larger than 2^31 - 1. In such cases, converting that timespec to
sbintime results in data loss or sign flip, yielding a shorter
expiration than desired.

To avoid this problem, use saturating timespec-to-sbintime conversion
functions. These will clamp the converted sbintime to SBT_MAX under
circumstances where the normal conversion functions would overflow.

Saturating conversions still result in data loss, but the consequences
are less severe, causing problems only after SBT_MAX (~68 years) of
system uptime elapses.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 71306
Build 68189: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Mar 10 2026, 1:11 AM

Is this covered by the timerfd tests you posted already?

sys/kern/sys_timerfd.c
404

Do you need to catch overflow here too?

Saturate next expiration sbintime

This revision now requires review to proceed.Mar 20 2026, 6:36 AM
This revision is now accepted and ready to land.Mar 20 2026, 6:41 AM
This revision was automatically updated to reflect the committed changes.