IB/uverbs: Protect QP multicast list
authorEli Cohen <eli@dev.mellanox.co.il>
Wed, 4 Jan 2012 04:36:48 +0000 (20:36 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 12 Jan 2012 19:29:24 +0000 (11:29 -0800)
commit585ea9bc6752c41d669ea0f4cee8f3954df326e0
tree9089e0928ac101795d5d3dab93fc9dbac32d89ce
parent0d878668d0a4663a4807d413532f3a99496eebf4
IB/uverbs: Protect QP multicast list

commit e214a0fe2b382fa302c036ecd6e6ffe99e3b9875 upstream.

Userspace verbs multicast attach/detach operations on a QP are done
while holding the rwsem of the QP for reading.  That's not sufficient
since a reader lock allows more than one reader to acquire the
lock.  However, multicast attach/detach does list manipulation that
can corrupt the list if multiple threads run in parallel.

Fix this by acquiring the rwsem as a writer to serialize attach/detach
operations.  Add idr_write_qp() and put_qp_write() to encapsulate
this.

This fixes oops seen when running applications that perform multicast
joins/leaves.

Reported by: Mike Dubman <miked@mellanox.com>
Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/infiniband/core/uverbs_cmd.c