aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_acct.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2006-02-07 18:59:47 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2006-02-07 18:59:47 +0000
commit222fdf4bff7c7eb961027923b14ac76b5838b5ea (patch)
tree90aa09ec72f03fed0ca74b4a0eadfb5ada090c66 /sys/kern/kern_acct.c
parent37a395c11023e18f656ccfc6f59c1c57a0e9b9d1 (diff)
downloadsrc-222fdf4bff7c7eb961027923b14ac76b5838b5ea.tar.gz
src-222fdf4bff7c7eb961027923b14ac76b5838b5ea.zip
Provide some anti-footshooting. Don't allow the user to set the interval
for acctwatch() runs to be negative or zero as this could result in either a possible hang (or panic if INVARIANTS is on). Previously the accounting code handled the <= 0 case by calling acctwatch on every clock tick (eww!) due to an implementation detail of callout_reset(). (Tick counts of <= 0 are converted to 1). MFC after: 3 days
Notes
Notes: svn path=/head/; revision=155438
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r--sys/kern/kern_acct.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index 6a66da17497a..ffc9496f45fc 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -122,8 +122,29 @@ SYSCTL_INT(_kern, OID_AUTO, acct_resume, CTLFLAG_RW,
&acctresume, 0, "percentage of free disk space above which accounting resumes");
static int acctchkfreq = 15; /* frequency (in seconds) to check space */
-SYSCTL_INT(_kern, OID_AUTO, acct_chkfreq, CTLFLAG_RW,
- &acctchkfreq, 0, "frequency for checking the free space");
+
+static int
+sysctl_acct_chkfreq(SYSCTL_HANDLER_ARGS)
+{
+ int error, value;
+
+ /* Write out the old value. */
+ error = SYSCTL_OUT(req, &acctchkfreq, sizeof(int));
+ if (error || req->newptr == NULL)
+ return (error);
+
+ /* Read in and verify the new value. */
+ error = SYSCTL_IN(req, &value, sizeof(int));
+ if (error)
+ return (error);
+ if (value <= 0)
+ return (EINVAL);
+ acctchkfreq = value;
+ return (0);
+}
+SYSCTL_PROC(_kern, OID_AUTO, acct_chkfreq, CTLTYPE_INT|CTLFLAG_RW,
+ &acctchkfreq, 0, sysctl_acct_chkfreq, "I",
+ "frequency for checking the free space");
SYSCTL_INT(_kern, OID_AUTO, acct_suspended, CTLFLAG_RD, &acct_suspended, 0,
"Accounting suspended or not");