Disallow excessively small times of day in clock_settime(2).

Reported by:	syzkaller
Reviewed by:	cem, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20151
This commit is contained in:
Mark Johnston 2019-05-03 21:26:44 +00:00
parent 1f6ba72eb4
commit bc79b41c40
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347063

View file

@ -412,7 +412,9 @@ kern_clock_settime(struct thread *td, clockid_t clock_id, struct timespec *ats)
if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000 ||
ats->tv_sec < 0)
return (EINVAL);
if (!allow_insane_settime && ats->tv_sec > 8000ULL * 365 * 24 * 60 * 60)
if (!allow_insane_settime &&
(ats->tv_sec > 8000ULL * 365 * 24 * 60 * 60 ||
ats->tv_sec < utc_offset()))
return (EINVAL);
/* XXX Don't convert nsec->usec and back */
TIMESPEC_TO_TIMEVAL(&atv, ats);