Fix a race condition between the main thread in aqm_pie_cleanup() and the
authortruckman <truckman@FreeBSD.org>
Tue, 5 Jul 2016 00:53:01 +0000 (00:53 +0000)
committertruckman <truckman@FreeBSD.org>
Tue, 5 Jul 2016 00:53:01 +0000 (00:53 +0000)
commit9e6e43be959bda5472c468f080cf53a6b89df4b1
tree7ec59f62a930f6429ad3c14599c07e18bc3efdf0
parent88737253e2b67e4109f85f15f071809a99bb081c
Fix a race condition between the main thread in aqm_pie_cleanup() and the
callout thread that can cause a kernel panic.  Always do the final cleanup
in the callout thread by passing a separate callout function for that task
to callout_reset_sbt().

Protect the ref_count decrement in the callout with DN_BH_WLOCK().  All
other ref_count manipulation is protected with this lock.

There is still a tiny window between ref_count reaching zero and the end
of the callout function where it is unsafe to unload the module.  Fixing
this would require the use of callout_drain(), but this can't be done
because dummynet holds a mutex and callout_drain() might sleep.

Remove the callout_pending(), callout_active(), and callout_deactivate()
calls from calculate_drop_prob().  They are not needed because this callout
uses callout_init_mtx().

Submitted by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
Approved by: re (gjb)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D6928
sys/netpfil/ipfw/dn_aqm_pie.c