Commit Graph

162 Commits

Author SHA1 Message Date
jmcneill bcb36a3aae PR# kern/45330: ptrace: signals can alter syscall return values
process_stoptrace: defer signal processing to userret, ok christos@
2011-09-06 11:22:42 +00:00
christos 179ba60291 add support for PRACE_FORK. 2011-09-02 20:07:41 +00:00
jmcneill 1904b2b8db PR# kern/45312: ptrace: PT_SETREGS can't alter system calls
Add a new PT_SYSCALLEMU request that cancels the current syscall, for
use with PT_SYSCALL.
2011-08-31 22:58:39 +00:00
christos b179ba6b46 Process the signal now, otherwise calling issignal() and ignoring
the return will lose the signal if it came from the debugger
(issignal() clears p->p_xstat)
2011-08-30 22:45:55 +00:00
jmcneill 41a1fc0b6b PR# kern/43681: PT_SYSCALL appears to be broken
sys_ptrace: For PT_CONTINUE/PT_SYSCALL/PT_DETACH, modify the p_trace_enabled
flag of the target process, not the calling process.
2011-08-29 17:31:50 +00:00
mrg 2624874e7c avoid some uninitialised variable warnings from GCC.
at least the puffs one seems valid, but i'm not 100% sure.
2011-07-03 08:57:43 +00:00
rmind 3c507045e2 Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour.  Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
2010-07-01 02:38:26 +00:00
christos 2909eda13b fix build for ports that don't have PT_STEP (Havard Eidnes) 2010-04-07 13:10:46 +00:00
christos ca843a73b0 PR/43128: Paul Koning: Threads support in ptrace() is insufficient for gdb to
debug threaded live apps: Add an optional lwpid in PT_STEP and PT_CONTINUE to
indicate which lwp to operate on, and implement the glue required to make it
work.
2010-04-06 13:50:22 +00:00
rmind 1069745866 Replace few USER_TO_UAREA/UAREA_TO_USER uses, reduce sys/user.h inclusions. 2009-12-17 01:25:10 +00:00
matt e110dba586 Merge from matt-nb5-mips64 2009-12-14 00:47:10 +00:00
rmind 40cf6f3659 Remove uarea swap-out functionality:
- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code.  Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
2009-10-21 21:11:57 +00:00
elad fa69dc186a Install floppies (haha) don't get built with ktrace/ptrace, so they don't
include kern/sys_process.c. Move proc_uidmatch() to kern/kern_proc.c which
always gets built instead.

Pointed out by Kurt Schreiner on current-users@:

    http://mail-index.netbsd.org/current-users/2009/10/03/msg010745.html
2009-10-04 03:15:08 +00:00
elad bcc5014bd0 Move rlimit policy back to the subsystem.
For this we needed proc_uidmatch() exposed, which makes a lot of sense,
so put it back in sys_process.c for use in other places as well.
2009-10-02 22:38:45 +00:00
elad 2ae3a70827 Move ptrace's security policy back to the subsystem itself.
Add a ptrace_init() so we have a place to register the listener; called
next to ktrinit().
2009-10-02 22:18:56 +00:00
yamt 85542b11cd wrap a long line. 2009-06-28 11:42:07 +00:00
ad 3c32363107 PR kern/36183 problem with ptrace and multithreaded processes
Fix the crashy test case that Thor provided.
2009-02-04 21:17:39 +00:00
yamt cb1e92d5d5 malloc -> kmem_alloc 2009-01-22 14:38:34 +00:00
ad 92ce8c6a3d Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
2008-11-19 18:35:57 +00:00
wrstuden 53908c9c0a Pull in a fix from wrstuden-revivesa:
Let's look for threads in the TARGET process, not in the
debugger process (gdb). Noticed when a KASSERT fired while
running gdb on a threaded app.

I will adjust wrstuden-revivesa-base-3 to include this change.
2008-09-27 03:52:24 +00:00
yamt 75734d288f process_stoptrace: fix a locking botch. 2008-08-28 06:23:42 +00:00
rmind 160268aca6 Remove proc_representative_lwp(), use a simple LIST_FIRST() instead.
OK by <ad>.
2008-07-02 19:49:58 +00:00
yamt c27d8958e0 sys_ptrace: fix a locking botch. PR/38649 from Martin Husemann. 2008-05-13 09:16:11 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 284c2b9aef Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
2008-04-24 18:39:20 +00:00
ad 6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
dsl 5546b33571 Set p->p_trace_enabled in fork and whenever the controlling falgs change
instead of doing it in syscall_intern().
Note that syscall_intern() must still be called when the flags change
since many ports use a different copy of the syscall entry code when
tracing is enabled.
2008-02-24 18:30:07 +00:00
elad c27d5f30b6 Tons of process scope changes.
- Add a KAUTH_PROCESS_SCHEDULER action, to handle scheduler related
    requests, and add specific requests for set/get scheduler policy and
    set/get scheduler parameters.

  - Add a KAUTH_PROCESS_KEVENT_FILTER action, to handle kevent(2) related
    requests.

  - Add a KAUTH_DEVICE_TTY_STI action to handle requests to TIOCSTI.

  - Add requests for the KAUTH_PROCESS_CANSEE action, indicating what
    process information is being looked at (entry itself, args, env,
    open files).

  - Add requests for the KAUTH_PROCESS_RLIMIT action indicating set/get.

  - Add requests for the KAUTH_PROCESS_CORENAME action indicating set/get.

  - Make bsd44 secmodel code handle the newly added rqeuests appropriately.

All of the above make it possible to issue finer-grained kauth(9) calls in
many places, removing some KAUTH_GENERIC_ISSUSER requests.

  - Remove the "CAN" from KAUTH_PROCESS_CAN{KTRACE,PROCFS,PTRACE,SIGNAL}.

Discussed with christos@ and yamt@.
2008-01-23 15:04:38 +00:00
dsl 463af8509e Don't pass curlwp into process_stoptrace() 2008-01-05 12:41:43 +00:00
ad 2ecdf58c2c Remove systrace. Ok core@. 2007-12-31 15:31:24 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
ad d18c6ca4de Merge from vmlocking:
- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
2007-11-07 00:23:13 +00:00
ad bccf777b72 Make ras_lookup() lockless. 2007-10-24 14:50:38 +00:00
ad 15b0a1106e Merge from vmlocking: don't add a refrerence to a dying LWP. 2007-10-08 14:08:26 +00:00
dsl 0ca3d21b5b Include sys/cdefs.h first. 2007-09-21 19:14:12 +00:00
ad 4688843d2b Merge unobtrusive locking changes from the vmlocking branch. 2007-07-21 19:21:53 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
ad b0c22204d2 process_stoptrace: after setting a pending stop on curproc, call issignal
once to have it do the needful. PR kern/36161.
2007-04-19 22:42:10 +00:00
skrll 335ac44f76 Restore previous semantics of PT_LWPINFO and make sure to lwp_addref the
LWP.

OK'ed by ad.
2007-03-15 20:55:15 +00:00
ad c147748d84 - 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.
2007-03-09 14:11:22 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
pavel 934634a18c Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
2007-02-17 22:31:36 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
elad 8764325d83 Refactor a bit the ptrace(2) code: first make the keep-kernel-stable
decisions, then have a kauth(9) call for security policy enforcement,
and only then proceed to processing each request.

Add a KAUTH_PROCESS_CANSEE call right after pfind(). This should really
be done differently, so mark it with XXX.
2006-12-27 10:02:46 +00:00
christos 99f8337886 get the vmspace first before you try to use it. 2006-12-06 18:54:02 +00:00
elad edad69123e PR/25741: ITOH Yasufumi: ras(9) sequence is not protected against ptrace(2)
Okay christos@
2006-12-04 18:50:19 +00:00
elad 233dc909a8 Kill process_checkioperm().
While here, adjust comments.
2006-11-28 17:58:10 +00:00
elad 8bb202af97 Move ktrace, ptrace, systrace, and procfs to use kauth(9).
First, remove process_checkioperm() calls from MD code. Similar checks
using kauth(9) routines (on the process scope, using appropriate action)
are done in the callers.

Add secmodel back-end to handle each subsystem.
2006-11-28 17:27:09 +00:00
christos b7cb52a381 for pt_syscall, send a signal to our parent, not out grandparent. Noted by
mrg and ad.
2006-11-13 02:52:08 +00:00
yamt caa14e011b kill signal "dolock" hacks.
related to PR/32962 and PR/34895.  reviewed by matthew green.
2006-11-01 09:46:14 +00:00