Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Check for valid timespec in clock_settime1()
details: https://anonhg.NetBSD.org/src/rev/56eb3e7cc3c7
branches: trunk
changeset: 460045:56eb3e7cc3c7
user: kamil <kamil%NetBSD.org@localhost>
date: Sat Oct 05 12:57:40 2019 +0000
description:
Check for valid timespec in clock_settime1()
An alternative approach would be to check the valie in settime1(), but
it would result in multiple checks for valid tv_nsec, as there are
settime1() users that need to check the ranges earlier.
Reported-by: syzbot+96e5ce2c2c704d96c2f0%syzkaller.appspotmail.com@localhost
diffstat:
sys/kern/kern_time.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diffs (28 lines):
diff -r 359d0ba635f8 -r 56eb3e7cc3c7 sys/kern/kern_time.c
--- a/sys/kern/kern_time.c Sat Oct 05 12:27:14 2019 +0000
+++ b/sys/kern/kern_time.c Sat Oct 05 12:57:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_time.c,v 1.200 2019/09/20 14:12:57 kamil Exp $ */
+/* $NetBSD: kern_time.c,v 1.201 2019/10/05 12:57:40 kamil Exp $ */
/*-
* Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.200 2019/09/20 14:12:57 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.201 2019/10/05 12:57:40 kamil Exp $");
#include <sys/param.h>
#include <sys/resourcevar.h>
@@ -217,6 +217,9 @@
{
int error;
+ if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000L)
+ return EINVAL;
+
switch (clock_id) {
case CLOCK_REALTIME:
if ((error = settime1(p, tp, check_kauth)) != 0)
Home |
Main Index |
Thread Index |
Old Index