Prevent crashes due to unlocked access to hash buckets in two sysctls.

Use CACHE_LOCK to prevent crashes.

Sysctls fixed: debug.hashstat.nchash and debug.hashstat.rawnchash.

Obtained from: Juniper Networks
MFC After: 1 week
This commit is contained in:
alfred 2008-08-16 21:48:10 +00:00
parent 03af772d71
commit f8f6317629

View File

@ -199,10 +199,12 @@ sysctl_debug_hashstat_rawnchash(SYSCTL_HANDLER_ARGS)
/* Scan hash tables for applicable entries */
for (ncpp = nchashtbl; n_nchash > 0; n_nchash--, ncpp++) {
CACHE_LOCK();
count = 0;
LIST_FOREACH(ncp, ncpp, nc_hash) {
count++;
}
CACHE_UNLOCK();
error = SYSCTL_OUT(req, &count, sizeof(count));
if (error)
return (error);
@ -231,9 +233,11 @@ sysctl_debug_hashstat_nchash(SYSCTL_HANDLER_ARGS)
/* Scan hash tables for applicable entries */
for (ncpp = nchashtbl; n_nchash > 0; n_nchash--, ncpp++) {
count = 0;
CACHE_LOCK();
LIST_FOREACH(ncp, ncpp, nc_hash) {
count++;
}
CACHE_UNLOCK();
if (count)
used++;
if (maxlength < count)