public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] time: verify time values in adjtimex ADJ_SETOFFSET to avoid overflow
@ 2015-12-04  3:09 Sasha Levin
  2015-12-04 20:27 ` John Stultz
  2015-12-05 17:10 ` Thomas Gleixner
  0 siblings, 2 replies; 13+ messages in thread
From: Sasha Levin @ 2015-12-04  3:09 UTC (permalink / raw)
  To: john.stultz, tglx; +Cc: linux-kernel, Sasha Levin

Make sure the tv_usec makes sense. We might multiply them later which can
cause an overflow and undefined behavior.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 kernel/time/timekeeping.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index d563c19..aa3c1c2 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1987,6 +1987,10 @@ int do_adjtimex(struct timex *txc)
 
 	if (txc->modes & ADJ_SETOFFSET) {
 		struct timespec delta;
+
+		if (txc->time.tv_usec >= USEC_PER_SEC || txc->time.tv_usec <= -USEC_PER_SEC)
+			return -EINVAL;
+
 		delta.tv_sec  = txc->time.tv_sec;
 		delta.tv_nsec = txc->time.tv_usec;
 		if (!(txc->modes & ADJ_NANO))
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-12-07 20:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04  3:09 [PATCH] time: verify time values in adjtimex ADJ_SETOFFSET to avoid overflow Sasha Levin
2015-12-04 20:27 ` John Stultz
2015-12-05 17:10 ` Thomas Gleixner
2015-12-06  0:15   ` Sasha Levin
2015-12-06  9:07     ` Thomas Gleixner
2015-12-06 22:11       ` Richard Cochran
2015-12-07 19:54         ` John Stultz
2015-12-07 20:11           ` [RFC][PATCH -reworked] time: Verify " John Stultz
2015-12-07 20:13             ` John Stultz
2015-12-07 20:16               ` Thomas Gleixner
2015-12-07 20:15           ` [PATCH] time: verify " Thomas Gleixner
2015-12-07 20:19             ` John Stultz
2015-12-07 20:23             ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox