Date: Fri, 17 Jun 2022 19:40:04 GMT From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 34f633b6a7aa - stable/13 - linux(4): Prevent time_t overflows on i386. Message-ID: <202206171940.25HJe4se019296@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=34f633b6a7aa2ad953239619563c446e8da16ec0 commit 34f633b6a7aa2ad953239619563c446e8da16ec0 Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2022-05-08 12:39:09 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2022-06-17 19:34:59 +0000 linux(4): Prevent time_t overflows on i386. As native i386 time_t is still 32-bit, check that the user-provided 64-bit tv_sec value fits to the kernel time_t, return EOVERFLOW if not. MFC after: 2 weeks (cherry picked from commit 3dc2a06752b593acd1a76e784b169f3d60e81d00) --- sys/compat/linux/linux_time.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index d4f502eee7c6..0f1af6b3a5cf 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -177,6 +177,11 @@ int linux_to_native_timespec64(struct timespec *ntp, struct l_timespec64 *ltp64) { +#if defined(__i386__) + /* i386 time_t is still 32-bit */ + if (ltp64->tv_sec > INT_MAX || ltp64->tv_sec < INT_MIN) + return (EOVERFLOW); +#endif /* Zero out the padding in compat mode. */ ntp->tv_nsec = ltp64->tv_nsec & 0xFFFFFFFFUL; ntp->tv_sec = ltp64->tv_sec;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206171940.25HJe4se019296>