From a526db13df7e8d34a082e04c563c7bba4e4f75e2 Mon Sep 17 00:00:00 2001 From: yamt Date: Fri, 24 Oct 2003 16:11:21 +0000 Subject: [PATCH] sa_unblockyield: don't assert that syscall arguments are sane. return an appropriate error instead. --- sys/kern/kern_sa.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_sa.c b/sys/kern/kern_sa.c index f8685efe4845..f132c5d79341 100644 --- a/sys/kern/kern_sa.c +++ b/sys/kern/kern_sa.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sa.c,v 1.27 2003/10/20 07:15:26 wiz Exp $ */ +/* $NetBSD: kern_sa.c,v 1.28 2003/10/24 16:11:21 yamt Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.27 2003/10/20 07:15:26 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.28 2003/10/24 16:11:21 yamt Exp $"); #include #include @@ -493,12 +493,17 @@ sys_sa_unblockyield(struct lwp *l, void *v, register_t *retval) SCHED_LOCK(s); LIST_FOREACH(l2, &p->p_lwps, l_sibling) { if (l2->l_lid == SCARG(uap, sa_id)) { - KDASSERT(l2->l_upcallstack == - sa->sa_stacks[sa->sa_nstacks].ss_sp); break; } } - KDASSERT(l2 != NULL); + if (l2 == NULL) { + SCHED_UNLOCK(s); + return (ESRCH); + } + if (l2->l_upcallstack != sa->sa_stacks[sa->sa_nstacks].ss_sp) { + SCHED_UNLOCK(s); + return (EINVAL); + } /* * upcall not interrupted: (*up_preempted == NULL)