]> git.baikalelectronics.ru Git - kernel.git/commit
IB/mad: Fix race between cancel and receive completion
authorRoland Dreier <rolandd@cisco.com>
Mon, 13 Nov 2006 17:38:07 +0000 (09:38 -0800)
committerRoland Dreier <rolandd@cisco.com>
Mon, 13 Nov 2006 17:38:07 +0000 (09:38 -0800)
commit20c4b66d8678a209bcf31b7dce2c9a275c4dc323
tree89f594faf977f800893f6fa59213e94e098df386
parent8406fc30d6dc441c64c055a7ff26d15cb618c4c1
IB/mad: Fix race between cancel and receive completion

When ib_cancel_mad() is called, it puts the canceled send on a list
and schedules a "flushed" callback from process context.  However,
this leaves a window where a receive completion could be processed
before the send is fully flushed.

This is fine, except that ib_find_send_mad() will find the MAD and
return it to the receive processing, which results in the sender
getting both a successful receive and a "flushed" send completion for
the same request.  Understandably, this confuses the sender, which is
expecting only one of these two callbacks, and leads to grief such as
a use-after-free in IPoIB.

Fix this by changing ib_find_send_mad() to return a send struct only
if the status is still successful (and not "flushed").  The search of
the send_list already had this check, so this patch just adds the same
check to the search of the wait_list.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/mad.c