Fri Nov 30 10:28:46 2018 UTC ()
Additionally pull up following revision(s) (requested by maxv in ticket #1110):

	sys/compat/linux/common/linux_misc_notalpha.c: revision 1.110
	sys/kern/kern_time.c: revision 1.193

Improve my kern_time.c::rev1.192, systematically clear the buffers we get
from 'ptimer_pool' to prevent more leaks.


(martin)
diff -r1.109 -r1.109.12.1 src/sys/compat/linux/common/linux_misc_notalpha.c
diff -r1.189.8.1 -r1.189.8.2 src/sys/kern/kern_time.c

cvs diff -r1.109 -r1.109.12.1 src/sys/compat/linux/common/linux_misc_notalpha.c (expand / switch to unified diff)

--- src/sys/compat/linux/common/linux_misc_notalpha.c 2014/11/09 17:48:08 1.109
+++ src/sys/compat/linux/common/linux_misc_notalpha.c 2018/11/30 10:28:46 1.109.12.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux_misc_notalpha.c,v 1.109 2014/11/09 17:48:08 maxv Exp $ */ 1/* $NetBSD: linux_misc_notalpha.c,v 1.109.12.1 2018/11/30 10:28:46 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe 8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center. 9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.109 2014/11/09 17:48:08 maxv Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.109.12.1 2018/11/30 10:28:46 martin Exp $");
35 35
36/* 36/*
37 * Note that we must NOT include "opt_compat_linux32.h" here, 37 * Note that we must NOT include "opt_compat_linux32.h" here,
38 * the maze of ifdefs below relies on COMPAT_LINUX32 only being 38 * the maze of ifdefs below relies on COMPAT_LINUX32 only being
39 * defined when this file is built for linux32. 39 * defined when this file is built for linux32.
40 */ 40 */
41 41
42#include <sys/param.h> 42#include <sys/param.h>
43#include <sys/systm.h> 43#include <sys/systm.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/mman.h> 45#include <sys/mman.h>
46#include <sys/mount.h> 46#include <sys/mount.h>
47#include <sys/mbuf.h> 47#include <sys/mbuf.h>
@@ -151,26 +151,27 @@ linux_sys_alarm(struct lwp *l, const str @@ -151,26 +151,27 @@ linux_sys_alarm(struct lwp *l, const str
151 timespecclear(&it.it_interval); 151 timespecclear(&it.it_interval);
152 it.it_value.tv_sec = SCARG(uap, secs); 152 it.it_value.tv_sec = SCARG(uap, secs);
153 it.it_value.tv_nsec = 0; 153 it.it_value.tv_nsec = 0;
154 if (itimespecfix(&it.it_value) || itimespecfix(&it.it_interval)) { 154 if (itimespecfix(&it.it_value) || itimespecfix(&it.it_interval)) {
155 mutex_spin_exit(&timer_lock); 155 mutex_spin_exit(&timer_lock);
156 return (EINVAL); 156 return (EINVAL);
157 } 157 }
158 158
159 ptp = pts->pts_timers[ITIMER_REAL]; 159 ptp = pts->pts_timers[ITIMER_REAL];
160 if (ptp == NULL) { 160 if (ptp == NULL) {
161 if (spare == NULL) { 161 if (spare == NULL) {
162 mutex_spin_exit(&timer_lock); 162 mutex_spin_exit(&timer_lock);
163 spare = pool_get(&ptimer_pool, PR_WAITOK); 163 spare = pool_get(&ptimer_pool, PR_WAITOK);
 164 memset(spare, 0, sizeof(*spare));
164 goto retry; 165 goto retry;
165 } 166 }
166 ptp = spare; 167 ptp = spare;
167 spare = NULL; 168 spare = NULL;
168 ptp->pt_ev.sigev_notify = SIGEV_SIGNAL; 169 ptp->pt_ev.sigev_notify = SIGEV_SIGNAL;
169 ptp->pt_ev.sigev_signo = SIGALRM; 170 ptp->pt_ev.sigev_signo = SIGALRM;
170 ptp->pt_overruns = 0; 171 ptp->pt_overruns = 0;
171 ptp->pt_proc = p; 172 ptp->pt_proc = p;
172 ptp->pt_type = CLOCK_REALTIME; 173 ptp->pt_type = CLOCK_REALTIME;
173 ptp->pt_entry = CLOCK_REALTIME; 174 ptp->pt_entry = CLOCK_REALTIME;
174 ptp->pt_active = 0; 175 ptp->pt_active = 0;
175 ptp->pt_queued = 0; 176 ptp->pt_queued = 0;
176 callout_init(&ptp->pt_ch, CALLOUT_MPSAFE); 177 callout_init(&ptp->pt_ch, CALLOUT_MPSAFE);

cvs diff -r1.189.8.1 -r1.189.8.2 src/sys/kern/kern_time.c (expand / switch to unified diff)

--- src/sys/kern/kern_time.c 2018/11/29 08:48:38 1.189.8.1
+++ src/sys/kern/kern_time.c 2018/11/30 10:28:46 1.189.8.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_time.c,v 1.189.8.1 2018/11/29 08:48:38 martin Exp $ */ 1/* $NetBSD: kern_time.c,v 1.189.8.2 2018/11/30 10:28:46 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christopher G. Demetriou, and by Andrew Doran. 8 * by Christopher G. Demetriou, and by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -51,27 +51,27 @@ @@ -51,27 +51,27 @@
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE. 58 * SUCH DAMAGE.
59 * 59 *
60 * @(#)kern_time.c 8.4 (Berkeley) 5/26/95 60 * @(#)kern_time.c 8.4 (Berkeley) 5/26/95
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.1 2018/11/29 08:48:38 martin Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.2 2018/11/30 10:28:46 martin Exp $");
65 65
66#include <sys/param.h> 66#include <sys/param.h>
67#include <sys/resourcevar.h> 67#include <sys/resourcevar.h>
68#include <sys/kernel.h> 68#include <sys/kernel.h>
69#include <sys/systm.h> 69#include <sys/systm.h>
70#include <sys/proc.h> 70#include <sys/proc.h>
71#include <sys/vnode.h> 71#include <sys/vnode.h>
72#include <sys/signalvar.h> 72#include <sys/signalvar.h>
73#include <sys/syslog.h> 73#include <sys/syslog.h>
74#include <sys/timetc.h> 74#include <sys/timetc.h>
75#include <sys/timex.h> 75#include <sys/timex.h>
76#include <sys/kauth.h> 76#include <sys/kauth.h>
77#include <sys/mount.h> 77#include <sys/mount.h>
@@ -1154,26 +1154,27 @@ dosetitimer(struct proc *p, int which, s @@ -1154,26 +1154,27 @@ dosetitimer(struct proc *p, int which, s
1154 pts = p->p_timers; 1154 pts = p->p_timers;
1155 retry: 1155 retry:
1156 if (!timerisset(&itvp->it_value) && (pts == NULL || 1156 if (!timerisset(&itvp->it_value) && (pts == NULL ||
1157 pts->pts_timers[which] == NULL)) 1157 pts->pts_timers[which] == NULL))
1158 return (0); 1158 return (0);
1159 if (pts == NULL) 1159 if (pts == NULL)
1160 pts = timers_alloc(p); 1160 pts = timers_alloc(p);
1161 mutex_spin_enter(&timer_lock); 1161 mutex_spin_enter(&timer_lock);
1162 pt = pts->pts_timers[which]; 1162 pt = pts->pts_timers[which];
1163 if (pt == NULL) { 1163 if (pt == NULL) {
1164 if (spare == NULL) { 1164 if (spare == NULL) {
1165 mutex_spin_exit(&timer_lock); 1165 mutex_spin_exit(&timer_lock);
1166 spare = pool_get(&ptimer_pool, PR_WAITOK); 1166 spare = pool_get(&ptimer_pool, PR_WAITOK);
 1167 memset(spare, 0, sizeof(*spare));
1167 goto retry; 1168 goto retry;
1168 } 1169 }
1169 pt = spare; 1170 pt = spare;
1170 spare = NULL; 1171 spare = NULL;
1171 pt->pt_ev.sigev_notify = SIGEV_SIGNAL; 1172 pt->pt_ev.sigev_notify = SIGEV_SIGNAL;
1172 pt->pt_ev.sigev_value.sival_int = which; 1173 pt->pt_ev.sigev_value.sival_int = which;
1173 pt->pt_overruns = 0; 1174 pt->pt_overruns = 0;
1174 pt->pt_proc = p; 1175 pt->pt_proc = p;
1175 pt->pt_type = which; 1176 pt->pt_type = which;
1176 pt->pt_entry = which; 1177 pt->pt_entry = which;
1177 pt->pt_queued = false; 1178 pt->pt_queued = false;
1178 if (pt->pt_type == CLOCK_REALTIME) 1179 if (pt->pt_type == CLOCK_REALTIME)
1179 callout_init(&pt->pt_ch, CALLOUT_MPSAFE); 1180 callout_init(&pt->pt_ch, CALLOUT_MPSAFE);