1994-08-08 13:00:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994, Sean Eric Fagan
|
|
|
|
* All rights reserved.
|
1994-05-24 10:09:53 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1994-08-08 13:00:27 +00:00
|
|
|
* This product includes software developed by Sean Eric Fagan.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
1994-05-24 10:09:53 +00:00
|
|
|
*
|
1994-08-08 13:00:27 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
1994-05-24 10:09:53 +00:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
1994-08-08 13:00:27 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
1994-05-24 10:09:53 +00:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1994-08-18 22:36:09 +00:00
|
|
|
#include <sys/systm.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
1995-11-12 06:43:28 +00:00
|
|
|
#include <sys/sysproto.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/proc.h>
|
1994-08-08 13:00:27 +00:00
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/ptrace.h>
|
2001-03-28 11:52:56 +00:00
|
|
|
#include <sys/sx.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/user.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
#include <machine/reg.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <vm/vm_map.h>
|
1994-08-08 13:00:27 +00:00
|
|
|
#include <vm/vm_page.h>
|
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
#include <miscfs/procfs/procfs.h>
|
1994-08-08 13:00:27 +00:00
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
/* use the equivalent procfs code */
|
|
|
|
#if 0
|
1995-05-12 21:39:48 +00:00
|
|
|
static int
|
1994-08-08 13:00:27 +00:00
|
|
|
pread (struct proc *procp, unsigned int addr, unsigned int *retval) {
|
|
|
|
int rv;
|
|
|
|
vm_map_t map, tmap;
|
|
|
|
vm_object_t object;
|
|
|
|
vm_offset_t kva = 0;
|
|
|
|
int page_offset; /* offset into page */
|
|
|
|
vm_offset_t pageno; /* page number */
|
|
|
|
vm_map_entry_t out_entry;
|
|
|
|
vm_prot_t out_prot;
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
boolean_t wired;
|
1995-12-17 06:59:36 +00:00
|
|
|
vm_pindex_t pindex;
|
1994-08-08 13:00:27 +00:00
|
|
|
|
|
|
|
/* Map page into kernel space */
|
|
|
|
|
|
|
|
map = &procp->p_vmspace->vm_map;
|
|
|
|
|
|
|
|
page_offset = addr - trunc_page(addr);
|
|
|
|
pageno = trunc_page(addr);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
tmap = map;
|
|
|
|
rv = vm_map_lookup (&tmap, pageno, VM_PROT_READ, &out_entry,
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
&object, &pindex, &out_prot, &wired);
|
1994-08-08 13:00:27 +00:00
|
|
|
|
|
|
|
if (rv != KERN_SUCCESS)
|
|
|
|
return EINVAL;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
vm_map_lookup_done (tmap, out_entry);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
/* Find space in kernel_map for the page we're interested in */
|
1996-01-19 04:00:31 +00:00
|
|
|
rv = vm_map_find (kernel_map, object, IDX_TO_OFF(pindex),
|
|
|
|
&kva, PAGE_SIZE, 0, VM_PROT_ALL, VM_PROT_ALL, 0);
|
1994-08-08 13:00:27 +00:00
|
|
|
|
|
|
|
if (!rv) {
|
|
|
|
vm_object_reference (object);
|
|
|
|
|
|
|
|
rv = vm_map_pageable (kernel_map, kva, kva + PAGE_SIZE, 0);
|
|
|
|
if (!rv) {
|
|
|
|
*retval = 0;
|
1994-08-18 22:36:09 +00:00
|
|
|
bcopy ((caddr_t)kva + page_offset,
|
|
|
|
retval, sizeof *retval);
|
1994-08-08 13:00:27 +00:00
|
|
|
}
|
|
|
|
vm_map_remove (kernel_map, kva, kva + PAGE_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1995-05-12 21:39:48 +00:00
|
|
|
static int
|
1994-08-08 13:00:27 +00:00
|
|
|
pwrite (struct proc *procp, unsigned int addr, unsigned int datum) {
|
|
|
|
int rv;
|
|
|
|
vm_map_t map, tmap;
|
|
|
|
vm_object_t object;
|
|
|
|
vm_offset_t kva = 0;
|
|
|
|
int page_offset; /* offset into page */
|
|
|
|
vm_offset_t pageno; /* page number */
|
|
|
|
vm_map_entry_t out_entry;
|
|
|
|
vm_prot_t out_prot;
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
boolean_t wired;
|
1995-12-17 06:59:36 +00:00
|
|
|
vm_pindex_t pindex;
|
1994-08-08 13:00:27 +00:00
|
|
|
boolean_t fix_prot = 0;
|
|
|
|
|
|
|
|
/* Map page into kernel space */
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
map = &procp->p_vmspace->vm_map;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
page_offset = addr - trunc_page(addr);
|
|
|
|
pageno = trunc_page(addr);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
/*
|
|
|
|
* Check the permissions for the area we're interested in.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (vm_map_check_protection (map, pageno, pageno + PAGE_SIZE,
|
|
|
|
VM_PROT_WRITE) == FALSE) {
|
|
|
|
/*
|
|
|
|
* If the page was not writable, we make it so.
|
|
|
|
* XXX It is possible a page may *not* be read/executable,
|
|
|
|
* if a process changes that!
|
|
|
|
*/
|
|
|
|
fix_prot = 1;
|
|
|
|
/* The page isn't writable, so let's try making it so... */
|
|
|
|
if ((rv = vm_map_protect (map, pageno, pageno + PAGE_SIZE,
|
|
|
|
VM_PROT_ALL, 0)) != KERN_SUCCESS)
|
|
|
|
return EFAULT; /* I guess... */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now we need to get the page. out_entry, out_prot, wired, and
|
|
|
|
* single_use aren't used. One would think the vm code would be
|
|
|
|
* a *bit* nicer... We use tmap because vm_map_lookup() can
|
|
|
|
* change the map argument.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tmap = map;
|
|
|
|
rv = vm_map_lookup (&tmap, pageno, VM_PROT_WRITE, &out_entry,
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
&object, &pindex, &out_prot, &wired);
|
1994-08-08 13:00:27 +00:00
|
|
|
if (rv != KERN_SUCCESS) {
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Okay, we've got the page. Let's release tmap.
|
|
|
|
*/
|
|
|
|
|
|
|
|
vm_map_lookup_done (tmap, out_entry);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
/*
|
|
|
|
* Fault the page in...
|
|
|
|
*/
|
|
|
|
|
1995-02-10 22:36:11 +00:00
|
|
|
rv = vm_fault(map, pageno, VM_PROT_WRITE|VM_PROT_READ, FALSE);
|
1994-08-08 13:00:27 +00:00
|
|
|
if (rv != KERN_SUCCESS)
|
|
|
|
return EFAULT;
|
|
|
|
|
|
|
|
/* Find space in kernel_map for the page we're interested in */
|
1996-01-19 04:00:31 +00:00
|
|
|
rv = vm_map_find (kernel_map, object, IDX_TO_OFF(pindex),
|
|
|
|
&kva, PAGE_SIZE, 0,
|
|
|
|
VM_PROT_ALL, VM_PROT_ALL, 0);
|
1994-08-08 13:00:27 +00:00
|
|
|
if (!rv) {
|
|
|
|
vm_object_reference (object);
|
|
|
|
|
|
|
|
rv = vm_map_pageable (kernel_map, kva, kva + PAGE_SIZE, 0);
|
|
|
|
if (!rv) {
|
1994-08-18 22:36:09 +00:00
|
|
|
bcopy (&datum, (caddr_t)kva + page_offset, sizeof datum);
|
1994-08-08 13:00:27 +00:00
|
|
|
}
|
|
|
|
vm_map_remove (kernel_map, kva, kva + PAGE_SIZE);
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
if (fix_prot)
|
|
|
|
vm_map_protect (map, pageno, pageno + PAGE_SIZE,
|
|
|
|
VM_PROT_READ|VM_PROT_EXECUTE, 0);
|
|
|
|
return rv;
|
|
|
|
}
|
1996-01-24 18:29:00 +00:00
|
|
|
#endif
|
1994-08-08 13:00:27 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Process debugging system call.
|
|
|
|
*/
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct ptrace_args {
|
|
|
|
int req;
|
|
|
|
pid_t pid;
|
|
|
|
caddr_t addr;
|
|
|
|
int data;
|
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
1994-08-08 13:00:27 +00:00
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
ptrace(curp, uap)
|
1994-08-08 13:00:27 +00:00
|
|
|
struct proc *curp;
|
|
|
|
struct ptrace_args *uap;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1994-08-08 13:00:27 +00:00
|
|
|
struct proc *p;
|
1996-01-24 18:29:00 +00:00
|
|
|
struct iovec iov;
|
|
|
|
struct uio uio;
|
1994-09-25 19:34:02 +00:00
|
|
|
int error = 0;
|
1996-01-24 18:29:00 +00:00
|
|
|
int write;
|
1994-08-08 13:00:27 +00:00
|
|
|
|
1999-07-01 22:52:40 +00:00
|
|
|
write = 0;
|
2001-04-24 00:51:53 +00:00
|
|
|
if (uap->req == PT_TRACE_ME) {
|
1996-01-24 18:29:00 +00:00
|
|
|
p = curp;
|
2001-04-24 00:51:53 +00:00
|
|
|
PROC_LOCK(p);
|
|
|
|
} else {
|
1996-01-24 18:29:00 +00:00
|
|
|
if ((p = pfind(uap->pid)) == NULL)
|
|
|
|
return ESRCH;
|
1994-08-08 13:00:27 +00:00
|
|
|
}
|
2001-04-24 00:51:53 +00:00
|
|
|
if (p_can(curp, p, P_CAN_SEE, NULL)) {
|
|
|
|
PROC_UNLOCK(p);
|
This Implements the mumbled about "Jail" feature.
This is a seriously beefed up chroot kind of thing. The process
is jailed along the same lines as a chroot does it, but with
additional tough restrictions imposed on what the superuser can do.
For all I know, it is safe to hand over the root bit inside a
prison to the customer living in that prison, this is what
it was developed for in fact: "real virtual servers".
Each prison has an ip number associated with it, which all IP
communications will be coerced to use and each prison has its own
hostname.
Needless to say, you need more RAM this way, but the advantage is
that each customer can run their own particular version of apache
and not stomp on the toes of their neighbors.
It generally does what one would expect, but setting up a jail
still takes a little knowledge.
A few notes:
I have no scripts for setting up a jail, don't ask me for them.
The IP number should be an alias on one of the interfaces.
mount a /proc in each jail, it will make ps more useable.
/proc/<pid>/status tells the hostname of the prison for
jailed processes.
Quotas are only sensible if you have a mountpoint per prison.
There are no privisions for stopping resource-hogging.
Some "#ifdef INET" and similar may be missing (send patches!)
If somebody wants to take it from here and develop it into
more of a "virtual machine" they should be most welcome!
Tools, comments, patches & documentation most welcome.
Have fun...
Sponsored by: http://www.rndassociates.com/
Run for almost a year by: http://www.servetheweb.com/
1999-04-28 11:38:52 +00:00
|
|
|
return (ESRCH);
|
2001-04-24 00:51:53 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
/*
|
|
|
|
* Permissions check
|
|
|
|
*/
|
|
|
|
switch (uap->req) {
|
|
|
|
case PT_TRACE_ME:
|
|
|
|
/* Always legal. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PT_ATTACH:
|
|
|
|
/* Self */
|
2001-04-24 00:51:53 +00:00
|
|
|
if (p->p_pid == curp->p_pid) {
|
|
|
|
PROC_UNLOCK(p);
|
1996-01-24 18:29:00 +00:00
|
|
|
return EINVAL;
|
2001-04-24 00:51:53 +00:00
|
|
|
}
|
1996-01-24 18:29:00 +00:00
|
|
|
|
|
|
|
/* Already traced */
|
2001-03-07 03:06:18 +00:00
|
|
|
if (p->p_flag & P_TRACED) {
|
|
|
|
PROC_UNLOCK(p);
|
1996-01-24 18:29:00 +00:00
|
|
|
return EBUSY;
|
2001-03-07 03:06:18 +00:00
|
|
|
}
|
1996-01-24 18:29:00 +00:00
|
|
|
|
2001-04-24 00:51:53 +00:00
|
|
|
if ((error = p_can(curp, p, P_CAN_DEBUG, NULL))) {
|
|
|
|
PROC_UNLOCK(p);
|
o Centralize inter-process access control, introducing:
int p_can(p1, p2, operation, privused)
which allows specification of subject process, object process,
inter-process operation, and an optional call-by-reference privused
flag, allowing the caller to determine if privilege was required
for the call to succeed. This allows jail, kern.ps_showallprocs and
regular credential-based interaction checks to occur in one block of
code. Possible operations are P_CAN_SEE, P_CAN_SCHED, P_CAN_KILL,
and P_CAN_DEBUG. p_can currently breaks out as a wrapper to a
series of static function checks in kern_prot, which should not
be invoked directly.
o Commented out capabilities entries are included for some checks.
o Update most inter-process authorization to make use of p_can() instead
of manual checks, PRISON_CHECK(), P_TRESPASS(), and
kern.ps_showallprocs.
o Modify suser{,_xxx} to use const arguments, as it no longer modifies
process flags due to the disabling of ASU.
o Modify some checks/errors in procfs so that ENOENT is returned instead
of ESRCH, further improving concealment of processes that should not
be visible to other processes. Also introduce new access checks to
improve hiding of processes for procfs_lookup(), procfs_getattr(),
procfs_readdir(). Correct a bug reported by bp concerning not
handling the CREATE case in procfs_lookup(). Remove volatile flag in
procfs that caused apparently spurious qualifier warnigns (approved by
bde).
o Add comment noting that ktrace() has not been updated, as its access
control checks are different from ptrace(), whereas they should
probably be the same. Further discussion should happen on this topic.
Reviewed by: bde, green, phk, freebsd-security, others
Approved by: bde
Obtained from: TrustedBSD Project
2000-08-30 04:49:09 +00:00
|
|
|
return error;
|
2001-04-24 00:51:53 +00:00
|
|
|
}
|
1997-04-27 19:02:37 +00:00
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
/* OK */
|
|
|
|
break;
|
1994-08-08 13:00:27 +00:00
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
case PT_READ_I:
|
|
|
|
case PT_READ_D:
|
|
|
|
case PT_READ_U:
|
|
|
|
case PT_WRITE_I:
|
|
|
|
case PT_WRITE_D:
|
|
|
|
case PT_WRITE_U:
|
|
|
|
case PT_CONTINUE:
|
|
|
|
case PT_KILL:
|
|
|
|
case PT_STEP:
|
|
|
|
case PT_DETACH:
|
|
|
|
#ifdef PT_GETREGS
|
|
|
|
case PT_GETREGS:
|
|
|
|
#endif
|
|
|
|
#ifdef PT_SETREGS
|
|
|
|
case PT_SETREGS:
|
|
|
|
#endif
|
|
|
|
#ifdef PT_GETFPREGS
|
|
|
|
case PT_GETFPREGS:
|
1994-08-08 13:00:27 +00:00
|
|
|
#endif
|
1996-01-24 18:29:00 +00:00
|
|
|
#ifdef PT_SETFPREGS
|
|
|
|
case PT_SETFPREGS:
|
1999-07-09 04:16:00 +00:00
|
|
|
#endif
|
|
|
|
#ifdef PT_GETDBREGS
|
|
|
|
case PT_GETDBREGS:
|
|
|
|
#endif
|
|
|
|
#ifdef PT_SETDBREGS
|
|
|
|
case PT_SETDBREGS:
|
1994-08-08 13:00:27 +00:00
|
|
|
#endif
|
1996-01-24 18:29:00 +00:00
|
|
|
/* not being traced... */
|
2001-03-07 03:06:18 +00:00
|
|
|
if ((p->p_flag & P_TRACED) == 0) {
|
|
|
|
PROC_UNLOCK(p);
|
1994-08-08 13:00:27 +00:00
|
|
|
return EPERM;
|
2001-03-07 03:06:18 +00:00
|
|
|
}
|
1996-01-24 18:29:00 +00:00
|
|
|
|
|
|
|
/* not being traced by YOU */
|
2000-12-23 19:43:10 +00:00
|
|
|
if (p->p_pptr != curp) {
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_UNLOCK(p);
|
1996-01-24 18:29:00 +00:00
|
|
|
return EBUSY;
|
2000-12-23 19:43:10 +00:00
|
|
|
}
|
1996-01-24 18:29:00 +00:00
|
|
|
|
|
|
|
/* not currently stopped */
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock_spin(&sched_lock);
|
2000-12-02 01:32:51 +00:00
|
|
|
if (p->p_stat != SSTOP || (p->p_flag & P_WAITED) == 0) {
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_UNLOCK(p);
|
1994-08-08 13:00:27 +00:00
|
|
|
return EBUSY;
|
2000-12-02 01:32:51 +00:00
|
|
|
}
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
1996-01-24 18:29:00 +00:00
|
|
|
|
|
|
|
/* OK */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-04-24 00:51:53 +00:00
|
|
|
PROC_UNLOCK(p);
|
1996-01-24 18:29:00 +00:00
|
|
|
return EINVAL;
|
1994-08-08 13:00:27 +00:00
|
|
|
}
|
1996-01-24 18:29:00 +00:00
|
|
|
|
2001-04-24 00:51:53 +00:00
|
|
|
PROC_UNLOCK(p);
|
1996-01-24 18:29:00 +00:00
|
|
|
#ifdef FIX_SSTEP
|
|
|
|
/*
|
|
|
|
* Single step fixup ala procfs
|
|
|
|
*/
|
|
|
|
FIX_SSTEP(p);
|
1994-08-08 13:00:27 +00:00
|
|
|
#endif
|
1996-01-24 18:29:00 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1996-01-24 18:29:00 +00:00
|
|
|
* Actually do the requests
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-08-08 13:00:27 +00:00
|
|
|
|
1997-11-12 12:28:12 +00:00
|
|
|
curp->p_retval[0] = 0;
|
1994-08-08 13:00:27 +00:00
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
switch (uap->req) {
|
|
|
|
case PT_TRACE_ME:
|
|
|
|
/* set my trace flag and "owner" so it can read/write me */
|
2001-03-28 11:52:56 +00:00
|
|
|
sx_xlock(&proctree_lock);
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_LOCK(p);
|
1994-08-08 13:00:27 +00:00
|
|
|
p->p_flag |= P_TRACED;
|
1996-01-24 18:29:00 +00:00
|
|
|
p->p_oppid = p->p_pptr->p_pid;
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_UNLOCK(p);
|
2001-03-28 11:52:56 +00:00
|
|
|
sx_xunlock(&proctree_lock);
|
1994-08-08 13:00:27 +00:00
|
|
|
return 0;
|
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
case PT_ATTACH:
|
|
|
|
/* security check done above */
|
2001-03-28 11:52:56 +00:00
|
|
|
sx_xlock(&proctree_lock);
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_LOCK(p);
|
|
|
|
p->p_flag |= P_TRACED;
|
1996-01-24 18:29:00 +00:00
|
|
|
p->p_oppid = p->p_pptr->p_pid;
|
|
|
|
if (p->p_pptr != curp)
|
|
|
|
proc_reparent(p, curp);
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_UNLOCK(p);
|
2001-03-28 11:52:56 +00:00
|
|
|
sx_xunlock(&proctree_lock);
|
1996-01-24 18:29:00 +00:00
|
|
|
uap->data = SIGSTOP;
|
|
|
|
goto sendsig; /* in PT_CONTINUE below */
|
|
|
|
|
|
|
|
case PT_STEP:
|
|
|
|
case PT_CONTINUE:
|
1994-08-08 13:00:27 +00:00
|
|
|
case PT_DETACH:
|
2000-10-14 03:56:01 +00:00
|
|
|
if ((uap->req != PT_STEP) && ((unsigned)uap->data >= NSIG))
|
1994-08-08 13:00:27 +00:00
|
|
|
return EINVAL;
|
1996-01-24 18:29:00 +00:00
|
|
|
|
|
|
|
PHOLD(p);
|
|
|
|
|
|
|
|
if (uap->req == PT_STEP) {
|
|
|
|
if ((error = ptrace_single_step (p))) {
|
|
|
|
PRELE(p);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uap->addr != (caddr_t)1) {
|
Change the proc information returned from the kernel so that it
no longer contains kernel specific data structures, but rather
only scalar values and structures that are already part of the
kernel/user interface, specifically rusage and rtprio. It no
longer contains proc, session, pcred, ucred, procsig, vmspace,
pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If
any of these changed in size, ps, w, fstat, gcore, systat, and
top would all stop working. The new structure has over 200 bytes
of unassigned space for future values to be added, yet is nearly
100 bytes smaller per entry than the structure that it replaced.
2000-12-12 07:25:57 +00:00
|
|
|
fill_kinfo_proc (p, &p->p_addr->u_kproc);
|
1998-07-15 04:43:49 +00:00
|
|
|
if ((error = ptrace_set_pc (p,
|
|
|
|
(u_long)(uintfptr_t)uap->addr))) {
|
1996-01-24 18:29:00 +00:00
|
|
|
PRELE(p);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PRELE(p);
|
|
|
|
|
|
|
|
if (uap->req == PT_DETACH) {
|
|
|
|
/* reset process parent */
|
2001-03-28 11:52:56 +00:00
|
|
|
sx_xlock(&proctree_lock);
|
1996-01-24 18:29:00 +00:00
|
|
|
if (p->p_oppid != p->p_pptr->p_pid) {
|
|
|
|
struct proc *pp;
|
|
|
|
|
|
|
|
pp = pfind(p->p_oppid);
|
2001-05-04 18:13:11 +00:00
|
|
|
if (pp != NULL)
|
|
|
|
PROC_UNLOCK(pp);
|
|
|
|
else
|
|
|
|
pp = initproc;
|
|
|
|
PROC_LOCK(p);
|
|
|
|
proc_reparent(p, pp);
|
2001-03-07 03:06:18 +00:00
|
|
|
} else
|
|
|
|
PROC_LOCK(p);
|
1996-01-24 18:29:00 +00:00
|
|
|
p->p_flag &= ~(P_TRACED | P_WAITED);
|
|
|
|
p->p_oppid = 0;
|
|
|
|
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_UNLOCK(p);
|
2001-03-28 11:52:56 +00:00
|
|
|
sx_xunlock(&proctree_lock);
|
2001-03-07 03:06:18 +00:00
|
|
|
|
1996-01-24 18:29:00 +00:00
|
|
|
/* should we send SIGCHLD? */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sendsig:
|
|
|
|
/* deliver or queue signal */
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_LOCK(p);
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock_spin(&sched_lock);
|
1994-08-08 13:00:27 +00:00
|
|
|
if (p->p_stat == SSTOP) {
|
|
|
|
p->p_xstat = uap->data;
|
|
|
|
setrunnable(p);
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
2000-12-02 01:32:51 +00:00
|
|
|
} else {
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
2001-03-07 03:06:18 +00:00
|
|
|
if (uap->data)
|
2000-12-02 01:32:51 +00:00
|
|
|
psignal(p, uap->data);
|
2001-03-07 03:06:18 +00:00
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
}
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_UNLOCK(p);
|
1994-08-08 13:00:27 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case PT_WRITE_I:
|
|
|
|
case PT_WRITE_D:
|
1996-01-24 18:29:00 +00:00
|
|
|
write = 1;
|
1994-08-08 13:00:27 +00:00
|
|
|
/* fallthrough */
|
1996-01-24 18:29:00 +00:00
|
|
|
case PT_READ_I:
|
|
|
|
case PT_READ_D:
|
|
|
|
/* write = 0 set above */
|
1997-11-12 12:28:12 +00:00
|
|
|
iov.iov_base = write ? (caddr_t)&uap->data : (caddr_t)curp->p_retval;
|
1996-01-24 18:29:00 +00:00
|
|
|
iov.iov_len = sizeof(int);
|
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
1998-07-15 04:43:49 +00:00
|
|
|
uio.uio_offset = (off_t)(uintptr_t)uap->addr;
|
1996-01-24 18:29:00 +00:00
|
|
|
uio.uio_resid = sizeof(int);
|
|
|
|
uio.uio_segflg = UIO_SYSSPACE; /* ie: the uap */
|
|
|
|
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
|
|
|
uio.uio_procp = p;
|
1996-03-30 15:02:58 +00:00
|
|
|
error = procfs_domem(curp, p, NULL, &uio);
|
|
|
|
if (uio.uio_resid != 0) {
|
|
|
|
/*
|
|
|
|
* XXX procfs_domem() doesn't currently return ENOSPC,
|
|
|
|
* so I think write() can bogusly return 0.
|
|
|
|
* XXX what happens for short writes? We don't want
|
|
|
|
* to write partial data.
|
|
|
|
* XXX procfs_domem() returns EPERM for other invalid
|
|
|
|
* addresses. Convert this to EINVAL. Does this
|
|
|
|
* clobber returns of EPERM for other reasons?
|
|
|
|
*/
|
|
|
|
if (error == 0 || error == ENOSPC || error == EPERM)
|
|
|
|
error = EINVAL; /* EOF */
|
|
|
|
}
|
|
|
|
return (error);
|
1994-08-08 13:00:27 +00:00
|
|
|
|
|
|
|
case PT_READ_U:
|
1998-12-26 17:14:37 +00:00
|
|
|
if ((uintptr_t)uap->addr > UPAGES * PAGE_SIZE - sizeof(int)) {
|
|
|
|
return EFAULT;
|
|
|
|
}
|
|
|
|
if ((uintptr_t)uap->addr & (sizeof(int) - 1)) {
|
1994-08-08 13:00:27 +00:00
|
|
|
return EFAULT;
|
|
|
|
}
|
1998-05-19 00:00:14 +00:00
|
|
|
if (ptrace_read_u_check(p,(vm_offset_t) uap->addr,
|
1999-11-21 19:03:20 +00:00
|
|
|
sizeof(int))) {
|
1998-05-19 00:00:14 +00:00
|
|
|
return EFAULT;
|
|
|
|
}
|
1996-01-24 18:29:00 +00:00
|
|
|
error = 0;
|
|
|
|
PHOLD(p); /* user had damn well better be incore! */
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock_spin(&sched_lock);
|
2001-01-24 11:15:24 +00:00
|
|
|
if (p->p_sflag & PS_INMEM) {
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
Change the proc information returned from the kernel so that it
no longer contains kernel specific data structures, but rather
only scalar values and structures that are already part of the
kernel/user interface, specifically rusage and rtprio. It no
longer contains proc, session, pcred, ucred, procsig, vmspace,
pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If
any of these changed in size, ps, w, fstat, gcore, systat, and
top would all stop working. The new structure has over 200 bytes
of unassigned space for future values to be added, yet is nearly
100 bytes smaller per entry than the structure that it replaced.
2000-12-12 07:25:57 +00:00
|
|
|
fill_kinfo_proc (p, &p->p_addr->u_kproc);
|
1998-07-29 18:41:30 +00:00
|
|
|
curp->p_retval[0] = *(int *)
|
1998-07-15 04:43:49 +00:00
|
|
|
((uintptr_t)p->p_addr + (uintptr_t)uap->addr);
|
1996-01-24 18:29:00 +00:00
|
|
|
} else {
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
1997-11-12 12:28:12 +00:00
|
|
|
curp->p_retval[0] = 0;
|
1996-01-24 18:29:00 +00:00
|
|
|
error = EFAULT;
|
|
|
|
}
|
|
|
|
PRELE(p);
|
|
|
|
return error;
|
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
case PT_WRITE_U:
|
1996-01-24 18:29:00 +00:00
|
|
|
PHOLD(p); /* user had damn well better be incore! */
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock_spin(&sched_lock);
|
2001-01-24 11:15:24 +00:00
|
|
|
if (p->p_sflag & PS_INMEM) {
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
Change the proc information returned from the kernel so that it
no longer contains kernel specific data structures, but rather
only scalar values and structures that are already part of the
kernel/user interface, specifically rusage and rtprio. It no
longer contains proc, session, pcred, ucred, procsig, vmspace,
pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If
any of these changed in size, ps, w, fstat, gcore, systat, and
top would all stop working. The new structure has over 200 bytes
of unassigned space for future values to be added, yet is nearly
100 bytes smaller per entry than the structure that it replaced.
2000-12-12 07:25:57 +00:00
|
|
|
fill_kinfo_proc (p, &p->p_addr->u_kproc);
|
1996-01-24 18:29:00 +00:00
|
|
|
error = ptrace_write_u(p, (vm_offset_t)uap->addr, uap->data);
|
|
|
|
} else {
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock_spin(&sched_lock);
|
1996-01-24 18:29:00 +00:00
|
|
|
error = EFAULT;
|
|
|
|
}
|
|
|
|
PRELE(p);
|
|
|
|
return error;
|
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
case PT_KILL:
|
1996-01-24 18:29:00 +00:00
|
|
|
uap->data = SIGKILL;
|
|
|
|
goto sendsig; /* in PT_CONTINUE above */
|
|
|
|
|
|
|
|
#ifdef PT_SETREGS
|
|
|
|
case PT_SETREGS:
|
|
|
|
write = 1;
|
|
|
|
/* fallthrough */
|
|
|
|
#endif /* PT_SETREGS */
|
1994-08-08 13:00:27 +00:00
|
|
|
#ifdef PT_GETREGS
|
|
|
|
case PT_GETREGS:
|
1996-01-24 18:29:00 +00:00
|
|
|
/* write = 0 above */
|
|
|
|
#endif /* PT_SETREGS */
|
|
|
|
#if defined(PT_SETREGS) || defined(PT_GETREGS)
|
|
|
|
if (!procfs_validregs(p)) /* no P_SYSTEM procs please */
|
|
|
|
return EINVAL;
|
|
|
|
else {
|
|
|
|
iov.iov_base = uap->addr;
|
|
|
|
iov.iov_len = sizeof(struct reg);
|
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
|
|
|
uio.uio_offset = 0;
|
|
|
|
uio.uio_resid = sizeof(struct reg);
|
|
|
|
uio.uio_segflg = UIO_USERSPACE;
|
|
|
|
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
|
|
|
uio.uio_procp = curp;
|
|
|
|
return (procfs_doregs(curp, p, NULL, &uio));
|
|
|
|
}
|
|
|
|
#endif /* defined(PT_SETREGS) || defined(PT_GETREGS) */
|
|
|
|
|
|
|
|
#ifdef PT_SETFPREGS
|
|
|
|
case PT_SETFPREGS:
|
|
|
|
write = 1;
|
|
|
|
/* fallthrough */
|
|
|
|
#endif /* PT_SETFPREGS */
|
|
|
|
#ifdef PT_GETFPREGS
|
|
|
|
case PT_GETFPREGS:
|
|
|
|
/* write = 0 above */
|
|
|
|
#endif /* PT_SETFPREGS */
|
|
|
|
#if defined(PT_SETFPREGS) || defined(PT_GETFPREGS)
|
|
|
|
if (!procfs_validfpregs(p)) /* no P_SYSTEM procs please */
|
|
|
|
return EINVAL;
|
|
|
|
else {
|
|
|
|
iov.iov_base = uap->addr;
|
|
|
|
iov.iov_len = sizeof(struct fpreg);
|
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
|
|
|
uio.uio_offset = 0;
|
|
|
|
uio.uio_resid = sizeof(struct fpreg);
|
|
|
|
uio.uio_segflg = UIO_USERSPACE;
|
|
|
|
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
|
|
|
uio.uio_procp = curp;
|
|
|
|
return (procfs_dofpregs(curp, p, NULL, &uio));
|
|
|
|
}
|
|
|
|
#endif /* defined(PT_SETFPREGS) || defined(PT_GETFPREGS) */
|
|
|
|
|
1999-07-09 04:16:00 +00:00
|
|
|
#ifdef PT_SETDBREGS
|
|
|
|
case PT_SETDBREGS:
|
|
|
|
write = 1;
|
|
|
|
/* fallthrough */
|
|
|
|
#endif /* PT_SETDBREGS */
|
|
|
|
#ifdef PT_GETDBREGS
|
|
|
|
case PT_GETDBREGS:
|
|
|
|
/* write = 0 above */
|
|
|
|
#endif /* PT_SETDBREGS */
|
|
|
|
#if defined(PT_SETDBREGS) || defined(PT_GETDBREGS)
|
|
|
|
if (!procfs_validdbregs(p)) /* no P_SYSTEM procs please */
|
|
|
|
return EINVAL;
|
|
|
|
else {
|
|
|
|
iov.iov_base = uap->addr;
|
|
|
|
iov.iov_len = sizeof(struct dbreg);
|
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
|
|
|
uio.uio_offset = 0;
|
|
|
|
uio.uio_resid = sizeof(struct dbreg);
|
|
|
|
uio.uio_segflg = UIO_USERSPACE;
|
|
|
|
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
|
|
|
uio.uio_procp = curp;
|
|
|
|
return (procfs_dodbregs(curp, p, NULL, &uio));
|
|
|
|
}
|
|
|
|
#endif /* defined(PT_SETDBREGS) || defined(PT_GETDBREGS) */
|
|
|
|
|
1994-08-08 13:00:27 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1994-08-08 13:00:27 +00:00
|
|
|
trace_req(p)
|
|
|
|
struct proc *p;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1994-08-08 13:00:27 +00:00
|
|
|
return 1;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-12-06 04:11:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* stopevent()
|
|
|
|
* Stop a process because of a procfs event;
|
|
|
|
* stay stopped until p->p_step is cleared
|
|
|
|
* (cleared by PIOCCONT in procfs).
|
2001-01-24 11:15:24 +00:00
|
|
|
*
|
|
|
|
* Must be called with the proc struct mutex held.
|
1997-12-06 04:11:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2001-01-24 11:15:24 +00:00
|
|
|
stopevent(p, event, val)
|
|
|
|
struct proc *p;
|
|
|
|
unsigned int event;
|
|
|
|
unsigned int val;
|
|
|
|
{
|
|
|
|
|
2001-03-07 03:06:18 +00:00
|
|
|
PROC_LOCK_ASSERT(p, MA_OWNED | MA_NOTRECURSED);
|
1997-12-06 04:11:14 +00:00
|
|
|
p->p_step = 1;
|
|
|
|
|
|
|
|
do {
|
|
|
|
p->p_xstat = val;
|
|
|
|
p->p_stype = event; /* Which event caused the stop? */
|
|
|
|
wakeup(&p->p_stype); /* Wake up any PIOCWAIT'ing procs */
|
2001-01-24 11:15:24 +00:00
|
|
|
msleep(&p->p_step, &p->p_mtx, PWAIT, "stopevent", 0);
|
1997-12-06 04:11:14 +00:00
|
|
|
} while (p->p_step);
|
|
|
|
}
|