svn commit: r316292 - stable/11/sys/compat/linux
Dmitry Chagin
dchagin at FreeBSD.org
Thu Mar 30 20:00:59 UTC 2017
Author: dchagin
Date: Thu Mar 30 20:00:57 2017
New Revision: 316292
URL: https://svnweb.freebsd.org/changeset/base/316292
Log:
MFC r314293:
Return EOVERFLOW error in case then the size of tv_sec field of struct timespec
in COMPAT_LINUX32 Linuxulator's not equal to the size of native tv_sec.
Modified:
stable/11/sys/compat/linux/linux_misc.c
stable/11/sys/compat/linux/linux_time.c
stable/11/sys/compat/linux/linux_timer.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/compat/linux/linux_misc.c
==============================================================================
--- stable/11/sys/compat/linux/linux_misc.c Thu Mar 30 19:59:23 2017 (r316291)
+++ stable/11/sys/compat/linux/linux_misc.c Thu Mar 30 20:00:57 2017 (r316292)
@@ -2290,8 +2290,9 @@ linux_pselect6(struct thread *td, struct
TIMEVAL_TO_TIMESPEC(&utv, &uts);
- native_to_linux_timespec(<s, &uts);
- error = copyout(<s, args->tsp, sizeof(lts));
+ error = native_to_linux_timespec(<s, &uts);
+ if (error == 0)
+ error = copyout(<s, args->tsp, sizeof(lts));
}
return (error);
@@ -2343,8 +2344,9 @@ linux_ppoll(struct thread *td, struct li
} else
timespecclear(&uts);
- native_to_linux_timespec(<s, &uts);
- error = copyout(<s, args->tsp, sizeof(lts));
+ error = native_to_linux_timespec(<s, &uts);
+ if (error == 0)
+ error = copyout(<s, args->tsp, sizeof(lts));
}
return (error);
@@ -2438,7 +2440,9 @@ linux_sched_rr_get_interval(struct threa
PROC_UNLOCK(tdt->td_proc);
if (error != 0)
return (error);
- native_to_linux_timespec(<s, &ts);
+ error = native_to_linux_timespec(<s, &ts);
+ if (error != 0)
+ return (error);
return (copyout(<s, uap->interval, sizeof(lts)));
}
Modified: stable/11/sys/compat/linux/linux_time.c
==============================================================================
--- stable/11/sys/compat/linux/linux_time.c Thu Mar 30 19:59:23 2017 (r316291)
+++ stable/11/sys/compat/linux/linux_time.c Thu Mar 30 20:00:57 2017 (r316292)
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_time.c
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/ucred.h>
+#include <sys/limits.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/resourcevar.h>
@@ -118,16 +119,21 @@ LIN_SDT_PROBE_DEFINE1(time, linux_clock_
LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, return, "int");
-void
+int
native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp)
{
LIN_SDT_PROBE2(time, native_to_linux_timespec, entry, ltp, ntp);
-
+#ifdef COMPAT_LINUX32
+ if (ntp->tv_sec > INT_MAX &&
+ sizeof(ltp->tv_sec) != sizeof(ntp->tv_sec))
+ return (EOVERFLOW);
+#endif
ltp->tv_sec = ntp->tv_sec;
ltp->tv_nsec = ntp->tv_nsec;
LIN_SDT_PROBE0(time, native_to_linux_timespec, return);
+ return (0);
}
int
@@ -322,8 +328,9 @@ linux_clock_gettime(struct thread *td, s
LIN_SDT_PROBE1(time, linux_clock_gettime, return, error);
return (error);
}
- native_to_linux_timespec(<s, &tp);
-
+ error = native_to_linux_timespec(<s, &tp);
+ if (error != 0)
+ return (error);
error = copyout(<s, args->tp, sizeof lts);
if (error != 0)
LIN_SDT_PROBE1(time, linux_clock_gettime, copyout_error, error);
@@ -450,8 +457,9 @@ linux_clock_getres(struct thread *td, st
LIN_SDT_PROBE1(time, linux_clock_getres, return, error);
return (error);
}
- native_to_linux_timespec(<s, &ts);
-
+ error = native_to_linux_timespec(<s, &ts);
+ if (error != 0)
+ return (error);
error = copyout(<s, args->tp, sizeof lts);
if (error != 0)
LIN_SDT_PROBE1(time, linux_clock_getres, copyout_error, error);
@@ -490,7 +498,9 @@ linux_nanosleep(struct thread *td, struc
}
error = kern_nanosleep(td, &rqts, rmtp);
if (error == EINTR && args->rmtp != NULL) {
- native_to_linux_timespec(&lrmts, rmtp);
+ error2 = native_to_linux_timespec(&lrmts, rmtp);
+ if (error2 != 0)
+ return (error2);
error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts));
if (error2 != 0) {
LIN_SDT_PROBE1(time, linux_nanosleep, copyout_error,
@@ -553,7 +563,9 @@ linux_clock_nanosleep(struct thread *td,
error = kern_nanosleep(td, &rqts, rmtp);
if (error == EINTR && args->rmtp != NULL) {
/* XXX. Not for TIMER_ABSTIME */
- native_to_linux_timespec(&lrmts, rmtp);
+ error2 = native_to_linux_timespec(&lrmts, rmtp);
+ if (error2 != 0)
+ return (error2);
error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts));
if (error2 != 0) {
LIN_SDT_PROBE1(time, linux_clock_nanosleep,
Modified: stable/11/sys/compat/linux/linux_timer.h
==============================================================================
--- stable/11/sys/compat/linux/linux_timer.h Thu Mar 30 19:59:23 2017 (r316291)
+++ stable/11/sys/compat/linux/linux_timer.h Thu Mar 30 20:00:57 2017 (r316292)
@@ -111,7 +111,7 @@ struct l_itimerspec {
struct l_timespec it_value;
};
-void native_to_linux_timespec(struct l_timespec *,
+int native_to_linux_timespec(struct l_timespec *,
struct timespec *);
int linux_to_native_timespec(struct timespec *,
struct l_timespec *);
More information about the svn-src-stable
mailing list