diff options
author | jhb <jhb@FreeBSD.org> | 2006-02-07 18:59:47 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2006-02-07 18:59:47 +0000 |
commit | f2894d18f677982f38448279ee02f7c365c8349f (patch) | |
tree | 90aa09ec72f03fed0ca74b4a0eadfb5ada090c66 /sys/kern/kern_acct.c | |
parent | 763746d8104af00df1c70066635c2b3c0040072c (diff) | |
download | FreeBSD-src-f2894d18f677982f38448279ee02f7c365c8349f.zip FreeBSD-src-f2894d18f677982f38448279ee02f7c365c8349f.tar.gz |
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
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r-- | sys/kern/kern_acct.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 6a66da1..ffc9496 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"); |