sys_process.c (71567) | sys_process.c (72200) |
---|---|
1/* 2 * Copyright (c) 1994, Sean Eric Fagan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * | 1/* 2 * Copyright (c) 1994, Sean Eric Fagan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * |
31 * $FreeBSD: head/sys/kern/sys_process.c 71567 2001-01-24 11:15:24Z jhb $ | 31 * $FreeBSD: head/sys/kern/sys_process.c 72200 2001-02-09 06:11:45Z bmilekic $ |
32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/sysproto.h> 37#include <sys/proc.h> 38#include <sys/vnode.h> 39#include <sys/ptrace.h> --- 239 unchanged lines hidden (view full) --- 279 PROCTREE_LOCK(PT_SHARED); 280 if (p->p_pptr != curp) { 281 PROCTREE_LOCK(PT_RELEASE); 282 return EBUSY; 283 } 284 PROCTREE_LOCK(PT_RELEASE); 285 286 /* not currently stopped */ | 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/sysproto.h> 37#include <sys/proc.h> 38#include <sys/vnode.h> 39#include <sys/ptrace.h> --- 239 unchanged lines hidden (view full) --- 279 PROCTREE_LOCK(PT_SHARED); 280 if (p->p_pptr != curp) { 281 PROCTREE_LOCK(PT_RELEASE); 282 return EBUSY; 283 } 284 PROCTREE_LOCK(PT_RELEASE); 285 286 /* not currently stopped */ |
287 mtx_enter(&sched_lock, MTX_SPIN); | 287 mtx_lock_spin(&sched_lock); |
288 if (p->p_stat != SSTOP || (p->p_flag & P_WAITED) == 0) { | 288 if (p->p_stat != SSTOP || (p->p_flag & P_WAITED) == 0) { |
289 mtx_exit(&sched_lock, MTX_SPIN); | 289 mtx_unlock_spin(&sched_lock); |
290 return EBUSY; 291 } | 290 return EBUSY; 291 } |
292 mtx_exit(&sched_lock, MTX_SPIN); | 292 mtx_unlock_spin(&sched_lock); |
293 294 /* OK */ 295 break; 296 297 default: 298 return EINVAL; 299 } 300 --- 71 unchanged lines hidden (view full) --- 372 373 /* should we send SIGCHLD? */ 374 375 } 376 377 sendsig: 378 /* deliver or queue signal */ 379 s = splhigh(); | 293 294 /* OK */ 295 break; 296 297 default: 298 return EINVAL; 299 } 300 --- 71 unchanged lines hidden (view full) --- 372 373 /* should we send SIGCHLD? */ 374 375 } 376 377 sendsig: 378 /* deliver or queue signal */ 379 s = splhigh(); |
380 mtx_enter(&sched_lock, MTX_SPIN); | 380 mtx_lock_spin(&sched_lock); |
381 if (p->p_stat == SSTOP) { 382 p->p_xstat = uap->data; 383 setrunnable(p); | 381 if (p->p_stat == SSTOP) { 382 p->p_xstat = uap->data; 383 setrunnable(p); |
384 mtx_exit(&sched_lock, MTX_SPIN); | 384 mtx_unlock_spin(&sched_lock); |
385 } else { | 385 } else { |
386 mtx_exit(&sched_lock, MTX_SPIN); | 386 mtx_unlock_spin(&sched_lock); |
387 if (uap->data) { 388 mtx_assert(&Giant, MA_OWNED); 389 psignal(p, uap->data); 390 } 391 } 392 splx(s); 393 return 0; 394 --- 37 unchanged lines hidden (view full) --- 432 return EFAULT; 433 } 434 if (ptrace_read_u_check(p,(vm_offset_t) uap->addr, 435 sizeof(int))) { 436 return EFAULT; 437 } 438 error = 0; 439 PHOLD(p); /* user had damn well better be incore! */ | 387 if (uap->data) { 388 mtx_assert(&Giant, MA_OWNED); 389 psignal(p, uap->data); 390 } 391 } 392 splx(s); 393 return 0; 394 --- 37 unchanged lines hidden (view full) --- 432 return EFAULT; 433 } 434 if (ptrace_read_u_check(p,(vm_offset_t) uap->addr, 435 sizeof(int))) { 436 return EFAULT; 437 } 438 error = 0; 439 PHOLD(p); /* user had damn well better be incore! */ |
440 mtx_enter(&sched_lock, MTX_SPIN); | 440 mtx_lock_spin(&sched_lock); |
441 if (p->p_sflag & PS_INMEM) { | 441 if (p->p_sflag & PS_INMEM) { |
442 mtx_exit(&sched_lock, MTX_SPIN); | 442 mtx_unlock_spin(&sched_lock); |
443 fill_kinfo_proc (p, &p->p_addr->u_kproc); 444 curp->p_retval[0] = *(int *) 445 ((uintptr_t)p->p_addr + (uintptr_t)uap->addr); 446 } else { | 443 fill_kinfo_proc (p, &p->p_addr->u_kproc); 444 curp->p_retval[0] = *(int *) 445 ((uintptr_t)p->p_addr + (uintptr_t)uap->addr); 446 } else { |
447 mtx_exit(&sched_lock, MTX_SPIN); | 447 mtx_unlock_spin(&sched_lock); |
448 curp->p_retval[0] = 0; 449 error = EFAULT; 450 } 451 PRELE(p); 452 return error; 453 454 case PT_WRITE_U: 455 PHOLD(p); /* user had damn well better be incore! */ | 448 curp->p_retval[0] = 0; 449 error = EFAULT; 450 } 451 PRELE(p); 452 return error; 453 454 case PT_WRITE_U: 455 PHOLD(p); /* user had damn well better be incore! */ |
456 mtx_enter(&sched_lock, MTX_SPIN); | 456 mtx_lock_spin(&sched_lock); |
457 if (p->p_sflag & PS_INMEM) { | 457 if (p->p_sflag & PS_INMEM) { |
458 mtx_exit(&sched_lock, MTX_SPIN); | 458 mtx_unlock_spin(&sched_lock); |
459 fill_kinfo_proc (p, &p->p_addr->u_kproc); 460 error = ptrace_write_u(p, (vm_offset_t)uap->addr, uap->data); 461 } else { | 459 fill_kinfo_proc (p, &p->p_addr->u_kproc); 460 error = ptrace_write_u(p, (vm_offset_t)uap->addr, uap->data); 461 } else { |
462 mtx_exit(&sched_lock, MTX_SPIN); | 462 mtx_unlock_spin(&sched_lock); |
463 error = EFAULT; 464 } 465 PRELE(p); 466 return error; 467 468 case PT_KILL: 469 uap->data = SIGKILL; 470 goto sendsig; /* in PT_CONTINUE above */ --- 119 unchanged lines hidden --- | 463 error = EFAULT; 464 } 465 PRELE(p); 466 return error; 467 468 case PT_KILL: 469 uap->data = SIGKILL; 470 goto sendsig; /* in PT_CONTINUE above */ --- 119 unchanged lines hidden --- |