From a1a04dd1be152e989c15c6d94720429f417bdb96 Mon Sep 17 00:00:00 2001 From: drochner Date: Thu, 10 Dec 2009 12:39:12 +0000 Subject: [PATCH] If a struct sigevent with SIGEV_SIGNAL is passed to timer_create(2), check the signal number to be in the allowed range. An invalid signal number could crash the kernel by overflowing the sigset_t array. More checks would be good, and SIGEV_THREAD shouldn't be dropped silently, but this fixes at least the local DOS vulnerability. --- sys/kern/kern_time.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index cf6af747dd09..ec47d61cea2c 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.162 2009/10/03 20:48:42 elad Exp $ */ +/* $NetBSD: kern_time.c,v 1.163 2009/12/10 12:39:12 drochner Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.162 2009/10/03 20:48:42 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.163 2009/12/10 12:39:12 drochner Exp $"); #include #include @@ -531,7 +531,10 @@ timer_create1(timer_t *tid, clockid_t id, struct sigevent *evp, if (((error = (*fetch_event)(evp, &pt->pt_ev, sizeof(pt->pt_ev))) != 0) || ((pt->pt_ev.sigev_notify < SIGEV_NONE) || - (pt->pt_ev.sigev_notify > SIGEV_SA))) { + (pt->pt_ev.sigev_notify > SIGEV_SA)) || + (pt->pt_ev.sigev_notify == SIGEV_SIGNAL && + (pt->pt_ev.sigev_signo <= 0 || + pt->pt_ev.sigev_signo >= NSIG))) { pool_put(&ptimer_pool, pt); return (error ? error : EINVAL); }