From patchwork Fri Oct 12 20:46:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Maloy X-Patchwork-Id: 983302 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="ZjfB3muR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42X0Jg4pCgz9s4s for ; Sat, 13 Oct 2018 07:47:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725982AbeJMEVp (ORCPT ); Sat, 13 Oct 2018 00:21:45 -0400 Received: from sesbmg22.ericsson.net ([193.180.251.48]:54512 "EHLO sesbmg22.ericsson.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725745AbeJMEVp (ORCPT ); Sat, 13 Oct 2018 00:21:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1539377247; x=1541969247; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XK1nF3YGpeIvESsO/WrvL/QPteC5B2Cq1FJd4AzfxOY=; b=ZjfB3muRXlTP05qpBwJ0KezfnPAeXPghLP3TYnj9ZL5O8wvrN8JdFMLKxuVgWUJo 0JVH57tPRwZYP84h01JdEVnMcX8lszwwV20bdsaOHOQP58DKE87Guq5U/DXUW69Z pW9wjkUEyDF37mCkRLkEmv/QPj1IBbkcgx8vZVnKEsw=; X-AuditID: c1b4fb30-776849e0000047d2-67-5bc1085f5ed2 Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 1C.10.18386.F5801CB5; Fri, 12 Oct 2018 22:47:27 +0200 (CEST) Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 12 Oct 2018 22:47:02 +0200 Received: from ESESSHC011.ericsson.se (153.88.183.51) by ESESBMB503.ericsson.se (153.88.183.170) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256) id 15.1.1466.3 via Frontend Transport; Fri, 12 Oct 2018 22:47:02 +0200 Received: from daly.lab.linux.ericsson.se (10.35.28.123) by ESESSHC011.ericsson.se (153.88.183.51) with Microsoft SMTP Server (TLS) id 14.3.382.0; Fri, 12 Oct 2018 22:47:01 +0200 From: Jon Maloy To: , CC: , , , , , , Subject: [net 1/1] tipc: fix unsafe rcu locking when accessing publication list Date: Fri, 12 Oct 2018 22:46:55 +0200 Message-ID: <1539377215-29145-1-git-send-email-jon.maloy@ericsson.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-Originating-IP: [10.35.28.123] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsUyM2J7uW48x8Fogw3LpCxuNPQwW8w538Ji sWL3JFaLt69msVscWyBmseV8lsWV9rPsFo+vX2d24PDYsvImk8e7K2weuxd8ZvL4vEnOY/2W rUwBrFFcNimpOZllqUX6dglcGQe/HWErOMRTcfDBcdYGxq1cXYycHBICJhKfZ89h7WLk4hAS OMoo8bj7PwuE841RouHxZkaQKiGBTiaJpftdIextjBKbf5eA2GwCGhIvp3WA1YgIGEu8WtnJ BNLMLPCYUeLL/VVsIAlhgQCJY32LmbsYOThYBFQlzr5gBwnzCrhJfPj2jBXiCjmJ88d/MkPE BSVOznzCAmIzC0hIHHzxghlir7LE3A/TmCDqFSQ+zFrGNoFRYBaSlllIWhYwMq1iFC1OLU7K TTcy0kstykwuLs7P08tLLdnECAzpg1t+G+xgfPnc8RCjAAejEg/v0t8HooVYE8uKK3MPMUpw MCuJ8C7IAgrxpiRWVqUW5ccXleakFh9ilOZgURLntfDbHCUkkJ5YkpqdmlqQWgSTZeLglGpg nN3+IGvWuUm6czKfpQgVyvqoXDZ6fKczxM0y71flkxaOLxavPmxKyhS9dzZXSKktz0BbJdHn /fefzvL7i29IKFZrBKpv5etp8kqbXph2MnL+1ucXRI+uOJjAna67RuX2AW7vVWdfJ5TWOPh8 tnn4bk/OG/3pv4KyTFQksi+tygnRedRief6BEktxRqKhFnNRcSIA/O0XLmUCAAA= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tung Nguyen The binding table's 'cluster_scope' list is rcu protected to handle races between threads changing the list and those traversing the list at the same moment. We have now found that the function named_distribute() uses the regular list_for_each() macro to traverse the said list. Likewise, the function tipc_named_withdraw() is removing items from the same list using the regular list_del() call. When these two functions execute in parallel we see occasional crashes. This commit fixes this by adding the missing _rcu() suffixes. Signed-off-by: Tung Nguyen Signed-off-by: Jon Maloy --- net/tipc/name_distr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index 51b4b96..3cfeb9d 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -115,7 +115,7 @@ struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ) struct sk_buff *buf; struct distr_item *item; - list_del(&publ->binding_node); + list_del_rcu(&publ->binding_node); if (publ->scope == TIPC_NODE_SCOPE) return NULL; @@ -147,7 +147,7 @@ static void named_distribute(struct net *net, struct sk_buff_head *list, ITEM_SIZE) * ITEM_SIZE; u32 msg_rem = msg_dsz; - list_for_each_entry(publ, pls, binding_node) { + list_for_each_entry_rcu(publ, pls, binding_node) { /* Prepare next buffer: */ if (!skb) { skb = named_prepare_buf(net, PUBLICATION, msg_rem,