Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.

ok christos@
This commit is contained in:
maxv 2014-06-24 14:33:57 +00:00
parent 6354014157
commit dc0681e4c5
2 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_compat_50.c,v 1.23 2013/03/29 01:04:30 christos Exp $ */
/* $NetBSD: netbsd32_compat_50.c,v 1.24 2014/06/24 14:33:57 maxv Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.23 2013/03/29 01:04:30 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.24 2014/06/24 14:33:57 maxv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sysv.h"
@ -633,7 +633,8 @@ compat_50_netbsd32_kevent(struct lwp *l,
nchanges = SCARG(uap, nchanges);
nevents = SCARG(uap, nevents);
maxalloc = MIN(KQ_NEVENTS, MAX(nchanges, nevents));
maxalloc = KQ_NEVENTS;
netbsd32_kevent_ops.keo_private =
kmem_alloc(maxalloc * sizeof(struct netbsd32_kevent), KM_SLEEP);

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_event.c,v 1.10 2014/01/23 10:50:14 manu Exp $ */
/* $NetBSD: netbsd32_event.c,v 1.11 2014/06/24 14:33:57 maxv Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_event.c,v 1.10 2014/01/23 10:50:14 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_event.c,v 1.11 2014/06/24 14:33:57 maxv Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -112,7 +112,8 @@ netbsd32___kevent50(struct lwp *l,
nchanges = SCARG(uap, nchanges);
nevents = SCARG(uap, nevents);
maxalloc = MIN(KQ_NEVENTS, MAX(nchanges, nevents));
maxalloc = KQ_NEVENTS;
netbsd32_kevent_ops.keo_private =
kmem_alloc(maxalloc * sizeof(struct netbsd32_kevent), KM_SLEEP);