- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks. - LOCK_ASSERT -> KASSERT in some places. - Hold proclist_lock/kernel_lock longer in a couple of places.
This commit is contained in:
parent
50a8df5d23
commit
c147748d84
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pmap.c,v 1.146 2007/03/04 19:21:55 christos Exp $ */
|
/* $NetBSD: pmap.c,v 1.147 2007/03/09 14:11:22 ad Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 1998, 1999, 2003 Ludd, University of Lule}, Sweden.
|
* Copyright (c) 1994, 1998, 1999, 2003 Ludd, University of Lule}, Sweden.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.146 2007/03/04 19:21:55 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.147 2007/03/09 14:11:22 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
#include "opt_cputype.h"
|
#include "opt_cputype.h"
|
||||||
|
@ -689,7 +689,7 @@ pmap_rmproc(struct pmap *pm)
|
||||||
|
|
||||||
outl = outl2 = NULL;
|
outl = outl2 = NULL;
|
||||||
outpri = outpri2 = 0;
|
outpri = outpri2 = 0;
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
LIST_FOREACH(l, &alllwp, l_list) {
|
LIST_FOREACH(l, &alllwp, l_list) {
|
||||||
if (!swappable(l, pm))
|
if (!swappable(l, pm))
|
||||||
continue;
|
continue;
|
||||||
|
@ -716,7 +716,7 @@ pmap_rmproc(struct pmap *pm)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (didswap == 0) {
|
if (didswap == 0) {
|
||||||
if ((l = outl) == NULL)
|
if ((l = outl) == NULL)
|
||||||
l = outl2;
|
l = outl2;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: darwin_sysctl.c,v 1.49 2007/03/04 06:01:14 christos Exp $ */
|
/* $NetBSD: darwin_sysctl.c,v 1.50 2007/03/09 14:11:28 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: darwin_sysctl.c,v 1.49 2007/03/04 06:01:14 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: darwin_sysctl.c,v 1.50 2007/03/09 14:11:28 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ darwin_sysctl_dokproc(SYSCTLFN_ARGS)
|
||||||
elem_count = name[3];
|
elem_count = name[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
pd = proclists;
|
pd = proclists;
|
||||||
again:
|
again:
|
||||||
|
@ -726,7 +726,7 @@ again:
|
||||||
pd++;
|
pd++;
|
||||||
if (pd->pd_list != NULL)
|
if (pd->pd_list != NULL)
|
||||||
goto again;
|
goto again;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
if (where != NULL) {
|
if (where != NULL) {
|
||||||
*oldlenp = (char *)dp - where;
|
*oldlenp = (char *)dp - where;
|
||||||
|
@ -738,7 +738,7 @@ again:
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
cleanup:
|
cleanup:
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: freebsd_sched.c,v 1.8 2007/02/18 09:45:39 dsl Exp $ */
|
/* $NetBSD: freebsd_sched.c,v 1.9 2007/03/09 14:11:28 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: freebsd_sched.c,v 1.8 2007/02/18 09:45:39 dsl Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: freebsd_sched.c,v 1.9 2007/03/09 14:11:28 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
@ -82,7 +82,7 @@ check_proc_access(struct lwp *l, pid_t pid)
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
p = p_find(pid, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
p = p_find(pid, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
|
@ -95,11 +95,11 @@ check_proc_access(struct lwp *l, pid_t pid)
|
||||||
kauth_cred_geteuid(pc) == kauth_cred_getuid(p->p_cred) ||
|
kauth_cred_geteuid(pc) == kauth_cred_getuid(p->p_cred) ||
|
||||||
kauth_cred_getuid(pc) == kauth_cred_geteuid(p->p_cred) ||
|
kauth_cred_getuid(pc) == kauth_cred_geteuid(p->p_cred) ||
|
||||||
kauth_cred_geteuid(pc) == kauth_cred_geteuid(p->p_cred))) {
|
kauth_cred_geteuid(pc) == kauth_cred_geteuid(p->p_cred))) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (kauth_authorize_generic(pc, KAUTH_GENERIC_ISSUSER, NULL) != 0)
|
if (kauth_authorize_generic(pc, KAUTH_GENERIC_ISSUSER, NULL) != 0)
|
||||||
return EPERM;
|
return EPERM;
|
||||||
} else
|
} else
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: hpux_compat.c,v 1.89 2007/03/04 06:01:15 christos Exp $ */
|
/* $NetBSD: hpux_compat.c,v 1.90 2007/03/09 14:11:28 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: hpux_compat.c,v 1.89 2007/03/04 06:01:15 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: hpux_compat.c,v 1.90 2007/03/09 14:11:28 ad Exp $");
|
||||||
|
|
||||||
#if defined(_KERNEL_OPT)
|
#if defined(_KERNEL_OPT)
|
||||||
#include "opt_sysv.h"
|
#include "opt_sysv.h"
|
||||||
|
@ -549,7 +549,7 @@ hpux_sys_rtprio(struct lwp *lp, void *v, register_t *retval)
|
||||||
SCARG(uap, prio) != RTPRIO_RTOFF)
|
SCARG(uap, prio) != RTPRIO_RTOFF)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if (SCARG(uap, pid) == 0)
|
if (SCARG(uap, pid) == 0)
|
||||||
p = lp->l_proc;
|
p = lp->l_proc;
|
||||||
else {
|
else {
|
||||||
|
@ -567,7 +567,7 @@ hpux_sys_rtprio(struct lwp *lp, void *v, register_t *retval)
|
||||||
switch (SCARG(uap, prio)) {
|
switch (SCARG(uap, prio)) {
|
||||||
|
|
||||||
case RTPRIO_NOCHG:
|
case RTPRIO_NOCHG:
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case RTPRIO_RTOFF:
|
case RTPRIO_RTOFF:
|
||||||
|
@ -583,7 +583,7 @@ hpux_sys_rtprio(struct lwp *lp, void *v, register_t *retval)
|
||||||
mutex_enter(&p->p_mutex);
|
mutex_enter(&p->p_mutex);
|
||||||
error = donice(lp, p, nice);
|
error = donice(lp, p, nice);
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (error == EACCES)
|
if (error == EACCES)
|
||||||
error = EPERM;
|
error = EPERM;
|
||||||
return (error);
|
return (error);
|
||||||
|
@ -896,10 +896,10 @@ hpux_sys_getpgrp2(struct lwp *lp, void *v, register_t *retval)
|
||||||
if (SCARG(uap, pid) == 0)
|
if (SCARG(uap, pid) == 0)
|
||||||
SCARG(uap, pid) = cp->p_pid;
|
SCARG(uap, pid) = cp->p_pid;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
p = p_find(SCARG(uap, pid), PFIND_LOCKED);
|
p = p_find(SCARG(uap, pid), PFIND_LOCKED);
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
}
|
}
|
||||||
mutex_enter(&p->p_mutex);
|
mutex_enter(&p->p_mutex);
|
||||||
|
@ -907,12 +907,12 @@ hpux_sys_getpgrp2(struct lwp *lp, void *v, register_t *retval)
|
||||||
kauth_cred_geteuid(p->p_cred) != kauth_cred_geteuid(lp->l_cred) &&
|
kauth_cred_geteuid(p->p_cred) != kauth_cred_geteuid(lp->l_cred) &&
|
||||||
!inferior(p, cp)) {
|
!inferior(p, cp)) {
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (EPERM);
|
return (EPERM);
|
||||||
}
|
}
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
*retval = p->p_pgid;
|
*retval = p->p_pgid;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: irix_signal.c,v 1.38 2007/03/06 12:43:09 tsutsui Exp $ */
|
/* $NetBSD: irix_signal.c,v 1.39 2007/03/09 14:11:28 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1994, 2001-2002 The NetBSD Foundation, Inc.
|
* Copyright (c) 1994, 2001-2002 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.38 2007/03/06 12:43:09 tsutsui Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.39 2007/03/09 14:11:28 ad Exp $");
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
|
@ -897,17 +897,17 @@ irix_sys_waitsys(l, v, retval)
|
||||||
if (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED))
|
if (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED))
|
||||||
options |= WUNTRACED;
|
options |= WUNTRACED;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
error = find_stopped_child(parent, SCARG(uap,pid), options, &child,
|
error = find_stopped_child(parent, SCARG(uap,pid), options, &child,
|
||||||
&status);
|
&status);
|
||||||
stat = child->p_stat; /* XXXSMP */
|
stat = child->p_stat; /* XXXSMP */
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
*retval = 0;
|
*retval = 0;
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return irix_wait_siginfo(NULL, 0, stat, SCARG(uap, info));
|
return irix_wait_siginfo(NULL, 0, stat, SCARG(uap, info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ irix_sys_waitsys(l, v, retval)
|
||||||
#endif
|
#endif
|
||||||
if ((error = irix_wait_siginfo(child, status, stat,
|
if ((error = irix_wait_siginfo(child, status, stat,
|
||||||
SCARG(uap, info))) != 0) {
|
SCARG(uap, info))) != 0) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,7 +925,7 @@ irix_sys_waitsys(l, v, retval)
|
||||||
#ifdef DEBUG_IRIX
|
#ifdef DEBUG_IRIX
|
||||||
printf(("irix_sys_wait(): Don't wait\n"));
|
printf(("irix_sys_wait(): Don't wait\n"));
|
||||||
#endif
|
#endif
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ irix_sys_waitsys(l, v, retval)
|
||||||
#ifdef DEBUG_IRIX
|
#ifdef DEBUG_IRIX
|
||||||
printf("jobcontrol %d\n", child->p_pid);
|
printf("jobcontrol %d\n", child->p_pid);
|
||||||
#endif
|
#endif
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return irix_wait_siginfo(child, W_STOPCODE(status), stat,
|
return irix_wait_siginfo(child, W_STOPCODE(status), stat,
|
||||||
SCARG(uap, info));
|
SCARG(uap, info));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: linux_exec.c,v 1.93 2007/03/04 06:01:23 christos Exp $ */
|
/* $NetBSD: linux_exec.c,v 1.94 2007/03/09 14:11:28 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1994, 1995, 1998, 2000, 2007 The NetBSD Foundation, Inc.
|
* Copyright (c) 1994, 1995, 1998, 2000, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: linux_exec.c,v 1.93 2007/03/04 06:01:23 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: linux_exec.c,v 1.94 2007/03/09 14:11:28 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -341,7 +341,7 @@ linux_nptl_proc_exit(p)
|
||||||
{
|
{
|
||||||
struct linux_emuldata *e = p->p_emuldata;
|
struct linux_emuldata *e = p->p_emuldata;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if we are a thread group leader victim of another
|
* Check if we are a thread group leader victim of another
|
||||||
|
@ -367,7 +367,7 @@ linux_nptl_proc_exit(p)
|
||||||
cv_broadcast(&initproc->p_waitcv);
|
cv_broadcast(&initproc->p_waitcv);
|
||||||
}
|
}
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
/* Emulate LINUX_CLONE_CHILD_CLEARTID */
|
/* Emulate LINUX_CLONE_CHILD_CLEARTID */
|
||||||
if (e->clear_tid != NULL) {
|
if (e->clear_tid != NULL) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: linux_file.c,v 1.79 2007/03/04 06:01:23 christos Exp $ */
|
/* $NetBSD: linux_file.c,v 1.80 2007/03/09 14:11:28 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.79 2007/03/04 06:01:23 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.80 2007/03/09 14:11:28 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -461,7 +461,7 @@ linux_sys_fcntl(l, v, retval)
|
||||||
retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PGID;
|
retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PGID;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if ((long)arg <= 0) {
|
if ((long)arg <= 0) {
|
||||||
pgid = -(long)arg;
|
pgid = -(long)arg;
|
||||||
} else {
|
} else {
|
||||||
|
@ -472,11 +472,11 @@ linux_sys_fcntl(l, v, retval)
|
||||||
}
|
}
|
||||||
pgrp = pg_find(pgid, PFIND_LOCKED);
|
pgrp = pg_find(pgid, PFIND_LOCKED);
|
||||||
if (pgrp == NULL || pgrp->pg_session != p->p_session) {
|
if (pgrp == NULL || pgrp->pg_session != p->p_session) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return EPERM;
|
return EPERM;
|
||||||
}
|
}
|
||||||
tp->t_pgrp = pgrp;
|
tp->t_pgrp = pgrp;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: svr4_misc.c,v 1.124 2007/03/04 06:01:33 christos Exp $ */
|
/* $NetBSD: svr4_misc.c,v 1.125 2007/03/09 14:11:28 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.124 2007/03/04 06:01:33 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.125 2007/03/09 14:11:28 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -1187,17 +1187,17 @@ svr4_sys_waitsys(l, v, retval)
|
||||||
SCARG(uap, grp), SCARG(uap, id),
|
SCARG(uap, grp), SCARG(uap, id),
|
||||||
SCARG(uap, info), SCARG(uap, options)));
|
SCARG(uap, info), SCARG(uap, options)));
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
error = find_stopped_child(parent, SCARG(uap, id), options, &child,
|
error = find_stopped_child(parent, SCARG(uap, id), options, &child,
|
||||||
&status);
|
&status);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
*retval = 0;
|
*retval = 0;
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
svr4_setinfo(NULL, 0, &i);
|
svr4_setinfo(NULL, 0, &i);
|
||||||
return copyout(&i, SCARG(uap, info), sizeof(i));
|
return copyout(&i, SCARG(uap, info), sizeof(i));
|
||||||
}
|
}
|
||||||
|
@ -1208,7 +1208,7 @@ svr4_sys_waitsys(l, v, retval)
|
||||||
|
|
||||||
if ((SCARG(uap, options) & SVR4_WNOWAIT)) {
|
if ((SCARG(uap, options) & SVR4_WNOWAIT)) {
|
||||||
DPRINTF(("Don't wait\n"));
|
DPRINTF(("Don't wait\n"));
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1220,7 +1220,7 @@ svr4_sys_waitsys(l, v, retval)
|
||||||
DPRINTF(("jobcontrol %d\n", child->p_pid));
|
DPRINTF(("jobcontrol %d\n", child->p_pid));
|
||||||
|
|
||||||
svr4_setinfo(child, W_STOPCODE(status), &i);
|
svr4_setinfo(child, W_STOPCODE(status), &i);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return copyout(&i, SCARG(uap, info), sizeof(i));
|
return copyout(&i, SCARG(uap, info), sizeof(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: svr4_32_misc.c,v 1.42 2007/03/04 07:54:09 christos Exp $ */
|
/* $NetBSD: svr4_32_misc.c,v 1.43 2007/03/09 14:11:29 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.42 2007/03/04 07:54:09 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.43 2007/03/09 14:11:29 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -1221,16 +1221,16 @@ svr4_32_sys_waitsys(l, v, retval)
|
||||||
if (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED))
|
if (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED))
|
||||||
options |= WUNTRACED;
|
options |= WUNTRACED;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
error = find_stopped_child(parent, SCARG(uap, id), options, &child,
|
error = find_stopped_child(parent, SCARG(uap, id), options, &child,
|
||||||
&status);
|
&status);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
*retval = 0;
|
*retval = 0;
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return svr4_32_setinfo(NULL, 0, SCARG(uap, info));
|
return svr4_32_setinfo(NULL, 0, SCARG(uap, info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,12 +1238,12 @@ svr4_32_sys_waitsys(l, v, retval)
|
||||||
DPRINTF(("found %d\n", child->p_pid));
|
DPRINTF(("found %d\n", child->p_pid));
|
||||||
error = svr4_32_setinfo(child, status, SCARG(uap,info));
|
error = svr4_32_setinfo(child, status, SCARG(uap,info));
|
||||||
if (error) {
|
if (error) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((SCARG(uap, options) & SVR4_WNOWAIT)) {
|
if ((SCARG(uap, options) & SVR4_WNOWAIT)) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
DPRINTF(("Don't wait\n"));
|
DPRINTF(("Don't wait\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1254,7 +1254,7 @@ svr4_32_sys_waitsys(l, v, retval)
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINTF(("jobcontrol %d\n", child->p_pid));
|
DPRINTF(("jobcontrol %d\n", child->p_pid));
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return svr4_32_setinfo(child, W_STOPCODE(status), SCARG(uap, info));
|
return svr4_32_setinfo(child, W_STOPCODE(status), SCARG(uap, info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: core_elf32.c,v 1.29 2007/02/09 21:55:30 ad Exp $ */
|
/* $NetBSD: core_elf32.c,v 1.30 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.29 2007/02/09 21:55:30 ad Exp $");
|
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.30 2007/03/09 14:11:23 ad Exp $");
|
||||||
|
|
||||||
/* If not included by core_elf64.c, ELFSIZE won't be defined. */
|
/* If not included by core_elf64.c, ELFSIZE won't be defined. */
|
||||||
#ifndef ELFSIZE
|
#ifndef ELFSIZE
|
||||||
|
@ -346,11 +346,11 @@ ELFNAMEEND(coredump_notes)(struct proc *p, struct lwp *l,
|
||||||
sizeof(cpi.cpi_sigcatch));
|
sizeof(cpi.cpi_sigcatch));
|
||||||
|
|
||||||
cpi.cpi_pid = p->p_pid;
|
cpi.cpi_pid = p->p_pid;
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
cpi.cpi_ppid = p->p_pptr->p_pid;
|
cpi.cpi_ppid = p->p_pptr->p_pid;
|
||||||
cpi.cpi_pgrp = p->p_pgid;
|
cpi.cpi_pgrp = p->p_pgid;
|
||||||
cpi.cpi_sid = p->p_session->s_sid;
|
cpi.cpi_sid = p->p_session->s_sid;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
cpi.cpi_ruid = kauth_cred_getuid(l->l_cred);
|
cpi.cpi_ruid = kauth_cred_getuid(l->l_cred);
|
||||||
cpi.cpi_euid = kauth_cred_geteuid(l->l_cred);
|
cpi.cpi_euid = kauth_cred_geteuid(l->l_cred);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: init_main.c,v 1.297 2007/03/04 06:03:03 christos Exp $ */
|
/* $NetBSD: init_main.c,v 1.298 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
|
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.297 2007/03/04 06:03:03 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.298 2007/03/09 14:11:23 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ipsec.h"
|
#include "opt_ipsec.h"
|
||||||
#include "opt_kcont.h"
|
#include "opt_kcont.h"
|
||||||
|
@ -565,7 +565,7 @@ main(void)
|
||||||
mono_time = time;
|
mono_time = time;
|
||||||
#endif
|
#endif
|
||||||
boottime = time;
|
boottime = time;
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
LIST_FOREACH(p, &allproc, p_list) {
|
LIST_FOREACH(p, &allproc, p_list) {
|
||||||
KASSERT((p->p_flag & PK_MARKER) == 0);
|
KASSERT((p->p_flag & PK_MARKER) == 0);
|
||||||
mutex_enter(&p->p_smutex);
|
mutex_enter(&p->p_smutex);
|
||||||
|
@ -578,7 +578,7 @@ main(void)
|
||||||
}
|
}
|
||||||
mutex_exit(&p->p_smutex);
|
mutex_exit(&p->p_smutex);
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
/* Create the pageout daemon kernel thread. */
|
/* Create the pageout daemon kernel thread. */
|
||||||
uvm_swap_init();
|
uvm_swap_init();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: init_sysctl.c,v 1.97 2007/02/17 22:31:42 pavel Exp $ */
|
/* $NetBSD: init_sysctl.c,v 1.98 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.97 2007/02/17 22:31:42 pavel Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.98 2007/03/09 14:11:23 ad Exp $");
|
||||||
|
|
||||||
#include "opt_sysv.h"
|
#include "opt_sysv.h"
|
||||||
#include "opt_multiprocessor.h"
|
#include "opt_multiprocessor.h"
|
||||||
|
@ -1708,10 +1708,10 @@ sysctl_kern_lwp(SYSCTLFN_ARGS)
|
||||||
elem_size = name[1];
|
elem_size = name[1];
|
||||||
elem_count = name[2];
|
elem_count = name[2];
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
p = p_find(pid, PFIND_LOCKED);
|
p = p_find(pid, PFIND_LOCKED);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
}
|
}
|
||||||
mutex_enter(&p->p_smutex);
|
mutex_enter(&p->p_smutex);
|
||||||
|
@ -1739,7 +1739,7 @@ sysctl_kern_lwp(SYSCTLFN_ARGS)
|
||||||
needed += elem_size;
|
needed += elem_size;
|
||||||
}
|
}
|
||||||
mutex_exit(&p->p_smutex);
|
mutex_exit(&p->p_smutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
if (where != NULL) {
|
if (where != NULL) {
|
||||||
*oldlenp = dp - where;
|
*oldlenp = dp - where;
|
||||||
|
@ -1917,7 +1917,7 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
|
||||||
if (arg < -1)
|
if (arg < -1)
|
||||||
/* -1 means all processes */
|
/* -1 means all processes */
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
PROCLIST_FOREACH(p, &allproc) {
|
PROCLIST_FOREACH(p, &allproc) {
|
||||||
if (p->p_stat == SIDL)
|
if (p->p_stat == SIDL)
|
||||||
/* skip embryonic processes */
|
/* skip embryonic processes */
|
||||||
|
@ -1950,7 +1950,7 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
@ -2051,7 +2051,7 @@ sysctl_doeproc(SYSCTLFN_ARGS)
|
||||||
eproc = NULL;
|
eproc = NULL;
|
||||||
kproc2 = malloc(sizeof(*kproc2), M_TEMP, M_WAITOK);
|
kproc2 = malloc(sizeof(*kproc2), M_TEMP, M_WAITOK);
|
||||||
}
|
}
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
pd = proclists;
|
pd = proclists;
|
||||||
again:
|
again:
|
||||||
|
@ -2167,7 +2167,7 @@ again:
|
||||||
pd++;
|
pd++;
|
||||||
if (pd->pd_list != NULL)
|
if (pd->pd_list != NULL)
|
||||||
goto again;
|
goto again;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
if (where != NULL) {
|
if (where != NULL) {
|
||||||
if (type == KERN_PROC)
|
if (type == KERN_PROC)
|
||||||
|
@ -2188,7 +2188,7 @@ again:
|
||||||
free(eproc, M_TEMP);
|
free(eproc, M_TEMP);
|
||||||
return 0;
|
return 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
out:
|
out:
|
||||||
if (kproc2)
|
if (kproc2)
|
||||||
free(kproc2, M_TEMP);
|
free(kproc2, M_TEMP);
|
||||||
|
@ -2237,7 +2237,7 @@ sysctl_kern_proc_args(SYSCTLFN_ARGS)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
/* check pid */
|
/* check pid */
|
||||||
if ((p = p_find(pid, PFIND_LOCKED)) == NULL) {
|
if ((p = p_find(pid, PFIND_LOCKED)) == NULL) {
|
||||||
|
@ -2303,7 +2303,7 @@ sysctl_kern_proc_args(SYSCTLFN_ARGS)
|
||||||
vmspace = p->p_vmspace;
|
vmspace = p->p_vmspace;
|
||||||
vmspace->vm_refcnt++; /* XXX */
|
vmspace->vm_refcnt++; /* XXX */
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a temporary buffer to hold the arguments.
|
* Allocate a temporary buffer to hold the arguments.
|
||||||
|
@ -2440,7 +2440,7 @@ done:
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
out_locked:
|
out_locked:
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_acct.c,v 1.72 2007/03/04 06:03:03 christos Exp $ */
|
/* $NetBSD: kern_acct.c,v 1.73 2007/03/09 14:11:24 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1982, 1986, 1989, 1993
|
* Copyright (c) 1982, 1986, 1989, 1993
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.72 2007/03/04 06:03:03 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.73 2007/03/09 14:11:24 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -443,12 +443,12 @@ acct_process(struct lwp *l)
|
||||||
acct.ac_gid = kauth_cred_getgid(l->l_cred);
|
acct.ac_gid = kauth_cred_getgid(l->l_cred);
|
||||||
|
|
||||||
/* (7) The terminal from which the process was started */
|
/* (7) The terminal from which the process was started */
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if ((p->p_lflag & PL_CONTROLT) && p->p_pgrp->pg_session->s_ttyp)
|
if ((p->p_lflag & PL_CONTROLT) && p->p_pgrp->pg_session->s_ttyp)
|
||||||
acct.ac_tty = p->p_pgrp->pg_session->s_ttyp->t_dev;
|
acct.ac_tty = p->p_pgrp->pg_session->s_ttyp->t_dev;
|
||||||
else
|
else
|
||||||
acct.ac_tty = NODEV;
|
acct.ac_tty = NODEV;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
/* (8) The boolean flags that tell how the process terminated, etc. */
|
/* (8) The boolean flags that tell how the process terminated, etc. */
|
||||||
acct.ac_flag = p->p_acflag;
|
acct.ac_flag = p->p_acflag;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_core.c,v 1.3 2007/02/17 22:31:42 pavel Exp $ */
|
/* $NetBSD: kern_core.c,v 1.4 2007/03/09 14:11:24 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.3 2007/02/17 22:31:42 pavel Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.4 2007/03/09 14:11:24 ad Exp $");
|
||||||
|
|
||||||
#include "opt_coredump.h"
|
#include "opt_coredump.h"
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ coredump(struct lwp *l, const char *pattern)
|
||||||
p = l->l_proc;
|
p = l->l_proc;
|
||||||
vm = p->p_vmspace;
|
vm = p->p_vmspace;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER); /* p_session */
|
mutex_enter(&proclist_lock); /* p_session */
|
||||||
mutex_enter(&p->p_mutex);
|
mutex_enter(&p->p_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -102,7 +102,7 @@ coredump(struct lwp *l, const char *pattern)
|
||||||
*/
|
*/
|
||||||
if ((p->p_flag & PK_SUGID) && !security_setidcore_dump) {
|
if ((p->p_flag & PK_SUGID) && !security_setidcore_dump) {
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return EPERM;
|
return EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ coredump(struct lwp *l, const char *pattern)
|
||||||
if (USPACE + ctob(vm->vm_dsize + vm->vm_ssize) >=
|
if (USPACE + ctob(vm->vm_dsize + vm->vm_ssize) >=
|
||||||
p->p_rlimit[RLIMIT_CORE].rlim_cur) {
|
p->p_rlimit[RLIMIT_CORE].rlim_cur) {
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return EFBIG; /* better error code? */
|
return EFBIG; /* better error code? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ restart:
|
||||||
(vp->v_mount->mnt_flag & MNT_NOCOREDUMP) != 0) {
|
(vp->v_mount->mnt_flag & MNT_NOCOREDUMP) != 0) {
|
||||||
error = EPERM;
|
error = EPERM;
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ restart:
|
||||||
}
|
}
|
||||||
error = coredump_buildname(p, name, pattern, MAXPATHLEN);
|
error = coredump_buildname(p, name, pattern, MAXPATHLEN);
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, l);
|
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, l);
|
||||||
|
@ -166,7 +166,7 @@ restart:
|
||||||
if ((error = vn_start_write(NULL, &mp,
|
if ((error = vn_start_write(NULL, &mp,
|
||||||
V_WAIT | V_SLEEPONLY | V_PCATCH)) != 0)
|
V_WAIT | V_SLEEPONLY | V_PCATCH)) != 0)
|
||||||
goto done;
|
goto done;
|
||||||
rw_enter(&proclist_lock, RW_READER); /* p_session */
|
mutex_enter(&proclist_lock); /* p_session */
|
||||||
mutex_enter(&p->p_mutex);
|
mutex_enter(&p->p_mutex);
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ coredump_buildname(struct proc *p, char *dst, const char *src, size_t len)
|
||||||
char *d, *end;
|
char *d, *end;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_read_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
for (s = src, d = dst, end = d + len; *s != '\0'; s++) {
|
for (s = src, d = dst, end = d + len; *s != '\0'; s++) {
|
||||||
if (*s == '%') {
|
if (*s == '%') {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_descrip.c,v 1.151 2007/02/17 22:31:42 pavel Exp $ */
|
/* $NetBSD: kern_descrip.c,v 1.152 2007/03/09 14:11:24 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.151 2007/02/17 22:31:42 pavel Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.152 2007/03/09 14:11:24 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -1819,7 +1819,7 @@ restart:
|
||||||
if (devnullfp)
|
if (devnullfp)
|
||||||
FILE_UNUSE(devnullfp, l);
|
FILE_UNUSE(devnullfp, l);
|
||||||
if (closed[0] != '\0') {
|
if (closed[0] != '\0') {
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
pp = p->p_pptr;
|
pp = p->p_pptr;
|
||||||
mutex_enter(&pp->p_mutex);
|
mutex_enter(&pp->p_mutex);
|
||||||
log(LOG_WARNING, "set{u,g}id pid %d (%s) "
|
log(LOG_WARNING, "set{u,g}id pid %d (%s) "
|
||||||
|
@ -1828,7 +1828,7 @@ restart:
|
||||||
p->p_pid, p->p_comm, kauth_cred_geteuid(pp->p_cred),
|
p->p_pid, p->p_comm, kauth_cred_geteuid(pp->p_cred),
|
||||||
pp->p_pid, pp->p_comm, &closed[1]);
|
pp->p_pid, pp->p_comm, &closed[1]);
|
||||||
mutex_exit(&pp->p_mutex);
|
mutex_exit(&pp->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_exec.c,v 1.241 2007/03/05 04:59:20 dogcow Exp $ */
|
/* $NetBSD: kern_exec.c,v 1.242 2007/03/09 14:11:24 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
|
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.241 2007/03/05 04:59:20 dogcow Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.242 2007/03/09 14:11:24 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
#include "opt_syscall_debug.h"
|
#include "opt_syscall_debug.h"
|
||||||
|
@ -769,12 +769,12 @@ execve1(struct lwp *l, const char *path, char * const *args,
|
||||||
* exited and exec()/exit() are the only places it will be cleared.
|
* exited and exec()/exit() are the only places it will be cleared.
|
||||||
*/
|
*/
|
||||||
if ((p->p_sflag & PS_PPWAIT) != 0) {
|
if ((p->p_sflag & PS_PPWAIT) != 0) {
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
mutex_enter(&p->p_smutex);
|
mutex_enter(&p->p_smutex);
|
||||||
p->p_sflag &= ~PS_PPWAIT;
|
p->p_sflag &= ~PS_PPWAIT;
|
||||||
cv_broadcast(&p->p_pptr->p_waitcv);
|
cv_broadcast(&p->p_pptr->p_waitcv);
|
||||||
mutex_exit(&p->p_smutex);
|
mutex_exit(&p->p_smutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1161,7 +1161,7 @@ emul_unregister(const char *name)
|
||||||
* emul_unregister() is running quite sendomly, it's better
|
* emul_unregister() is running quite sendomly, it's better
|
||||||
* to do expensive check here than to use any locking.
|
* to do expensive check here than to use any locking.
|
||||||
*/
|
*/
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
for (pd = proclists; pd->pd_list != NULL && !error; pd++) {
|
for (pd = proclists; pd->pd_list != NULL && !error; pd++) {
|
||||||
PROCLIST_FOREACH(ptmp, pd->pd_list) {
|
PROCLIST_FOREACH(ptmp, pd->pd_list) {
|
||||||
if (ptmp->p_emul == it->el_emul) {
|
if (ptmp->p_emul == it->el_emul) {
|
||||||
|
@ -1170,7 +1170,7 @@ emul_unregister(const char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_exit.c,v 1.168 2007/02/22 06:34:43 thorpej Exp $ */
|
/* $NetBSD: kern_exit.c,v 1.169 2007/03/09 14:11:24 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998, 1999, 2006, 2007 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998, 1999, 2006, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.168 2007/02/22 06:34:43 thorpej Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.169 2007/03/09 14:11:24 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
#include "opt_perfctrs.h"
|
#include "opt_perfctrs.h"
|
||||||
|
@ -338,7 +338,7 @@ exit1(struct lwp *l, int rv)
|
||||||
* wake up the parent early to avoid deadlock. We can do this once
|
* wake up the parent early to avoid deadlock. We can do this once
|
||||||
* the VM resources are released.
|
* the VM resources are released.
|
||||||
*/
|
*/
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
mutex_enter(&p->p_smutex);
|
mutex_enter(&p->p_smutex);
|
||||||
if (p->p_sflag & PS_PPWAIT) {
|
if (p->p_sflag & PS_PPWAIT) {
|
||||||
|
@ -374,9 +374,9 @@ exit1(struct lwp *l, int rv)
|
||||||
TTY_UNLOCK(tp);
|
TTY_UNLOCK(tp);
|
||||||
splx(s);
|
splx(s);
|
||||||
SESSRELE(sp);
|
SESSRELE(sp);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
(void) ttywait(tp);
|
(void) ttywait(tp);
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The tty could have been revoked
|
* The tty could have been revoked
|
||||||
|
@ -398,12 +398,12 @@ exit1(struct lwp *l, int rv)
|
||||||
sp->s_leader = NULL;
|
sp->s_leader = NULL;
|
||||||
|
|
||||||
if (vprevoke != NULL || vprele != NULL) {
|
if (vprevoke != NULL || vprele != NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (vprevoke != NULL)
|
if (vprevoke != NULL)
|
||||||
VOP_REVOKE(vprevoke, REVOKEALL);
|
VOP_REVOKE(vprevoke, REVOKEALL);
|
||||||
if (vprele != NULL)
|
if (vprele != NULL)
|
||||||
vrele(vprele);
|
vrele(vprele);
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mutex_enter(&proclist_mutex);
|
mutex_enter(&proclist_mutex);
|
||||||
|
@ -562,7 +562,7 @@ exit1(struct lwp *l, int rv)
|
||||||
/*
|
/*
|
||||||
* Signal the parent to collect us, and drop the proclist lock.
|
* Signal the parent to collect us, and drop the proclist lock.
|
||||||
*/
|
*/
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
/* Verify that we hold no locks other than the kernel lock. */
|
/* Verify that we hold no locks other than the kernel lock. */
|
||||||
#ifdef MULTIPROCESSOR
|
#ifdef MULTIPROCESSOR
|
||||||
|
@ -684,16 +684,16 @@ sys_wait4(struct lwp *l, void *v, register_t *retval)
|
||||||
if (SCARG(uap, options) & ~(WUNTRACED|WNOHANG|WALTSIG|WALLSIG))
|
if (SCARG(uap, options) & ~(WUNTRACED|WNOHANG|WALTSIG|WALLSIG))
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
error = find_stopped_child(parent, SCARG(uap,pid), SCARG(uap,options),
|
error = find_stopped_child(parent, SCARG(uap,pid), SCARG(uap,options),
|
||||||
&child, &status);
|
&child, &status);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
*retval = 0;
|
*retval = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ sys_wait4(struct lwp *l, void *v, register_t *retval)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
/* Child state must have been SSTOP. */
|
/* Child state must have been SSTOP. */
|
||||||
if (SCARG(uap, status)) {
|
if (SCARG(uap, status)) {
|
||||||
|
@ -730,7 +730,7 @@ sys_wait4(struct lwp *l, void *v, register_t *retval)
|
||||||
* Scan list of child processes for a child process that has stopped or
|
* Scan list of child processes for a child process that has stopped or
|
||||||
* exited. Used by sys_wait4 and 'compat' equivalents.
|
* exited. Used by sys_wait4 and 'compat' equivalents.
|
||||||
*
|
*
|
||||||
* Must be called with the proclist_lock write held, and may release
|
* Must be called with the proclist_lock held, and may release
|
||||||
* while waiting.
|
* while waiting.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
@ -740,7 +740,7 @@ find_stopped_child(struct proc *parent, pid_t pid, int options,
|
||||||
struct proc *child, *dead;
|
struct proc *child, *dead;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
error = ECHILD;
|
error = ECHILD;
|
||||||
|
@ -824,10 +824,10 @@ find_stopped_child(struct proc *parent, pid_t pid, int options,
|
||||||
/*
|
/*
|
||||||
* Wait for another child process to stop.
|
* Wait for another child process to stop.
|
||||||
*/
|
*/
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
error = cv_wait_sig(&parent->p_waitcv, &proclist_mutex);
|
error = cv_wait_sig(&parent->p_waitcv, &proclist_mutex);
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return error;
|
return error;
|
||||||
|
@ -836,7 +836,7 @@ find_stopped_child(struct proc *parent, pid_t pid, int options,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free a process after parent has taken all the state info. Must be called
|
* Free a process after parent has taken all the state info. Must be called
|
||||||
* with the proclist lock write held, and will release before returning.
|
* with the proclist lock held, and will release before returning.
|
||||||
*
|
*
|
||||||
* *ru is returned to the caller, and must be freed by the caller.
|
* *ru is returned to the caller, and must be freed by the caller.
|
||||||
*/
|
*/
|
||||||
|
@ -853,8 +853,7 @@ proc_free(struct proc *p, struct rusage *caller_ru)
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
KASSERT(p->p_nlwps == 1);
|
KASSERT(p->p_nlwps == 1);
|
||||||
KASSERT(p->p_nzlwps == 1);
|
KASSERT(p->p_nzlwps == 1);
|
||||||
KASSERT(p->p_nrlwps == 0);
|
KASSERT(p->p_nrlwps == 0);
|
||||||
|
@ -889,7 +888,7 @@ proc_free(struct proc *p, struct rusage *caller_ru)
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
}
|
}
|
||||||
cv_wakeup(&parent->p_waitcv); /* XXXSMP */
|
cv_wakeup(&parent->p_waitcv); /* XXXSMP */
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -934,12 +933,12 @@ proc_free(struct proc *p, struct rusage *caller_ru)
|
||||||
*/
|
*/
|
||||||
if (l->l_cpu->ci_curlwp == l) {
|
if (l->l_cpu->ci_curlwp == l) {
|
||||||
int count;
|
int count;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
KERNEL_UNLOCK_ALL(l, &count);
|
KERNEL_UNLOCK_ALL(l, &count);
|
||||||
while (l->l_cpu->ci_curlwp == l)
|
while (l->l_cpu->ci_curlwp == l)
|
||||||
SPINLOCK_BACKOFF_HOOK;
|
SPINLOCK_BACKOFF_HOOK;
|
||||||
KERNEL_LOCK(count, l);
|
KERNEL_LOCK(count, l);
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -997,13 +996,13 @@ proc_free(struct proc *p, struct rusage *caller_ru)
|
||||||
/*
|
/*
|
||||||
* make process 'parent' the new parent of process 'child'.
|
* make process 'parent' the new parent of process 'child'.
|
||||||
*
|
*
|
||||||
* Must be called with proclist_lock write locked held.
|
* Must be called with proclist_lock lock held.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
proc_reparent(struct proc *child, struct proc *parent)
|
proc_reparent(struct proc *child, struct proc *parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
if (child->p_pptr == parent)
|
if (child->p_pptr == parent)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_fork.c,v 1.135 2007/03/04 06:03:03 christos Exp $ */
|
/* $NetBSD: kern_fork.c,v 1.136 2007/03/09 14:11:24 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999, 2001, 2004 The NetBSD Foundation, Inc.
|
* Copyright (c) 1999, 2001, 2004 The NetBSD Foundation, Inc.
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.135 2007/03/04 06:03:03 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.136 2007/03/09 14:11:24 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
#include "opt_systrace.h"
|
#include "opt_systrace.h"
|
||||||
|
@ -440,7 +440,7 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
|
||||||
* It's now safe for the scheduler and other processes to see the
|
* It's now safe for the scheduler and other processes to see the
|
||||||
* child process.
|
* child process.
|
||||||
*/
|
*/
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
if (p1->p_session->s_ttyvp != NULL && p1->p_lflag & PL_CONTROLT)
|
if (p1->p_session->s_ttyvp != NULL && p1->p_lflag & PL_CONTROLT)
|
||||||
p2->p_lflag |= PL_CONTROLT;
|
p2->p_lflag |= PL_CONTROLT;
|
||||||
|
@ -453,7 +453,7 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
|
||||||
LIST_INSERT_HEAD(&allproc, p2, p_list);
|
LIST_INSERT_HEAD(&allproc, p2, p_list);
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
#ifdef SYSTRACE
|
#ifdef SYSTRACE
|
||||||
/* Tell systrace what's happening. */
|
/* Tell systrace what's happening. */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_ktrace.c,v 1.118 2007/03/04 06:03:03 christos Exp $ */
|
/* $NetBSD: kern_ktrace.c,v 1.119 2007/03/09 14:11:24 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.118 2007/03/04 06:03:03 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.119 2007/03/09 14:11:24 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
#include "opt_compat_mach.h"
|
#include "opt_compat_mach.h"
|
||||||
|
@ -161,7 +161,7 @@ ktd_wakeup(struct ktr_desc *ktd)
|
||||||
{
|
{
|
||||||
|
|
||||||
callout_stop(&ktd->ktd_wakch);
|
callout_stop(&ktd->ktd_wakch);
|
||||||
cv_broadcast(&ktd->ktd_cv);
|
cv_wakeup(&ktd->ktd_cv); /* XXXSMP */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -178,7 +178,7 @@ ktd_logerr(struct proc *p, int error)
|
||||||
{
|
{
|
||||||
struct ktr_desc *ktd;
|
struct ktr_desc *ktd;
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&ktrace_mutex));
|
KASSERT(mutex_owned(&ktrace_mutex));
|
||||||
|
|
||||||
ktd = p->p_tracep;
|
ktd = p->p_tracep;
|
||||||
if (ktd == NULL)
|
if (ktd == NULL)
|
||||||
|
@ -222,7 +222,7 @@ void
|
||||||
ktdrel(struct ktr_desc *ktd)
|
ktdrel(struct ktr_desc *ktd)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&ktrace_mutex));
|
KASSERT(mutex_owned(&ktrace_mutex));
|
||||||
|
|
||||||
KDASSERT(ktd->ktd_ref != 0);
|
KDASSERT(ktd->ktd_ref != 0);
|
||||||
KASSERT(ktd->ktd_ref > 0);
|
KASSERT(ktd->ktd_ref > 0);
|
||||||
|
@ -236,7 +236,7 @@ void
|
||||||
ktdref(struct ktr_desc *ktd)
|
ktdref(struct ktr_desc *ktd)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&ktrace_mutex));
|
KASSERT(mutex_owned(&ktrace_mutex));
|
||||||
|
|
||||||
ktd->ktd_ref++;
|
ktd->ktd_ref++;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ ktd_lookup(struct file *fp)
|
||||||
{
|
{
|
||||||
struct ktr_desc *ktd;
|
struct ktr_desc *ktd;
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&ktrace_mutex));
|
KASSERT(mutex_owned(&ktrace_mutex));
|
||||||
|
|
||||||
for (ktd = TAILQ_FIRST(&ktdq); ktd != NULL;
|
for (ktd = TAILQ_FIRST(&ktdq); ktd != NULL;
|
||||||
ktd = TAILQ_NEXT(ktd, ktd_list)) {
|
ktd = TAILQ_NEXT(ktd, ktd_list)) {
|
||||||
|
@ -399,7 +399,7 @@ ktrderef(struct proc *p)
|
||||||
{
|
{
|
||||||
struct ktr_desc *ktd = p->p_tracep;
|
struct ktr_desc *ktd = p->p_tracep;
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&ktrace_mutex));
|
KASSERT(mutex_owned(&ktrace_mutex));
|
||||||
|
|
||||||
p->p_traceflag = 0;
|
p->p_traceflag = 0;
|
||||||
if (ktd == NULL)
|
if (ktd == NULL)
|
||||||
|
@ -415,7 +415,7 @@ ktradref(struct proc *p)
|
||||||
{
|
{
|
||||||
struct ktr_desc *ktd = p->p_tracep;
|
struct ktr_desc *ktd = p->p_tracep;
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&ktrace_mutex));
|
KASSERT(mutex_owned(&ktrace_mutex));
|
||||||
|
|
||||||
ktdref(ktd);
|
ktdref(ktd);
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ ktrderefall(struct ktr_desc *ktd, int auth)
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
PROCLIST_FOREACH(p, &allproc) {
|
PROCLIST_FOREACH(p, &allproc) {
|
||||||
if (p->p_tracep != ktd)
|
if (p->p_tracep != ktd)
|
||||||
continue;
|
continue;
|
||||||
|
@ -442,7 +442,7 @@ ktrderefall(struct ktr_desc *ktd, int auth)
|
||||||
mutex_exit(&ktrace_mutex);
|
mutex_exit(&ktrace_mutex);
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -934,7 +934,7 @@ ktrace_common(struct lwp *curl, int ops, int facs, int pid, struct file *fp)
|
||||||
/*
|
/*
|
||||||
* do it
|
* do it
|
||||||
*/
|
*/
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
/*
|
/*
|
||||||
* by process group
|
* by process group
|
||||||
|
@ -965,7 +965,7 @@ ktrace_common(struct lwp *curl, int ops, int facs, int pid, struct file *fp)
|
||||||
else
|
else
|
||||||
ret |= ktrops(curl, p, ops, facs, ktd);
|
ret |= ktrops(curl, p, ops, facs, ktd);
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock); /* taken by p{g}_find */
|
mutex_exit(&proclist_lock); /* taken by p{g}_find */
|
||||||
if (error == 0 && !ret)
|
if (error == 0 && !ret)
|
||||||
error = EPERM;
|
error = EPERM;
|
||||||
done:
|
done:
|
||||||
|
@ -1162,7 +1162,7 @@ ktrsetchildren(struct lwp *curl, struct proc *top, int ops, int facs,
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_lock_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
p = top;
|
p = top;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -1337,8 +1337,8 @@ ktrace_thread(void *arg)
|
||||||
int
|
int
|
||||||
ktrcanset(struct lwp *calll, struct proc *targetp)
|
ktrcanset(struct lwp *calll, struct proc *targetp)
|
||||||
{
|
{
|
||||||
LOCK_ASSERT(mutex_owned(&targetp->p_mutex));
|
KASSERT(mutex_owned(&targetp->p_mutex));
|
||||||
LOCK_ASSERT(mutex_owned(&ktrace_mutex));
|
KASSERT(mutex_owned(&ktrace_mutex));
|
||||||
|
|
||||||
if (kauth_authorize_process(calll->l_cred, KAUTH_PROCESS_CANKTRACE,
|
if (kauth_authorize_process(calll->l_cred, KAUTH_PROCESS_CANKTRACE,
|
||||||
targetp, NULL, NULL, NULL) == 0)
|
targetp, NULL, NULL, NULL) == 0)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_proc.c,v 1.106 2007/03/04 06:03:05 christos Exp $ */
|
/* $NetBSD: kern_proc.c,v 1.107 2007/03/09 14:11:25 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc.
|
* Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.106 2007/03/04 06:03:05 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.107 2007/03/09 14:11:25 ad Exp $");
|
||||||
|
|
||||||
#include "opt_kstack.h"
|
#include "opt_kstack.h"
|
||||||
#include "opt_maxuprc.h"
|
#include "opt_maxuprc.h"
|
||||||
|
@ -112,14 +112,15 @@ struct proclist zombproc; /* resources have been freed */
|
||||||
/*
|
/*
|
||||||
* There are two locks on global process state.
|
* There are two locks on global process state.
|
||||||
*
|
*
|
||||||
* 1. proclist_lock is a reader/writer lock and is used when modifying or
|
* 1. proclist_lock is an adaptive mutex and is used when modifying
|
||||||
* examining process state from a process context. It protects our internal
|
* or examining process state from a process context. It protects
|
||||||
* tables, all of the process lists, and a number of members of struct lwp
|
* the internal tables, all of the process lists, and a number of
|
||||||
* and struct proc.
|
* members of struct proc.
|
||||||
|
*
|
||||||
* 2. proclist_mutex is used when allproc must be traversed from an
|
* 2. proclist_mutex is used when allproc must be traversed from an
|
||||||
* interrupt context, or when we must signal processes from an interrupt
|
* interrupt context, or when changing the state of processes. The
|
||||||
* context. The proclist_lock should always be used in preference.
|
* proclist_lock should always be used in preference. In some cases,
|
||||||
|
* both locks need to be held.
|
||||||
*
|
*
|
||||||
* proclist_lock proclist_mutex structure
|
* proclist_lock proclist_mutex structure
|
||||||
* --------------- --------------- -----------------
|
* --------------- --------------- -----------------
|
||||||
|
@ -138,13 +139,23 @@ struct proclist zombproc; /* resources have been freed */
|
||||||
*
|
*
|
||||||
* The lock order for processes and LWPs is approximately as following:
|
* The lock order for processes and LWPs is approximately as following:
|
||||||
*
|
*
|
||||||
* kernel_mutex
|
* kernel_lock
|
||||||
* -> proclist_lock
|
* -> proclist_lock
|
||||||
* -> proclist_mutex
|
* -> proc::p_mutex
|
||||||
* -> proc::p_mutex
|
* -> proclist_mutex
|
||||||
* -> proc::p_smutex
|
* -> proc::p_smutex
|
||||||
|
* -> proc::p_stmutex
|
||||||
|
*
|
||||||
|
* XXX p_smutex can be run at IPL_VM once audio drivers on the x86
|
||||||
|
* platform are made MP safe. Currently it blocks interrupts at
|
||||||
|
* IPL_SCHED and below.
|
||||||
|
*
|
||||||
|
* XXX The two process locks (p_smutex + p_mutex), and the two global
|
||||||
|
* state locks (proclist_lock + proclist_mutex) should be merged
|
||||||
|
* together. However, to do so requires interrupts that interrupts
|
||||||
|
* be run with LWP context.
|
||||||
*/
|
*/
|
||||||
krwlock_t proclist_lock;
|
kmutex_t proclist_lock;
|
||||||
kmutex_t proclist_mutex;
|
kmutex_t proclist_mutex;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -250,11 +261,7 @@ procinit(void)
|
||||||
for (pd = proclists; pd->pd_list != NULL; pd++)
|
for (pd = proclists; pd->pd_list != NULL; pd++)
|
||||||
LIST_INIT(pd->pd_list);
|
LIST_INIT(pd->pd_list);
|
||||||
|
|
||||||
/*
|
mutex_init(&proclist_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||||
* XXX p_smutex can be IPL_VM except for audio drivers
|
|
||||||
* XXX proclist_lock must die
|
|
||||||
*/
|
|
||||||
rw_init(&proclist_lock);
|
|
||||||
mutex_init(&proclist_mutex, MUTEX_SPIN, IPL_SCHED);
|
mutex_init(&proclist_mutex, MUTEX_SPIN, IPL_SCHED);
|
||||||
|
|
||||||
pid_table = malloc(INITIAL_PID_TABLE_SIZE * sizeof *pid_table,
|
pid_table = malloc(INITIAL_PID_TABLE_SIZE * sizeof *pid_table,
|
||||||
|
@ -301,11 +308,16 @@ proc0_init(void)
|
||||||
sess = &session0;
|
sess = &session0;
|
||||||
l = &lwp0;
|
l = &lwp0;
|
||||||
|
|
||||||
/* XXX p_smutex can be IPL_VM except for audio drivers */
|
/*
|
||||||
|
* XXX p_rasmutex is run at IPL_SCHED, because of lock order
|
||||||
|
* issues (kernel_lock -> p_rasmutex). Ideally ras_lookup
|
||||||
|
* should operate "lock free".
|
||||||
|
*/
|
||||||
mutex_init(&p->p_smutex, MUTEX_SPIN, IPL_SCHED);
|
mutex_init(&p->p_smutex, MUTEX_SPIN, IPL_SCHED);
|
||||||
mutex_init(&p->p_stmutex, MUTEX_SPIN, IPL_STATCLOCK);
|
mutex_init(&p->p_stmutex, MUTEX_SPIN, IPL_STATCLOCK);
|
||||||
mutex_init(&p->p_rasmutex, MUTEX_SPIN, IPL_NONE);
|
mutex_init(&p->p_rasmutex, MUTEX_SPIN, IPL_SCHED);
|
||||||
mutex_init(&p->p_mutex, MUTEX_DEFAULT, IPL_NONE);
|
mutex_init(&p->p_mutex, MUTEX_DEFAULT, IPL_NONE);
|
||||||
|
|
||||||
cv_init(&p->p_refcv, "drainref");
|
cv_init(&p->p_refcv, "drainref");
|
||||||
cv_init(&p->p_waitcv, "wait");
|
cv_init(&p->p_waitcv, "wait");
|
||||||
cv_init(&p->p_lwpcv, "lwpwait");
|
cv_init(&p->p_lwpcv, "lwpwait");
|
||||||
|
@ -437,9 +449,9 @@ pgid_in_session(struct proc *p, pid_t pg_id)
|
||||||
{
|
{
|
||||||
struct pgrp *pgrp;
|
struct pgrp *pgrp;
|
||||||
struct session *session;
|
struct session *session;
|
||||||
|
int error;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
if (pg_id < 0) {
|
if (pg_id < 0) {
|
||||||
struct proc *p1 = p_find(-pg_id, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
struct proc *p1 = p_find(-pg_id, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
||||||
if (p1 == NULL)
|
if (p1 == NULL)
|
||||||
|
@ -451,10 +463,13 @@ pgid_in_session(struct proc *p, pid_t pg_id)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
session = pgrp->pg_session;
|
session = pgrp->pg_session;
|
||||||
rw_exit(&proclist_lock);
|
|
||||||
if (session != p->p_pgrp->pg_session)
|
if (session != p->p_pgrp->pg_session)
|
||||||
return EPERM;
|
error = EPERM;
|
||||||
return 0;
|
else
|
||||||
|
error = 0;
|
||||||
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -482,7 +497,7 @@ p_find(pid_t pid, uint flags)
|
||||||
char stat;
|
char stat;
|
||||||
|
|
||||||
if (!(flags & PFIND_LOCKED))
|
if (!(flags & PFIND_LOCKED))
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
p = pid_table[pid & pid_tbl_mask].pt_proc;
|
p = pid_table[pid & pid_tbl_mask].pt_proc;
|
||||||
|
|
||||||
|
@ -492,11 +507,11 @@ p_find(pid_t pid, uint flags)
|
||||||
stat == SSTOP || ((flags & PFIND_ZOMBIE) &&
|
stat == SSTOP || ((flags & PFIND_ZOMBIE) &&
|
||||||
(stat == SZOMB || stat == SDEAD || stat == SDYING)))) {
|
(stat == SZOMB || stat == SDEAD || stat == SDYING)))) {
|
||||||
if (flags & PFIND_UNLOCK_OK)
|
if (flags & PFIND_UNLOCK_OK)
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
if (flags & PFIND_UNLOCK_FAIL)
|
if (flags & PFIND_UNLOCK_FAIL)
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +525,7 @@ pg_find(pid_t pgid, uint flags)
|
||||||
struct pgrp *pg;
|
struct pgrp *pg;
|
||||||
|
|
||||||
if (!(flags & PFIND_LOCKED))
|
if (!(flags & PFIND_LOCKED))
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
pg = pid_table[pgid & pid_tbl_mask].pt_pgrp;
|
pg = pid_table[pgid & pid_tbl_mask].pt_pgrp;
|
||||||
/*
|
/*
|
||||||
* Can't look up a pgrp that only exists because the session
|
* Can't look up a pgrp that only exists because the session
|
||||||
|
@ -518,12 +533,12 @@ pg_find(pid_t pgid, uint flags)
|
||||||
*/
|
*/
|
||||||
if (pg == NULL || pg->pg_id != pgid || LIST_EMPTY(&pg->pg_members)) {
|
if (pg == NULL || pg->pg_id != pgid || LIST_EMPTY(&pg->pg_members)) {
|
||||||
if (flags & PFIND_UNLOCK_FAIL)
|
if (flags & PFIND_UNLOCK_FAIL)
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & PFIND_UNLOCK_OK)
|
if (flags & PFIND_UNLOCK_OK)
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return pg;
|
return pg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,10 +554,10 @@ expand_pid_table(void)
|
||||||
|
|
||||||
new_pt = malloc(pt_size * 2 * sizeof *new_pt, M_PROC, M_WAITOK);
|
new_pt = malloc(pt_size * 2 * sizeof *new_pt, M_PROC, M_WAITOK);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
if (pt_size != pid_tbl_mask + 1) {
|
if (pt_size != pid_tbl_mask + 1) {
|
||||||
/* Another process beat us to it... */
|
/* Another process beat us to it... */
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
FREE(new_pt, M_PROC);
|
FREE(new_pt, M_PROC);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -603,7 +618,7 @@ expand_pid_table(void)
|
||||||
} else
|
} else
|
||||||
pid_alloc_lim <<= 1; /* doubles number of free slots... */
|
pid_alloc_lim <<= 1; /* doubles number of free slots... */
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
FREE(n_pt, M_PROC);
|
FREE(n_pt, M_PROC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,7 +640,7 @@ proc_alloc(void)
|
||||||
if (__predict_false(pid_alloc_cnt >= pid_alloc_lim))
|
if (__predict_false(pid_alloc_cnt >= pid_alloc_lim))
|
||||||
/* ensure pids cycle through 2000+ values */
|
/* ensure pids cycle through 2000+ values */
|
||||||
continue;
|
continue;
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
pt = &pid_table[next_free_pt];
|
pt = &pid_table[next_free_pt];
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (__predict_false(P_VALID(pt->pt_proc) || pt->pt_pgrp))
|
if (__predict_false(P_VALID(pt->pt_proc) || pt->pt_pgrp))
|
||||||
|
@ -635,7 +650,7 @@ proc_alloc(void)
|
||||||
if (nxt & pid_tbl_mask)
|
if (nxt & pid_tbl_mask)
|
||||||
break;
|
break;
|
||||||
/* Table full - expand (NB last entry not used....) */
|
/* Table full - expand (NB last entry not used....) */
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pid is 'saved use count' + 'size' + entry */
|
/* pid is 'saved use count' + 'size' + entry */
|
||||||
|
@ -651,7 +666,7 @@ proc_alloc(void)
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
pid_alloc_cnt++;
|
pid_alloc_cnt++;
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -659,7 +674,7 @@ proc_alloc(void)
|
||||||
/*
|
/*
|
||||||
* Free last resources of a process - called from proc_free (in kern_exit.c)
|
* Free last resources of a process - called from proc_free (in kern_exit.c)
|
||||||
*
|
*
|
||||||
* Called with the proclist_lock write held, and releases upon exit.
|
* Called with the proclist_lock held, and releases upon exit.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
proc_free_mem(struct proc *p)
|
proc_free_mem(struct proc *p)
|
||||||
|
@ -667,7 +682,7 @@ proc_free_mem(struct proc *p)
|
||||||
pid_t pid = p->p_pid;
|
pid_t pid = p->p_pid;
|
||||||
struct pid_table *pt;
|
struct pid_table *pt;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
pt = &pid_table[pid & pid_tbl_mask];
|
pt = &pid_table[pid & pid_tbl_mask];
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
|
@ -690,7 +705,7 @@ proc_free_mem(struct proc *p)
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
|
|
||||||
nprocs--;
|
nprocs--;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
pool_put(&proc_pool, p);
|
pool_put(&proc_pool, p);
|
||||||
}
|
}
|
||||||
|
@ -716,21 +731,19 @@ enterpgrp(struct proc *curp, pid_t pid, pid_t pgid, int mksess)
|
||||||
int rval;
|
int rval;
|
||||||
pid_t pg_id = NO_PGID;
|
pid_t pg_id = NO_PGID;
|
||||||
|
|
||||||
/* Allocate data areas we might need before doing any validity checks */
|
|
||||||
rw_enter(&proclist_lock, RW_READER); /* Because pid_table might change */
|
|
||||||
if (pid_table[pgid & pid_tbl_mask].pt_pgrp == 0) {
|
|
||||||
rw_exit(&proclist_lock);
|
|
||||||
new_pgrp = pool_get(&pgrp_pool, PR_WAITOK);
|
|
||||||
} else {
|
|
||||||
rw_exit(&proclist_lock);
|
|
||||||
new_pgrp = NULL;
|
|
||||||
}
|
|
||||||
if (mksess)
|
if (mksess)
|
||||||
sess = pool_get(&session_pool, PR_WAITOK);
|
sess = pool_get(&session_pool, PR_WAITOK);
|
||||||
else
|
else
|
||||||
sess = NULL;
|
sess = NULL;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
/* Allocate data areas we might need before doing any validity checks */
|
||||||
|
mutex_enter(&proclist_lock); /* Because pid_table might change */
|
||||||
|
if (pid_table[pgid & pid_tbl_mask].pt_pgrp == 0) {
|
||||||
|
mutex_exit(&proclist_lock);
|
||||||
|
new_pgrp = pool_get(&pgrp_pool, PR_WAITOK);
|
||||||
|
mutex_enter(&proclist_lock);
|
||||||
|
} else
|
||||||
|
new_pgrp = NULL;
|
||||||
rval = EPERM; /* most common error (to save typing) */
|
rval = EPERM; /* most common error (to save typing) */
|
||||||
|
|
||||||
/* Check pgrp exists or can be created */
|
/* Check pgrp exists or can be created */
|
||||||
|
@ -871,7 +884,7 @@ enterpgrp(struct proc *curp, pid_t pid, pid_t pgid, int mksess)
|
||||||
done:
|
done:
|
||||||
if (pg_id != NO_PGID)
|
if (pg_id != NO_PGID)
|
||||||
pg_delete(pg_id);
|
pg_delete(pg_id);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (sess != NULL)
|
if (sess != NULL)
|
||||||
pool_put(&session_pool, sess);
|
pool_put(&session_pool, sess);
|
||||||
if (new_pgrp != NULL)
|
if (new_pgrp != NULL)
|
||||||
|
@ -886,14 +899,14 @@ enterpgrp(struct proc *curp, pid_t pid, pid_t pgid, int mksess)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove a process from its process group. Must be called with the
|
* Remove a process from its process group. Must be called with the
|
||||||
* proclist_lock write held.
|
* proclist_lock held.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
leavepgrp(struct proc *p)
|
leavepgrp(struct proc *p)
|
||||||
{
|
{
|
||||||
struct pgrp *pgrp;
|
struct pgrp *pgrp;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there's a controlling terminal for the session, we have to
|
* If there's a controlling terminal for the session, we have to
|
||||||
|
@ -923,7 +936,7 @@ leavepgrp(struct proc *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free a process group. Must be called with the proclist_lock write held.
|
* Free a process group. Must be called with the proclist_lock held.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
pg_free(pid_t pg_id)
|
pg_free(pid_t pg_id)
|
||||||
|
@ -931,7 +944,7 @@ pg_free(pid_t pg_id)
|
||||||
struct pgrp *pgrp;
|
struct pgrp *pgrp;
|
||||||
struct pid_table *pt;
|
struct pid_table *pt;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
pt = &pid_table[pg_id & pid_tbl_mask];
|
pt = &pid_table[pg_id & pid_tbl_mask];
|
||||||
pgrp = pt->pt_pgrp;
|
pgrp = pt->pt_pgrp;
|
||||||
|
@ -960,8 +973,7 @@ pg_free(pid_t pg_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete a process group. Must be called with the proclist_lock write
|
* Delete a process group. Must be called with the proclist_lock held.
|
||||||
* held.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
pg_delete(pid_t pg_id)
|
pg_delete(pid_t pg_id)
|
||||||
|
@ -971,7 +983,7 @@ pg_delete(pid_t pg_id)
|
||||||
struct session *ss;
|
struct session *ss;
|
||||||
int is_pgrp_leader;
|
int is_pgrp_leader;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
pgrp = pid_table[pg_id & pid_tbl_mask].pt_pgrp;
|
pgrp = pid_table[pg_id & pid_tbl_mask].pt_pgrp;
|
||||||
if (pgrp == NULL || pgrp->pg_id != pg_id ||
|
if (pgrp == NULL || pgrp->pg_id != pg_id ||
|
||||||
|
@ -1005,13 +1017,13 @@ pg_delete(pid_t pg_id)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete session - called from SESSRELE when s_count becomes zero.
|
* Delete session - called from SESSRELE when s_count becomes zero.
|
||||||
* Must be called with the proclist_lock write held.
|
* Must be called with the proclist_lock held.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
sessdelete(struct session *ss)
|
sessdelete(struct session *ss)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We keep the pgrp with the same id as the session in
|
* We keep the pgrp with the same id as the session in
|
||||||
|
@ -1033,7 +1045,7 @@ sessdelete(struct session *ss)
|
||||||
* entering == 0 => p is leaving specified group.
|
* entering == 0 => p is leaving specified group.
|
||||||
* entering == 1 => p is entering specified group.
|
* entering == 1 => p is entering specified group.
|
||||||
*
|
*
|
||||||
* Call with proclist_lock write held.
|
* Call with proclist_lock held.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
|
fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
|
||||||
|
@ -1042,8 +1054,8 @@ fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
|
||||||
struct session *mysession = pgrp->pg_session;
|
struct session *mysession = pgrp->pg_session;
|
||||||
struct proc *child;
|
struct proc *child;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
LOCK_ASSERT(mutex_owned(&proclist_mutex));
|
KASSERT(mutex_owned(&proclist_mutex));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check p's parent to see whether p qualifies its own process
|
* Check p's parent to see whether p qualifies its own process
|
||||||
|
@ -1085,7 +1097,7 @@ fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
|
||||||
* if there are any stopped processes in the group,
|
* if there are any stopped processes in the group,
|
||||||
* hang-up all process in that group.
|
* hang-up all process in that group.
|
||||||
*
|
*
|
||||||
* Call with proclist_lock write held.
|
* Call with proclist_lock held.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
orphanpg(struct pgrp *pg)
|
orphanpg(struct pgrp *pg)
|
||||||
|
@ -1093,8 +1105,8 @@ orphanpg(struct pgrp *pg)
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
int doit;
|
int doit;
|
||||||
|
|
||||||
LOCK_ASSERT(rw_write_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
LOCK_ASSERT(mutex_owned(&proclist_mutex));
|
KASSERT(mutex_owned(&proclist_mutex));
|
||||||
|
|
||||||
doit = 0;
|
doit = 0;
|
||||||
|
|
||||||
|
@ -1252,7 +1264,7 @@ proclist_foreach_call(struct proclist *list,
|
||||||
|
|
||||||
marker.p_flag = PK_MARKER;
|
marker.p_flag = PK_MARKER;
|
||||||
PHOLD(l);
|
PHOLD(l);
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
for (p = LIST_FIRST(list); ret == 0 && p != NULL;) {
|
for (p = LIST_FIRST(list); ret == 0 && p != NULL;) {
|
||||||
if (p->p_flag & PK_MARKER) {
|
if (p->p_flag & PK_MARKER) {
|
||||||
p = LIST_NEXT(p, p_list);
|
p = LIST_NEXT(p, p_list);
|
||||||
|
@ -1260,11 +1272,11 @@ proclist_foreach_call(struct proclist *list,
|
||||||
}
|
}
|
||||||
LIST_INSERT_AFTER(p, &marker, p_list);
|
LIST_INSERT_AFTER(p, &marker, p_list);
|
||||||
ret = (*callback)(p, arg);
|
ret = (*callback)(p, arg);
|
||||||
KASSERT(rw_read_held(&proclist_lock));
|
KASSERT(mutex_owned(&proclist_lock));
|
||||||
p = LIST_NEXT(&marker, p_list);
|
p = LIST_NEXT(&marker, p_list);
|
||||||
LIST_REMOVE(&marker, p_list);
|
LIST_REMOVE(&marker, p_list);
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
PRELE(l);
|
PRELE(l);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1381,7 +1393,7 @@ int
|
||||||
proc_addref(struct proc *p)
|
proc_addref(struct proc *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&p->p_mutex));
|
KASSERT(mutex_owned(&p->p_mutex));
|
||||||
|
|
||||||
if (p->p_refcnt <= 0)
|
if (p->p_refcnt <= 0)
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
|
@ -1397,7 +1409,7 @@ void
|
||||||
proc_delref(struct proc *p)
|
proc_delref(struct proc *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&p->p_mutex));
|
KASSERT(mutex_owned(&p->p_mutex));
|
||||||
|
|
||||||
if (p->p_refcnt < 0) {
|
if (p->p_refcnt < 0) {
|
||||||
if (++p->p_refcnt == 0)
|
if (++p->p_refcnt == 0)
|
||||||
|
@ -1416,7 +1428,7 @@ void
|
||||||
proc_drainrefs(struct proc *p)
|
proc_drainrefs(struct proc *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCK_ASSERT(mutex_owned(&p->p_mutex));
|
KASSERT(mutex_owned(&p->p_mutex));
|
||||||
KASSERT(p->p_refcnt > 0);
|
KASSERT(p->p_refcnt > 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_prot.c,v 1.100 2007/03/04 06:03:06 christos Exp $ */
|
/* $NetBSD: kern_prot.c,v 1.101 2007/03/09 14:11:25 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
|
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.100 2007/03/04 06:03:06 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.101 2007/03/09 14:11:25 ad Exp $");
|
||||||
|
|
||||||
#include "opt_compat_43.h"
|
#include "opt_compat_43.h"
|
||||||
|
|
||||||
|
@ -88,9 +88,9 @@ sys_getpid_with_ppid(struct lwp *l, void *v, register_t *retval)
|
||||||
struct proc *p = l->l_proc;
|
struct proc *p = l->l_proc;
|
||||||
|
|
||||||
retval[0] = p->p_pid;
|
retval[0] = p->p_pid;
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
retval[1] = p->p_pptr->p_pid;
|
retval[1] = p->p_pptr->p_pid;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ sys_getppid(struct lwp *l, void *v, register_t *retval)
|
||||||
{
|
{
|
||||||
struct proc *p = l->l_proc;
|
struct proc *p = l->l_proc;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
*retval = p->p_pptr->p_pid;
|
*retval = p->p_pptr->p_pid;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,9 +112,9 @@ sys_getpgrp(struct lwp *l, void *v, register_t *retval)
|
||||||
{
|
{
|
||||||
struct proc *p = l->l_proc;
|
struct proc *p = l->l_proc;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
*retval = p->p_pgrp->pg_id;
|
*retval = p->p_pgrp->pg_id;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,14 +132,14 @@ sys_getsid(struct lwp *l, void *v, register_t *retval)
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
*retval = l->l_proc->p_session->s_sid;
|
*retval = l->l_proc->p_session->s_sid;
|
||||||
else if ((p = p_find(pid, PFIND_LOCKED)) != NULL)
|
else if ((p = p_find(pid, PFIND_LOCKED)) != NULL)
|
||||||
*retval = p->p_session->s_sid;
|
*retval = p->p_session->s_sid;
|
||||||
else
|
else
|
||||||
error = ESRCH;
|
error = ESRCH;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -154,14 +154,14 @@ sys_getpgid(struct lwp *l, void *v, register_t *retval)
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
*retval = l->l_proc->p_pgid;
|
*retval = l->l_proc->p_pgid;
|
||||||
else if ((p = p_find(pid, PFIND_LOCKED)) != NULL)
|
else if ((p = p_find(pid, PFIND_LOCKED)) != NULL)
|
||||||
*retval = p->p_pgid;
|
*retval = p->p_pgid;
|
||||||
else
|
else
|
||||||
error = ESRCH;
|
error = ESRCH;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -670,9 +670,9 @@ sys___getlogin(struct lwp *l, void *v, register_t *retval)
|
||||||
|
|
||||||
if (namelen > sizeof(login))
|
if (namelen > sizeof(login))
|
||||||
namelen = sizeof(login);
|
namelen = sizeof(login);
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
memcpy(login, p->p_session->s_login, namelen);
|
memcpy(login, p->p_session->s_login, namelen);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (copyout(login, (void *)SCARG(uap, namebuf), namelen));
|
return (copyout(login, (void *)SCARG(uap, namebuf), namelen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ sys___setlogin(struct lwp *l, void *v, register_t *retval)
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error == ENAMETOOLONG ? EINVAL : error);
|
return (error == ENAMETOOLONG ? EINVAL : error);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
sp = p->p_session;
|
sp = p->p_session;
|
||||||
if (sp->s_flags & S_LOGIN_SET && p->p_pid != sp->s_sid &&
|
if (sp->s_flags & S_LOGIN_SET && p->p_pid != sp->s_sid &&
|
||||||
strncmp(newname, sp->s_login, sizeof sp->s_login) != 0)
|
strncmp(newname, sp->s_login, sizeof sp->s_login) != 0)
|
||||||
|
@ -707,7 +707,7 @@ sys___setlogin(struct lwp *l, void *v, register_t *retval)
|
||||||
(int)sizeof sp->s_login, sp->s_login, newname);
|
(int)sizeof sp->s_login, sp->s_login, newname);
|
||||||
sp->s_flags |= S_LOGIN_SET;
|
sp->s_flags |= S_LOGIN_SET;
|
||||||
strncpy(sp->s_login, newname, sizeof sp->s_login);
|
strncpy(sp->s_login, newname, sizeof sp->s_login);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_resource.c,v 1.115 2007/03/04 06:03:06 christos Exp $ */
|
/* $NetBSD: kern_resource.c,v 1.116 2007/03/09 14:11:25 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1982, 1986, 1991, 1993
|
* Copyright (c) 1982, 1986, 1991, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.115 2007/03/04 06:03:06 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.116 2007/03/09 14:11:25 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -83,7 +83,7 @@ sys_getpriority(struct lwp *l, void *v, register_t *retval)
|
||||||
int low = NZERO + PRIO_MAX + 1;
|
int low = NZERO + PRIO_MAX + 1;
|
||||||
int who = SCARG(uap, who);
|
int who = SCARG(uap, who);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
switch (SCARG(uap, which)) {
|
switch (SCARG(uap, which)) {
|
||||||
case PRIO_PROCESS:
|
case PRIO_PROCESS:
|
||||||
if (who == 0)
|
if (who == 0)
|
||||||
|
@ -121,10 +121,10 @@ sys_getpriority(struct lwp *l, void *v, register_t *retval)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
if (low == NZERO + PRIO_MAX + 1)
|
if (low == NZERO + PRIO_MAX + 1)
|
||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
|
@ -145,7 +145,7 @@ sys_setpriority(struct lwp *l, void *v, register_t *retval)
|
||||||
int found = 0, error = 0;
|
int found = 0, error = 0;
|
||||||
int who = SCARG(uap, who);
|
int who = SCARG(uap, who);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
switch (SCARG(uap, which)) {
|
switch (SCARG(uap, which)) {
|
||||||
case PRIO_PROCESS:
|
case PRIO_PROCESS:
|
||||||
if (who == 0)
|
if (who == 0)
|
||||||
|
@ -194,7 +194,7 @@ sys_setpriority(struct lwp *l, void *v, register_t *retval)
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (found == 0)
|
if (found == 0)
|
||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
return (error);
|
return (error);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_sig.c,v 1.250 2007/03/05 20:29:14 ad Exp $ */
|
/* $NetBSD: kern_sig.c,v 1.251 2007/03/09 14:11:25 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.250 2007/03/05 20:29:14 ad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.251 2007/03/09 14:11:25 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
#include "opt_ptrace.h"
|
#include "opt_ptrace.h"
|
||||||
|
@ -808,7 +808,7 @@ killpg1(struct lwp *l, ksiginfo_t *ksi, int pgid, int all)
|
||||||
pc = l->l_cred;
|
pc = l->l_cred;
|
||||||
nfound = 0;
|
nfound = 0;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if (all) {
|
if (all) {
|
||||||
/*
|
/*
|
||||||
* broadcast
|
* broadcast
|
||||||
|
@ -862,7 +862,7 @@ killpg1(struct lwp *l, ksiginfo_t *ksi, int pgid, int all)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (nfound ? 0 : ESRCH);
|
return (nfound ? 0 : ESRCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_systrace.c,v 1.69 2007/03/04 06:03:06 christos Exp $ */
|
/* $NetBSD: kern_systrace.c,v 1.70 2007/03/09 14:11:26 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2002, 2003 Niels Provos <provos@citi.umich.edu>
|
* Copyright 2002, 2003 Niels Provos <provos@citi.umich.edu>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.69 2007/03/04 06:03:06 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.70 2007/03/09 14:11:26 ad Exp $");
|
||||||
|
|
||||||
#include "opt_systrace.h"
|
#include "opt_systrace.h"
|
||||||
|
|
||||||
|
@ -496,9 +496,9 @@ systracef_close(struct file *fp, struct lwp *l)
|
||||||
struct proc *q = strp->proc;
|
struct proc *q = strp->proc;
|
||||||
|
|
||||||
systrace_detach(strp);
|
systrace_detach(strp);
|
||||||
rw_enter(&proclist_lock, RW_READER); /* XXXSMP */
|
mutex_enter(&proclist_lock); /* XXXSMP */
|
||||||
psignal(q, SIGKILL);
|
psignal(q, SIGKILL);
|
||||||
rw_exit(&proclist_lock); /* XXXSMP */
|
mutex_exit(&proclist_lock); /* XXXSMP */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up fork and exit messages */
|
/* Clean up fork and exit messages */
|
||||||
|
@ -590,22 +590,22 @@ systrace_find(struct str_process *strp)
|
||||||
struct proc *proc;
|
struct proc *proc;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
if ((proc = p_find(strp->pid, PFIND_LOCKED)) == NULL) {
|
if ((proc = p_find(strp->pid, PFIND_LOCKED)) == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_enter(&proc->p_mutex);
|
mutex_enter(&proc->p_mutex);
|
||||||
if (proc != strp->proc || !ISSET(proc->p_flag, PK_SYSTRACE)) {
|
if (proc != strp->proc || !ISSET(proc->p_flag, PK_SYSTRACE)) {
|
||||||
mutex_exit(&proc->p_mutex);
|
mutex_exit(&proc->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
error = proc_addref(proc);
|
error = proc_addref(proc);
|
||||||
mutex_exit(&proc->p_mutex);
|
mutex_exit(&proc->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return (error ? NULL : proc);
|
return (error ? NULL : proc);
|
||||||
}
|
}
|
||||||
|
@ -652,9 +652,9 @@ systrace_sys_fork(struct proc *oldproc, struct proc *p)
|
||||||
|
|
||||||
if (systrace_insert_process(fst, p, &strp)) {
|
if (systrace_insert_process(fst, p, &strp)) {
|
||||||
/* We need to kill the child */
|
/* We need to kill the child */
|
||||||
rw_enter(&proclist_lock, RW_READER); /* XXXSMP */
|
mutex_enter(&proclist_lock); /* XXXSMP */
|
||||||
psignal(p, SIGKILL);
|
psignal(p, SIGKILL);
|
||||||
rw_exit(&proclist_lock); /* XXXSMP */
|
mutex_exit(&proclist_lock); /* XXXSMP */
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1228,16 +1228,16 @@ systrace_attach(struct fsystrace *fst, pid_t pid)
|
||||||
int error = 0;
|
int error = 0;
|
||||||
struct proc *proc, *p = curproc;
|
struct proc *proc, *p = curproc;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
if ((proc = p_find(pid, PFIND_LOCKED)) == NULL) {
|
if ((proc = p_find(pid, PFIND_LOCKED)) == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_enter(&proc->p_mutex);
|
mutex_enter(&proc->p_mutex);
|
||||||
error = proc_addref(proc);
|
error = proc_addref(proc);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
mutex_exit(&proc->p_mutex);
|
mutex_exit(&proc->p_mutex);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_time.c,v 1.116 2007/03/04 06:03:07 christos Exp $ */
|
/* $NetBSD: kern_time.c,v 1.117 2007/03/09 14:11:26 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc.
|
* Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc.
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.116 2007/03/04 06:03:07 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.117 2007/03/09 14:11:26 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
@ -137,7 +137,7 @@ settime(struct proc *p, struct timespec *ts)
|
||||||
if (ts->tv_sec > INT_MAX - 365*24*60*60) {
|
if (ts->tv_sec > INT_MAX - 365*24*60*60) {
|
||||||
struct proc *pp;
|
struct proc *pp;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
pp = p->p_pptr;
|
pp = p->p_pptr;
|
||||||
mutex_enter(&pp->p_mutex);
|
mutex_enter(&pp->p_mutex);
|
||||||
log(LOG_WARNING, "pid %d (%s) "
|
log(LOG_WARNING, "pid %d (%s) "
|
||||||
|
@ -146,7 +146,7 @@ settime(struct proc *p, struct timespec *ts)
|
||||||
p->p_pid, p->p_comm, kauth_cred_geteuid(pp->p_cred),
|
p->p_pid, p->p_comm, kauth_cred_geteuid(pp->p_cred),
|
||||||
pp->p_pid, pp->p_comm, (long)ts->tv_sec);
|
pp->p_pid, pp->p_comm, (long)ts->tv_sec);
|
||||||
mutex_exit(&pp->p_mutex);
|
mutex_exit(&pp->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (EPERM);
|
return (EPERM);
|
||||||
}
|
}
|
||||||
TIMESPEC_TO_TIMEVAL(&tv, ts);
|
TIMESPEC_TO_TIMEVAL(&tv, ts);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: sys_process.c,v 1.122 2007/03/04 06:03:09 christos Exp $ */
|
/* $NetBSD: sys_process.c,v 1.123 2007/03/09 14:11:26 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1982, 1986, 1989, 1993
|
* Copyright (c) 1982, 1986, 1989, 1993
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.122 2007/03/04 06:03:09 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.123 2007/03/09 14:11:26 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -146,7 +146,7 @@ sys_ptrace(struct lwp *l, void *v, register_t *retval)
|
||||||
* If attaching or detaching, we need to get a write hold on the
|
* If attaching or detaching, we need to get a write hold on the
|
||||||
* proclist lock so that we can re-parent the target process.
|
* proclist lock so that we can re-parent the target process.
|
||||||
*/
|
*/
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
/* "A foolish consistency..." XXX */
|
/* "A foolish consistency..." XXX */
|
||||||
if (req == PT_TRACE_ME)
|
if (req == PT_TRACE_ME)
|
||||||
|
@ -154,7 +154,7 @@ sys_ptrace(struct lwp *l, void *v, register_t *retval)
|
||||||
else {
|
else {
|
||||||
/* Find the process we're supposed to be operating on. */
|
/* Find the process we're supposed to be operating on. */
|
||||||
if ((t = p_find(SCARG(uap, pid), PFIND_LOCKED)) == NULL) {
|
if ((t = p_find(SCARG(uap, pid), PFIND_LOCKED)) == NULL) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ sys_ptrace(struct lwp *l, void *v, register_t *retval)
|
||||||
error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE,
|
error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE,
|
||||||
t, NULL, NULL, NULL);
|
t, NULL, NULL, NULL);
|
||||||
if (error) {
|
if (error) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ sys_ptrace(struct lwp *l, void *v, register_t *retval)
|
||||||
error = proc_addref(t);
|
error = proc_addref(t);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
mutex_exit(&t->p_mutex);
|
mutex_exit(&t->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ sys_ptrace(struct lwp *l, void *v, register_t *retval)
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
proc_delref(t);
|
proc_delref(t);
|
||||||
mutex_exit(&t->p_mutex);
|
mutex_exit(&t->p_mutex);
|
||||||
return error;
|
return error;
|
||||||
|
@ -340,7 +340,7 @@ sys_ptrace(struct lwp *l, void *v, register_t *retval)
|
||||||
pheld = 1;
|
pheld = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
mutex_exit(&t->p_mutex);
|
mutex_exit(&t->p_mutex);
|
||||||
pheld = 0;
|
pheld = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -743,7 +743,7 @@ sys_ptrace(struct lwp *l, void *v, register_t *retval)
|
||||||
if (pheld) {
|
if (pheld) {
|
||||||
proc_delref(t);
|
proc_delref(t);
|
||||||
mutex_exit(&t->p_mutex);
|
mutex_exit(&t->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
} else {
|
} else {
|
||||||
mutex_enter(&t->p_mutex);
|
mutex_enter(&t->p_mutex);
|
||||||
proc_delref(t);
|
proc_delref(t);
|
||||||
|
@ -914,6 +914,9 @@ process_stoptrace(struct lwp *l)
|
||||||
{
|
{
|
||||||
struct proc *p = l->l_proc, *pp;
|
struct proc *p = l->l_proc, *pp;
|
||||||
|
|
||||||
|
/* XXXSMP proc_stop -> child_psignal -> kpsignal2 -> pool_get */
|
||||||
|
KERNEL_LOCK(1, l);
|
||||||
|
|
||||||
mutex_enter(&proclist_mutex);
|
mutex_enter(&proclist_mutex);
|
||||||
mutex_enter(&p->p_smutex);
|
mutex_enter(&p->p_smutex);
|
||||||
pp = p->p_pptr;
|
pp = p->p_pptr;
|
||||||
|
@ -921,6 +924,7 @@ process_stoptrace(struct lwp *l)
|
||||||
CLR(p->p_slflag, PSL_SYSCALL); /* XXXSMP */
|
CLR(p->p_slflag, PSL_SYSCALL); /* XXXSMP */
|
||||||
mutex_exit(&p->p_smutex);
|
mutex_exit(&p->p_smutex);
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
|
KERNEL_UNLOCK_ONE(l);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,6 +935,6 @@ process_stoptrace(struct lwp *l)
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
lwp_lock(l);
|
lwp_lock(l);
|
||||||
mi_switch(l, NULL);
|
mi_switch(l, NULL);
|
||||||
KERNEL_LOCK(l->l_biglocks, l);
|
KERNEL_LOCK(l->l_biglocks - 1, l);
|
||||||
}
|
}
|
||||||
#endif /* KTRACE || PTRACE */
|
#endif /* KTRACE || PTRACE */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: sys_sig.c,v 1.6 2007/02/27 15:19:54 ad Exp $ */
|
/* $NetBSD: sys_sig.c,v 1.7 2007/03/09 14:11:27 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.6 2007/02/27 15:19:54 ad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.7 2007/03/09 14:11:27 ad Exp $");
|
||||||
|
|
||||||
#include "opt_ptrace.h"
|
#include "opt_ptrace.h"
|
||||||
#include "opt_compat_netbsd.h"
|
#include "opt_compat_netbsd.h"
|
||||||
|
@ -289,7 +289,7 @@ sys_kill(struct lwp *l, void *v, register_t *retval)
|
||||||
mutex_exit(&proclist_mutex);
|
mutex_exit(&proclist_mutex);
|
||||||
}
|
}
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
switch (SCARG(uap, pid)) {
|
switch (SCARG(uap, pid)) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: tty.c,v 1.192 2007/03/04 06:03:10 christos Exp $ */
|
/* $NetBSD: tty.c,v 1.193 2007/03/09 14:11:27 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1982, 1986, 1990, 1991, 1993
|
* Copyright (c) 1982, 1986, 1990, 1991, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.192 2007/03/04 06:03:10 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.193 2007/03/09 14:11:27 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -321,7 +321,7 @@ ttyclose(struct tty *tp)
|
||||||
TTY_UNLOCK(tp);
|
TTY_UNLOCK(tp);
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
s = spltty();
|
s = spltty();
|
||||||
TTY_LOCK(tp);
|
TTY_LOCK(tp);
|
||||||
if (tp->t_session != NULL) {
|
if (tp->t_session != NULL) {
|
||||||
|
@ -330,7 +330,7 @@ ttyclose(struct tty *tp)
|
||||||
}
|
}
|
||||||
TTY_UNLOCK(tp);
|
TTY_UNLOCK(tp);
|
||||||
splx(s);
|
splx(s);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1160,13 +1160,13 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag, struct lwp *l)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIOCSCTTY: /* become controlling tty */
|
case TIOCSCTTY: /* become controlling tty */
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
/* Session ctty vnode pointer set in vnode layer. */
|
/* Session ctty vnode pointer set in vnode layer. */
|
||||||
if (!SESS_LEADER(p) ||
|
if (!SESS_LEADER(p) ||
|
||||||
((p->p_session->s_ttyvp || tp->t_session) &&
|
((p->p_session->s_ttyvp || tp->t_session) &&
|
||||||
(tp->t_session != p->p_session))) {
|
(tp->t_session != p->p_session))) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (EPERM);
|
return (EPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag, struct lwp *l)
|
||||||
tp->t_pgrp = p->p_pgrp;
|
tp->t_pgrp = p->p_pgrp;
|
||||||
p->p_session->s_ttyp = tp;
|
p->p_session->s_ttyp = tp;
|
||||||
p->p_lflag |= PL_CONTROLT;
|
p->p_lflag |= PL_CONTROLT;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
break;
|
break;
|
||||||
case FIOSETOWN: { /* set pgrp of tty */
|
case FIOSETOWN: { /* set pgrp of tty */
|
||||||
pid_t pgid = *(int *)data;
|
pid_t pgid = *(int *)data;
|
||||||
|
@ -1192,7 +1192,7 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag, struct lwp *l)
|
||||||
if (tp->t_session != NULL && !isctty(p, tp))
|
if (tp->t_session != NULL && !isctty(p, tp))
|
||||||
return (ENOTTY);
|
return (ENOTTY);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
if (pgid < 0) {
|
if (pgid < 0) {
|
||||||
pgrp = pg_find(-pgid, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
pgrp = pg_find(-pgid, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
||||||
|
@ -1207,11 +1207,11 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag, struct lwp *l)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pgrp->pg_session != p->p_session) {
|
if (pgrp->pg_session != p->p_session) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (EPERM);
|
return (EPERM);
|
||||||
}
|
}
|
||||||
tp->t_pgrp = pgrp;
|
tp->t_pgrp = pgrp;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIOCSPGRP: { /* set pgrp of tty */
|
case TIOCSPGRP: { /* set pgrp of tty */
|
||||||
|
@ -1219,16 +1219,16 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag, struct lwp *l)
|
||||||
|
|
||||||
if (!isctty(p, tp))
|
if (!isctty(p, tp))
|
||||||
return (ENOTTY);
|
return (ENOTTY);
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
pgrp = pg_find(*(int *)data, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
pgrp = pg_find(*(int *)data, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
|
||||||
if (pgrp == NULL)
|
if (pgrp == NULL)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
if (pgrp->pg_session != p->p_session) {
|
if (pgrp->pg_session != p->p_session) {
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (EPERM);
|
return (EPERM);
|
||||||
}
|
}
|
||||||
tp->t_pgrp = pgrp;
|
tp->t_pgrp = pgrp;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIOCSTAT: /* get load avg stats */
|
case TIOCSTAT: /* get load avg stats */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: tty_tty.c,v 1.33 2007/03/04 06:03:10 christos Exp $ */
|
/* $NetBSD: tty_tty.c,v 1.34 2007/03/09 14:11:27 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1982, 1986, 1991, 1993, 1995
|
* Copyright (c) 1982, 1986, 1991, 1993, 1995
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: tty_tty.c,v 1.33 2007/03/04 06:03:10 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: tty_tty.c,v 1.34 2007/03/09 14:11:27 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -127,13 +127,13 @@ cttyioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
|
||||||
if (cmd == TIOCSCTTY) /* XXX */
|
if (cmd == TIOCSCTTY) /* XXX */
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
if (cmd == TIOCNOTTY) {
|
if (cmd == TIOCNOTTY) {
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
if (!SESS_LEADER(l->l_proc)) {
|
if (!SESS_LEADER(l->l_proc)) {
|
||||||
l->l_proc->p_lflag &= ~PL_CONTROLT;
|
l->l_proc->p_lflag &= ~PL_CONTROLT;
|
||||||
rv = 0;
|
rv = 0;
|
||||||
} else
|
} else
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED, l));
|
return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED, l));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vfs_syscalls.c,v 1.304 2007/03/01 10:02:31 pooka Exp $ */
|
/* $NetBSD: vfs_syscalls.c,v 1.305 2007/03/09 14:11:27 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.304 2007/03/01 10:02:31 pooka Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.305 2007/03/09 14:11:27 ad Exp $");
|
||||||
|
|
||||||
#include "opt_compat_netbsd.h"
|
#include "opt_compat_netbsd.h"
|
||||||
#include "opt_compat_43.h"
|
#include "opt_compat_43.h"
|
||||||
|
@ -493,7 +493,7 @@ checkdirs(struct vnode *olddp)
|
||||||
return;
|
return;
|
||||||
if (VFS_ROOT(olddp->v_mountedhere, &newdp))
|
if (VFS_ROOT(olddp->v_mountedhere, &newdp))
|
||||||
panic("mount: lost mount");
|
panic("mount: lost mount");
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
PROCLIST_FOREACH(p, &allproc) {
|
PROCLIST_FOREACH(p, &allproc) {
|
||||||
cwdi = p->p_cwdi;
|
cwdi = p->p_cwdi;
|
||||||
if (!cwdi)
|
if (!cwdi)
|
||||||
|
@ -509,7 +509,7 @@ checkdirs(struct vnode *olddp)
|
||||||
cwdi->cwdi_rdir = newdp;
|
cwdi->cwdi_rdir = newdp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (rootvnode == olddp) {
|
if (rootvnode == olddp) {
|
||||||
vrele(rootvnode);
|
vrele(rootvnode);
|
||||||
VREF(newdp);
|
VREF(newdp);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vfs_vnops.c,v 1.134 2007/03/04 06:03:12 christos Exp $ */
|
/* $NetBSD: vfs_vnops.c,v 1.135 2007/03/09 14:11:27 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1989, 1993
|
* Copyright (c) 1982, 1986, 1989, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.134 2007/03/04 06:03:12 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.135 2007/03/09 14:11:27 ad Exp $");
|
||||||
|
|
||||||
#include "fs_union.h"
|
#include "fs_union.h"
|
||||||
#include "veriexec.h"
|
#include "veriexec.h"
|
||||||
|
@ -638,10 +638,10 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct lwp *l)
|
||||||
l->l_cred, l);
|
l->l_cred, l);
|
||||||
if (error == 0 && com == TIOCSCTTY) {
|
if (error == 0 && com == TIOCSCTTY) {
|
||||||
VREF(vp);
|
VREF(vp);
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
ovp = p->p_session->s_ttyvp;
|
ovp = p->p_session->s_ttyvp;
|
||||||
p->p_session->s_ttyvp = vp;
|
p->p_session->s_ttyvp = vp;
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
if (ovp != NULL)
|
if (ovp != NULL)
|
||||||
vrele(ovp);
|
vrele(ovp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: procfs_ctl.c,v 1.39 2007/02/09 21:55:36 ad Exp $ */
|
/* $NetBSD: procfs_ctl.c,v 1.40 2007/03/09 14:11:22 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1993
|
* Copyright (c) 1993
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: procfs_ctl.c,v 1.39 2007/02/09 21:55:36 ad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: procfs_ctl.c,v 1.40 2007/03/09 14:11:22 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -140,7 +140,7 @@ procfs_control(curl, l, op, sig, pfs)
|
||||||
struct proc *p = l->l_proc;
|
struct proc *p = l->l_proc;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_WRITER);
|
mutex_enter(&proclist_lock);
|
||||||
mutex_enter(&p->p_mutex);
|
mutex_enter(&p->p_mutex);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -251,7 +251,7 @@ procfs_control(curl, l, op, sig, pfs)
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,12 +328,12 @@ procfs_control(curl, l, op, sig, pfs)
|
||||||
psignal(p, sig);
|
psignal(p, sig);
|
||||||
}
|
}
|
||||||
mutex_exit(&p->p_smutex);
|
mutex_exit(&p->p_smutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
case PROCFS_CTL_WAIT:
|
case PROCFS_CTL_WAIT:
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for the target process to stop.
|
* Wait for the target process to stop.
|
||||||
|
@ -352,7 +352,7 @@ procfs_control(curl, l, op, sig, pfs)
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: procfs_linux.c,v 1.32 2007/02/09 21:55:36 ad Exp $ */
|
/* $NetBSD: procfs_linux.c,v 1.33 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.32 2007/02/09 21:55:36 ad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.33 2007/03/09 14:11:23 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -220,7 +220,7 @@ procfs_do_pid_stat(struct lwp *curl, struct lwp *l,
|
||||||
vm_map_unlock_read(map);
|
vm_map_unlock_read(map);
|
||||||
uvmspace_free(vm);
|
uvmspace_free(vm);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
mutex_enter(&p->p_mutex);
|
mutex_enter(&p->p_mutex);
|
||||||
mutex_enter(&p->p_smutex);
|
mutex_enter(&p->p_smutex);
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ procfs_do_pid_stat(struct lwp *curl, struct lwp *l,
|
||||||
|
|
||||||
mutex_exit(&p->p_smutex);
|
mutex_exit(&p->p_smutex);
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: procfs_status.c,v 1.31 2007/02/17 22:31:44 pavel Exp $ */
|
/* $NetBSD: procfs_status.c,v 1.32 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1993
|
* Copyright (c) 1993
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.31 2007/02/17 22:31:44 pavel Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: procfs_status.c,v 1.32 2007/03/09 14:11:23 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -110,7 +110,7 @@ procfs_dostatus(
|
||||||
if (uio->uio_rw != UIO_READ)
|
if (uio->uio_rw != UIO_READ)
|
||||||
return (EOPNOTSUPP);
|
return (EOPNOTSUPP);
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
mutex_enter(&p->p_mutex);
|
mutex_enter(&p->p_mutex);
|
||||||
|
|
||||||
pid = p->p_pid;
|
pid = p->p_pid;
|
||||||
|
@ -182,7 +182,7 @@ procfs_dostatus(
|
||||||
ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "\n");
|
ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "\n");
|
||||||
|
|
||||||
mutex_exit(&p->p_mutex);
|
mutex_exit(&p->p_mutex);
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
return (uiomove_frombuf(psbuf, ps - psbuf, uio));
|
return (uiomove_frombuf(psbuf, ps - psbuf, uio));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: procfs_subr.c,v 1.78 2007/02/27 16:11:51 ad Exp $ */
|
/* $NetBSD: procfs_subr.c,v 1.79 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.78 2007/02/27 16:11:51 ad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.79 2007/03/09 14:11:23 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -670,7 +670,7 @@ procfs_proc_lock(int pid, struct proc **bunghole, int notfound)
|
||||||
struct proc *tp;
|
struct proc *tp;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
|
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
tp = &proc0;
|
tp = &proc0;
|
||||||
|
@ -683,7 +683,7 @@ procfs_proc_lock(int pid, struct proc **bunghole, int notfound)
|
||||||
mutex_exit(&tp->p_mutex);
|
mutex_exit(&tp->p_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
|
|
||||||
*bunghole = tp;
|
*bunghole = tp;
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: procfs_vnops.c,v 1.153 2007/03/04 06:03:14 christos Exp $ */
|
/* $NetBSD: procfs_vnops.c,v 1.154 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.153 2007/03/04 06:03:14 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.154 2007/03/09 14:11:23 ad Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -1214,9 +1214,9 @@ procfs_root_readdir_callback(struct proc *p, void *arg)
|
||||||
UIO_MX - offsetof(struct dirent, d_name), "%ld", (long)p->p_pid);
|
UIO_MX - offsetof(struct dirent, d_name), "%ld", (long)p->p_pid);
|
||||||
d.d_type = DT_DIR;
|
d.d_type = DT_DIR;
|
||||||
|
|
||||||
rw_exit(&proclist_lock);
|
mutex_exit(&proclist_lock);
|
||||||
error = uiomove(&d, UIO_MX, uiop);
|
error = uiomove(&d, UIO_MX, uiop);
|
||||||
rw_enter(&proclist_lock, RW_READER);
|
mutex_enter(&proclist_lock);
|
||||||
if (error) {
|
if (error) {
|
||||||
ctxp->error = error;
|
ctxp->error = error;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: proc.h,v 1.242 2007/03/04 06:03:41 christos Exp $ */
|
/* $NetBSD: proc.h,v 1.243 2007/03/09 14:11:23 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -480,7 +480,7 @@ extern int nprocs, maxproc; /* Current and max number of procs */
|
||||||
#define vmspace_kernel() (proc0.p_vmspace)
|
#define vmspace_kernel() (proc0.p_vmspace)
|
||||||
|
|
||||||
/* Process list locks; see kern_proc.c for locking protocol details */
|
/* Process list locks; see kern_proc.c for locking protocol details */
|
||||||
extern krwlock_t proclist_lock;
|
extern kmutex_t proclist_lock;
|
||||||
extern kmutex_t proclist_mutex;
|
extern kmutex_t proclist_mutex;
|
||||||
|
|
||||||
extern struct proclist allproc; /* List of all processes */
|
extern struct proclist allproc; /* List of all processes */
|
||||||
|
|
Loading…
Reference in New Issue