summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_mmap.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2013-09-19 18:53:42 +0000
committerjhb <jhb@FreeBSD.org>2013-09-19 18:53:42 +0000
commitd3ef75b6c79e9e6d642efa9c32a96524d7a5a5b7 (patch)
tree56c7a97f082d488a8b917c2d2d52956076373329 /sys/vm/vm_mmap.c
parent8ecfe4666e7be9cea4cf6c3ef929de2e8d286f41 (diff)
downloadFreeBSD-src-d3ef75b6c79e9e6d642efa9c32a96524d7a5a5b7.zip
FreeBSD-src-d3ef75b6c79e9e6d642efa9c32a96524d7a5a5b7.tar.gz
Extend the support for exempting processes from being killed when swap is
exhausted. - Add a new protect(1) command that can be used to set or revoke protection from arbitrary processes. Similar to ktrace it can apply a change to all existing descendants of a process as well as future descendants. - Add a new procctl(2) system call that provides a generic interface for control operations on processes (as opposed to the debugger-specific operations provided by ptrace(2)). procctl(2) uses a combination of idtype_t and an id to identify the set of processes on which to operate similar to wait6(). - Add a PROC_SPROTECT control operation to manage the protection status of a set of processes. MADV_PROTECT still works for backwards compatability. - Add a p_flag2 to struct proc (and a corresponding ki_flag2 to kinfo_proc) the first bit of which is used to track if P_PROTECT should be inherited by new child processes. Reviewed by: kib, jilles (earlier version) Approved by: re (delphij) MFC after: 1 month
Diffstat (limited to 'sys/vm/vm_mmap.c')
-rw-r--r--sys/vm/vm_mmap.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 0f2d531..17f8cad 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <sys/filedesc.h>
#include <sys/priv.h>
#include <sys/proc.h>
+#include <sys/procctl.h>
#include <sys/racct.h>
#include <sys/resource.h>
#include <sys/resourcevar.h>
@@ -68,6 +69,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mount.h>
#include <sys/conf.h>
#include <sys/stat.h>
+#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/vmmeter.h>
@@ -739,23 +741,18 @@ sys_madvise(td, uap)
{
vm_offset_t start, end;
vm_map_t map;
- struct proc *p;
- int error;
+ int flags;
/*
* Check for our special case, advising the swap pager we are
* "immortal."
*/
if (uap->behav == MADV_PROTECT) {
- error = priv_check(td, PRIV_VM_MADV_PROTECT);
- if (error == 0) {
- p = td->td_proc;
- PROC_LOCK(p);
- p->p_flag |= P_PROTECTED;
- PROC_UNLOCK(p);
- }
- return (error);
+ flags = PPROT_SET;
+ return (kern_procctl(td, P_PID, td->td_proc->p_pid,
+ PROC_SPROTECT, &flags));
}
+
/*
* Check for illegal behavior
*/
OpenPOWER on IntegriCloud