Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/thorpej-futex]: src/sys/kern futex_func_wait(): If TIMER_ABSTIME, sanity...
details: https://anonhg.NetBSD.org/src/rev/e2d59754b816
branches: thorpej-futex
changeset: 961143:e2d59754b816
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Apr 03 21:52:20 2021 +0000
description:
futex_func_wait(): If TIMER_ABSTIME, sanity check that the deadline
provided by the caller is not ridiculous.
diffstat:
sys/kern/sys_futex.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diffs (44 lines):
diff -r f230c8734257 -r e2d59754b816 sys/kern/sys_futex.c
--- a/sys/kern/sys_futex.c Sun Jan 03 16:49:31 2021 +0000
+++ b/sys/kern/sys_futex.c Sat Apr 03 21:52:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_futex.c,v 1.11.2.1 2020/11/01 15:16:43 thorpej Exp $ */
+/* $NetBSD: sys_futex.c,v 1.11.2.2 2021/04/03 21:52:20 thorpej Exp $ */
/*-
* Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.11.2.1 2020/11/01 15:16:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.11.2.2 2021/04/03 21:52:20 thorpej Exp $");
/*
* Futexes
@@ -1367,7 +1367,15 @@
return EAGAIN;
/* Determine a deadline on the specified clock. */
- if (timeout == NULL || (clkflags & TIMER_ABSTIME) == TIMER_ABSTIME) {
+ if (timeout == NULL) {
+ deadline = timeout;
+ } else if ((clkflags & TIMER_ABSTIME) == TIMER_ABSTIME) {
+ /* Sanity-check the deadline. */
+ if (timeout->tv_sec < 0 ||
+ timeout->tv_nsec < 0 ||
+ timeout->tv_nsec >= 1000000000L) {
+ return EINVAL;
+ }
deadline = timeout;
} else {
struct timespec interval = *timeout;
@@ -1920,7 +1928,7 @@
}
/*
- * Now wait. futex_wait() will dop our op lock once we
+ * Now wait. futex_wait() will drop our op lock once we
* are entered into the sleep queue, thus ensuring atomicity
* of wakes with respect to waits.
*
Home |
Main Index |
Thread Index |
Old Index