summaryrefslogtreecommitdiff
path: root/sys/kern/sys_futex.c
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2020-03-20 17:17:32 +0000
committercheloha <cheloha@cvs.openbsd.org>2020-03-20 17:17:32 +0000
commit7e0b32f0456d67a9052fe44a1c5985b64535d66d (patch)
tree1d44ffcfee563b5eda78aa5bd29389e2aa371049 /sys/kern/sys_futex.c
parent90cc01466d053a8dded828b201fb818c3d6f51b7 (diff)
futex(2): futex_wait(): ensure timeout is set when calling rwsleep_nsec(9)
rwsleep_nsec(9) will not set a timeout if the nsecs parameter is equal to INFSLP (UINT64_MAX). We need to limit the duration to MAXTSLP (UINT64_MAX - 1) to ensure a timeout is set.
Diffstat (limited to 'sys/kern/sys_futex.c')
-rw-r--r--sys/kern/sys_futex.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/sys_futex.c b/sys/kern/sys_futex.c
index fa932e41bac..140bb2b773e 100644
--- a/sys/kern/sys_futex.c
+++ b/sys/kern/sys_futex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_futex.c,v 1.14 2020/01/14 08:52:18 mpi Exp $ */
+/* $OpenBSD: sys_futex.c,v 1.15 2020/03/20 17:17:31 cheloha Exp $ */
/*
* Copyright (c) 2016-2017 Martin Pieuchot
@@ -244,7 +244,7 @@ futex_wait(uint32_t *uaddr, uint32_t val, const struct timespec *timeout,
#endif
if (ts.tv_sec < 0 || !timespecisvalid(&ts))
return EINVAL;
- nsecs = TIMESPEC_TO_NSEC(&ts);
+ nsecs = MIN(TIMESPEC_TO_NSEC(&ts), MAXTSLP);
}
f = futex_get(uaddr, flags | FT_CREATE);