diff options
author | Ying Xue <ying.xue@windriver.com> | 2013-12-09 22:54:47 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-10 22:35:49 -0500 |
commit | 00ede977098be3296d42d05a4265ec5ec4a28419 (patch) | |
tree | 68c532b62c7fa0371da9ca50e903f0a1acd15087 /net/tipc/handler.c | |
parent | 993b858e37b3120ee76d9957a901cca22312ffaa (diff) | |
download | linux-stable-00ede977098be3296d42d05a4265ec5ec4a28419.tar.gz linux-stable-00ede977098be3296d42d05a4265ec5ec4a28419.tar.bz2 linux-stable-00ede977098be3296d42d05a4265ec5ec4a28419.zip |
tipc: protect handler_enabled variable with qitem_lock spin lock
'handler_enabled' is a global flag indicating whether the TIPC
signal handling service is enabled or not. The lack of lock
protection for this flag incurs a risk for contention, so that
a tipc_k_signal() call might queue a signal handler to a destroyed
signal queue, with unpredictable results. To correct this, we let
the already existing 'qitem_lock' protect the flag, as it already
does with the queue itself. This way, we ensure that the flag
always is consistent across all cores.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/handler.c')
-rw-r--r-- | net/tipc/handler.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/net/tipc/handler.c b/net/tipc/handler.c index b36f0fcd9bdf..e4bc8a296744 100644 --- a/net/tipc/handler.c +++ b/net/tipc/handler.c @@ -56,12 +56,13 @@ unsigned int tipc_k_signal(Handler routine, unsigned long argument) { struct queue_item *item; + spin_lock_bh(&qitem_lock); if (!handler_enabled) { pr_err("Signal request ignored by handler\n"); + spin_unlock_bh(&qitem_lock); return -ENOPROTOOPT; } - spin_lock_bh(&qitem_lock); item = kmem_cache_alloc(tipc_queue_item_cache, GFP_ATOMIC); if (!item) { pr_err("Signal queue out of memory\n"); @@ -112,10 +113,14 @@ void tipc_handler_stop(void) struct list_head *l, *n; struct queue_item *item; - if (!handler_enabled) + spin_lock_bh(&qitem_lock); + if (!handler_enabled) { + spin_unlock_bh(&qitem_lock); return; - + } handler_enabled = 0; + spin_unlock_bh(&qitem_lock); + tasklet_kill(&tipc_tasklet); spin_lock_bh(&qitem_lock); |