summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorjonathan <jonathan@FreeBSD.org>2011-08-18 22:51:30 +0000
committerjonathan <jonathan@FreeBSD.org>2011-08-18 22:51:30 +0000
commit5ecd1c9d4080f3ae8a48c02523542b308b562160 (patch)
treeec80efcada771dd68fe28d71eaf850289af0e772 /sys/kern/kern_sig.c
parentc902e656105666eb86ca08b9d534253d3f831d46 (diff)
downloadFreeBSD-src-5ecd1c9d4080f3ae8a48c02523542b308b562160.zip
FreeBSD-src-5ecd1c9d4080f3ae8a48c02523542b308b562160.tar.gz
Add experimental support for process descriptors
A "process descriptor" file descriptor is used to manage processes without using the PID namespace. This is required for Capsicum's Capability Mode, where the PID namespace is unavailable. New system calls pdfork(2) and pdkill(2) offer the functional equivalents of fork(2) and kill(2). pdgetpid(2) allows querying the PID of the remote process for debugging purposes. The currently-unimplemented pdwait(2) will, in the future, allow querying rusage/exit status. In the interim, poll(2) may be used to check (and wait for) process termination. When a process is referenced by a process descriptor, it does not issue SIGCHLD to the parent, making it suitable for use in libraries---a common scenario when using library compartmentalisation from within large applications (such as web browsers). Some observers may note a similarity to Mach task ports; process descriptors provide a subset of this behaviour, but in a UNIX style. This feature is enabled by "options PROCDESC", but as with several other Capsicum kernel features, is not enabled by default in GENERIC 9.0. Reviewed by: jhb, kib Approved by: re (kib), mentor (rwatson) Sponsored by: Google Inc
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index e1861eb..26ef0d7 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -41,12 +41,14 @@ __FBSDID("$FreeBSD$");
#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_core.h"
+#include "opt_procdesc.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/vnode.h>
#include <sys/acct.h>
+#include <sys/capability.h>
#include <sys/condvar.h>
#include <sys/event.h>
#include <sys/fcntl.h>
@@ -59,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/procdesc.h>
#include <sys/posix4.h>
#include <sys/pioctl.h>
#include <sys/racct.h>
@@ -1698,6 +1701,34 @@ kill(struct thread *td, struct kill_args *uap)
/* NOTREACHED */
}
+int
+pdkill(td, uap)
+ struct thread *td;
+ struct pdkill_args *uap;
+{
+#ifdef PROCDESC
+ struct proc *p;
+ int error;
+
+ AUDIT_ARG_SIGNUM(uap->signum);
+ AUDIT_ARG_FD(uap->fd);
+ if ((u_int)uap->signum > _SIG_MAXSIG)
+ return (EINVAL);
+
+ error = procdesc_find(td, uap->fd, CAP_PDKILL, &p);
+ if (error)
+ return (error);
+ AUDIT_ARG_PROCESS(p);
+ error = p_cansignal(td, p, uap->signum);
+ if (error == 0 && uap->signum)
+ psignal(p, uap->signum);
+ PROC_UNLOCK(p);
+ return (error);
+#else
+ return (ENOSYS);
+#endif
+}
+
#if defined(COMPAT_43)
#ifndef _SYS_SYSPROTO_H_
struct okillpg_args {
OpenPOWER on IntegriCloud