aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2011-04-05 20:23:59 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2011-04-05 20:23:59 +0000
commit1ba5ad4210627e14e9b65653121b97820a812029 (patch)
treeff083b539865dc2215b27827e89a3109487e5979 /sys/kern
parentc98fe0a557fc7d06049820035de59540c8ddb62d (diff)
downloadsrc-1ba5ad4210627e14e9b65653121b97820a812029.tar.gz
src-1ba5ad4210627e14e9b65653121b97820a812029.zip
Add accounting for most of the memory-related resources.
Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version)
Notes
Notes: svn path=/head/; revision=220373
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/imgact_aout.c4
-rw-r--r--sys/kern/imgact_elf.c12
-rw-r--r--sys/kern/imgact_gzip.c5
3 files changed, 18 insertions, 3 deletions
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c
index 2f168d89ecdc..2f889ca915cb 100644
--- a/sys/kern/imgact_aout.c
+++ b/sys/kern/imgact_aout.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/syscall.h>
@@ -245,7 +246,8 @@ exec_aout_imgact(struct image_params *imgp)
a_out->a_text > maxtsiz ||
/* data + bss can't exceed rlimit */
- a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA)) {
+ a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
+ racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {
PROC_UNLOCK(imgp->proc);
return (ENOMEM);
}
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 80bb7000a635..b41741ad3dc3 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <sys/pioctl.h>
#include <sys/proc.h>
#include <sys/procfs.h>
+#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/sf_buf.h>
#include <sys/smp.h>
@@ -874,7 +875,9 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
PROC_LOCK(imgp->proc);
if (data_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
text_size > maxtsiz ||
- total_size > lim_cur(imgp->proc, RLIMIT_VMEM)) {
+ total_size > lim_cur(imgp->proc, RLIMIT_VMEM) ||
+ racct_set(imgp->proc, RACCT_DATA, data_size) != 0 ||
+ racct_set(imgp->proc, RACCT_VMEM, total_size) != 0) {
PROC_UNLOCK(imgp->proc);
return (ENOMEM);
}
@@ -1101,6 +1104,13 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
hdrsize = 0;
__elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count);
+ PROC_LOCK(td->td_proc);
+ error = racct_add(td->td_proc, RACCT_CORE, hdrsize + seginfo.size);
+ PROC_UNLOCK(td->td_proc);
+ if (error != 0) {
+ error = EFAULT;
+ goto done;
+ }
if (hdrsize + seginfo.size >= limit) {
error = EFAULT;
goto done;
diff --git a/sys/kern/imgact_gzip.c b/sys/kern/imgact_gzip.c
index 66f40f61b6dd..c83f36b6da59 100644
--- a/sys/kern/imgact_gzip.c
+++ b/sys/kern/imgact_gzip.c
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mman.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/sysent.h>
#include <sys/systm.h>
@@ -216,7 +217,9 @@ do_aout_hdr(struct imgact_gzip * gz)
/* data + bss can't exceed rlimit */
gz->a_out.a_data + gz->bss_size >
- lim_cur(gz->ip->proc, RLIMIT_DATA)) {
+ lim_cur(gz->ip->proc, RLIMIT_DATA) ||
+ racct_set(gz->ip->proc, RACCT_DATA,
+ gz->a_out.a_data + gz->bss_size) != 0) {
PROC_UNLOCK(gz->ip->proc);
gz->where = __LINE__;
return (ENOMEM);