]> git.karo-electronics.de Git - karo-tx-linux.git/commit
IPoIB: Fix use-after-free of multicast object
authorPatrick McHardy <kaber@trash.net>
Thu, 30 Aug 2012 07:01:30 +0000 (07:01 +0000)
committerRoland Dreier <roland@purestorage.com>
Tue, 18 Sep 2012 17:42:44 +0000 (10:42 -0700)
commitc807a9922efff852754218a0d6d15709fce676bb
tree9d7d0556e30d7caef046398d842dec8597000853
parentb5120a6e11e90d98d8a752545ac60bfa1ea95f1a
IPoIB: Fix use-after-free of multicast object

Fix a crash in ipoib_mcast_join_task().  (with help from Or Gerlitz)

Commit c8c2afe360b7 ("IPoIB: Use rtnl lock/unlock when changing device
flags") added a call to rtnl_lock() in ipoib_mcast_join_task(), which
is run from the ipoib_workqueue, and hence the workqueue can't be
flushed from the context of ipoib_stop().

In the current code, ipoib_stop() (which doesn't flush the workqueue)
calls ipoib_mcast_dev_flush(), which goes and deletes all the
multicast entries.  This takes place without any synchronization with
a possible running instance of ipoib_mcast_join_task() for the same
ipoib device, leading to a crash due to NULL pointer dereference.

Fix this by making sure that the workqueue is flushed before
ipoib_mcast_dev_flush() is called.  To make that possible, we move the
RTNL-lock wrapped code to ipoib_mcast_join_finish().

Signed-off-by: Patrick McHardy <kaber@trash.net>
Cc: <stable@vger.kernel.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/ipoib/ipoib_multicast.c