summaryrefslogtreecommitdiffstats
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2014-02-14 10:05:21 +0000
committerglebius <glebius@FreeBSD.org>2014-02-14 10:05:21 +0000
commit1ea1d562a3cd9a58f90832eaff87d94ede9b5bfc (patch)
treed75437f1387850beb0727915096f9a956d708eb3 /sbin/pfctl
parente7560978e3e057a99776d754c463415dceea5dd7 (diff)
downloadFreeBSD-src-1ea1d562a3cd9a58f90832eaff87d94ede9b5bfc.zip
FreeBSD-src-1ea1d562a3cd9a58f90832eaff87d94ede9b5bfc.tar.gz
Once pf became not covered by a single mutex, many counters in it became
race prone. Some just gather statistics, but some are later used in different calculations. A real problem was the race provoked underflow of the states_cur counter on a rule. Once it goes below zero, it wraps to UINT32_MAX. Later this value is used in pf_state_expires() and any state created by this rule is immediately expired. Thus, make fields states_cur, states_tot and src_nodes of struct pf_rule be counter(9)s. Thanks to Dennis for providing me shell access to problematic box and his help with reproducing, debugging and investigating the problem. Thanks to: Dennis Yusupoff <dyr smartspb.net> Also reported by: dumbbell, pgj, Rambler Sponsored by: Nginx, Inc.
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/pfctl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index cb70e7f..7983ac7 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -791,17 +791,17 @@ pfctl_print_rule_counters(struct pf_rule *rule, int opts)
}
if (opts & PF_OPT_VERBOSE) {
printf(" [ Evaluations: %-8llu Packets: %-8llu "
- "Bytes: %-10llu States: %-6u]\n",
+ "Bytes: %-10llu States: %-6lu]\n",
(unsigned long long)rule->evaluations,
(unsigned long long)(rule->packets[0] +
rule->packets[1]),
(unsigned long long)(rule->bytes[0] +
- rule->bytes[1]), rule->states_cur);
+ rule->bytes[1]), (uint64_t)rule->states_cur);
if (!(opts & PF_OPT_DEBUG))
printf(" [ Inserted: uid %u pid %u "
- "State Creations: %-6u]\n",
+ "State Creations: %-6lu]\n",
(unsigned)rule->cuid, (unsigned)rule->cpid,
- rule->states_tot);
+ (uint64_t)rule->states_tot);
}
}
OpenPOWER on IntegriCloud