net: ipv4: ipmr_expire_timer causes crash when removing net namespace
authorFrancesco Ruggeri <fruggeri@aristanetworks.com>
Fri, 24 Aug 2012 07:38:35 +0000 (07:38 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 19 Sep 2012 14:04:57 +0000 (15:04 +0100)
commit4c5e5e2a49816debff35ac5400b0d56a2d57e495
tree62dcfdb66509cd199a1f04998424fc9c15c985fb
parentdb385ea9719a50e852fa7396c4af2213ec342f6c
net: ipv4: ipmr_expire_timer causes crash when removing net namespace

[ Upstream commit acbb219d5f53821b2d0080d047800410c0420ea1 ]

When tearing down a net namespace, ipv4 mr_table structures are freed
without first deactivating their timers. This can result in a crash in
run_timer_softirq.
This patch mimics the corresponding behaviour in ipv6.
Locking and synchronization seem to be adequate.
We are about to kfree mrt, so existing code should already make sure that
no other references to mrt are pending or can be created by incoming traffic.
The functions invoked here do not cause new references to mrt or other
race conditions to be created.
Invoking del_timer_sync guarantees that ipmr_expire_timer is inactive.
Both ipmr_expire_process (whose completion we may have to wait in
del_timer_sync) and mroute_clean_tables internally use mfc_unres_lock
or other synchronizations when needed, and they both only modify mrt.

Tested in Linux 3.4.8.

Signed-off-by: Francesco Ruggeri <fruggeri@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ipv4/ipmr.c