diff options
author | 2020-08-11 15:41:50 +0000 | |
---|---|---|
committer | 2020-08-11 15:41:50 +0000 | |
commit | 74ea3cc86ee15933c6f981ce83e65f4b7b652f9e (patch) | |
tree | 0abb1c13f184a2973294a76447aada266cf84416 | |
parent | Explicitly #include <scsi/scsi_debug.h> rather than assuming scsiconf.h will do (diff) | |
download | wireguard-openbsd-74ea3cc86ee15933c6f981ce83e65f4b7b652f9e.tar.xz wireguard-openbsd-74ea3cc86ee15933c6f981ce83e65f4b7b652f9e.zip |
getitimer(2): don't enter itimer_mtx to read ITIMER_REAL itimerspec
The ITIMER_REAL per-process interval timer is protected by the kernel
lock. The ITIMER_REAL timeout (ps_realit_to), setitimer(2), and
getitimer(2) all run under the kernel lock. Entering itimer_mtx
during getitimer(2) when reading the ITIMER_REAL ps_timer state is
superfluous and misleading.
-rw-r--r-- | sys/kern/kern_time.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 2097c292788..73daea85537 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.135 2020/08/09 19:15:47 cheloha Exp $ */ +/* $OpenBSD: kern_time.c,v 1.136 2020/08/11 15:41:50 cheloha Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -526,10 +526,13 @@ sys_getitimer(struct proc *p, void *v, register_t *retval) return (EINVAL); itimer = &p->p_p->ps_timer[which]; memset(&aitv, 0, sizeof(aitv)); - mtx_enter(&itimer_mtx); + + if (which != ITIMER_REAL) + mtx_enter(&itimer_mtx); TIMESPEC_TO_TIMEVAL(&aitv.it_interval, &itimer->it_interval); TIMESPEC_TO_TIMEVAL(&aitv.it_value, &itimer->it_value); - mtx_leave(&itimer_mtx); + if (which != ITIMER_REAL) + mtx_leave(&itimer_mtx); if (which == ITIMER_REAL) { struct timeval now; |