Bug 267157

Summary: system reboots when date is set far in the future
Product: Base System Reporter: jschauma
Component: kernAssignee: Alan Somers <asomers>
Status: In Progress ---    
Severity: Affects Many People CC: asomers, grahamperrin, zlei
Priority: ---    
Version: 13.1-RELEASE   
Hardware: amd64   
OS: Any   
URL: https://reviews.freebsd.org/D37030

Description jschauma 2022-10-17 19:11:03 UTC
As noted in this thread:
https://lists.freebsd.org/archives/freebsd-hackers/2022-October/001550.html

FreeBSD/amd64 13.1R on at least AWS instances ami-0cf377776fddcf8ba spontaneously reboot if the date is set to values larger than epoch 49282253052249598.

(On 13.0R / ami-00e91cb82b335d15f, this cut-off date appears to be epoch 44093078356492799.)

To reproduce:
Boot an instance of the given AMI above and log in as ec2-user.

$ su
# date -f "%s" 49282253052249598
Fri Dec 31 23:59:58 UTC 1561694399
# date -f "%s" 49282253052249599
Fri Dec 31 23:59:59 UTC 1561694399
[ reboots ~three seconds later ]

Rather than leading to a reboot, settimeofday(2) (I'm guessing) should return EINVAL.

asomers@ noted that assertions in https://github.com/freebsd/freebsd-src/commit/90a79ac5765a09d48b085183503324584ef0f956 could be added.