]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tipc: make macro tipc_wait_for_cond() smp safe
authorJon Paul Maloy <jon.maloy@ericsson.com>
Thu, 11 May 2017 18:28:15 +0000 (20:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Jun 2017 10:10:00 +0000 (12:10 +0200)
commitd9cb26d6a39f4d75dddf699033d5963b6633b98b
treeaa26327d75d50480e4d9d96d691db37eb2a40360
parentc91cd74b32ecbfa1a796e9f789e229024f9902f1
tipc: make macro tipc_wait_for_cond() smp safe

[ Upstream commit 844cf763fba654436d3a4279b6a672c196cf1901 ]

The macro tipc_wait_for_cond() is embedding the macro sk_wait_event()
to fulfil its task. The latter, in turn, is evaluating the stated
condition outside the socket lock context. This is problematic if
the condition is accessing non-trivial data structures which may be
altered by incoming interrupts, as is the case with the cong_links()
linked list, used by socket to keep track of the current set of
congested links. We sometimes see crashes when this list is accessed
by a condition function at the same time as a SOCK_WAKEUP interrupt
is removing an element from the list.

We fix this by expanding selected parts of sk_wait_event() into the
outer macro, while ensuring that all evaluations of a given condition
are performed under socket lock protection.

Fixes: commit 365ad353c256 ("tipc: reduce risk of user starvation during link congestion")
Reviewed-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/tipc/socket.c