From patchwork Fri Mar 6 12:13:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18078 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 72B7A80868; Fri, 6 Mar 2020 13:13:22 +0100 (CET) Received: from simonwunderlich.de (packetmixer.de [IPv6:2001:4d88:2000:24::c0de]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 7ADAC801D6 for ; Fri, 6 Mar 2020 13:13:19 +0100 (CET) Received: from kero.packetmixer.de (p200300C597077300B0A48B46F0435C76.dip0.t-ipconnect.de [IPv6:2003:c5:9707:7300:b0a4:8b46:f043:5c76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 40D5B6205E; Fri, 6 Mar 2020 13:13:19 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net Subject: [PATCH 1/3] batman-adv: Start new development cycle Date: Fri, 6 Mar 2020 13:13:15 +0100 Message-Id: <20200306121317.28931-2-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200306121317.28931-1-sw@simonwunderlich.de> References: <20200306121317.28931-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1583496799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j02pm7EYl4aZr4F7SbbUXiNe6gVDfIF4HYHeQfkR3pI=; b=VH+BseI3wTV3mfXqS0t5z3knSM0OBr6YVxn3JRmJ/M+rwPoNTHTCa8sH1MljyTmRe4RO+l T4ot0ZJ8TVOGLdcdHfR1/KBtafvzArmw5V50Xb+sOgc1kNGeQVcyFjYJZMYorKqkUcKA/Z V0Ec8qT+FdH1aqQCudwjyRBMDSl/U3o= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1583496799; a=rsa-sha256; cv=none; b=CSmeR8V/hQcrDaI7MCWS4k/MwtI9dqZJAmwtFNFhY5CunzrUZhVgm9KjlogIwo5X4jRgWe 8ubrMsvji8xkEck5WPlwtU7XPnX3XbwPCYv3vps84x9ptSt6gSlEo2BT8YPoocpxt58H6j Rvb/LxKAcS8+sj/dzDBWB2tc1DbgMGQ= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 2001:4d88:2000:24::c0de as permitted sender) smtp.mailfrom=sw@simonwunderlich.de X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 692306df7b6f..2a234d0ad445 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2020.0" +#define BATADV_SOURCE_VERSION "2020.1" #endif /* B.A.T.M.A.N. parameters */ From patchwork Fri Mar 6 12:13:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18079 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id EBB9E8086B; Fri, 6 Mar 2020 13:13:33 +0100 (CET) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id D01FC802A0 for ; Fri, 6 Mar 2020 13:13:19 +0100 (CET) Received: from kero.packetmixer.de (p200300C597077300B0A48B46F0435C76.dip0.t-ipconnect.de [IPv6:2003:c5:9707:7300:b0a4:8b46:f043:5c76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 916C56205F; Fri, 6 Mar 2020 13:13:19 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net Subject: [PATCH 2/3] batman-adv: Avoid RCU list-traversal in spinlock Date: Fri, 6 Mar 2020 13:13:16 +0100 Message-Id: <20200306121317.28931-3-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200306121317.28931-1-sw@simonwunderlich.de> References: <20200306121317.28931-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1583496799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OhGcenzURxT/W2iT6n5KT9gSdZjaCCLdfVgx9oGalHM=; b=U1WGSs5qc2PF5g4PxOw2wv2IoOAwtoMrgQXdHfIEGwyCSdBfxc8ZGtV4jatGP6ahsCxMsi /Ke0tMhud/UTyuneGOx95qizZgHQtw0Bn2FldYeyLYmal/4J9Mvhz4r8T2KMXGQ1aGrda8 Fi1XV4E0RJEUZwVfzfqqbObExrbriGY= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1583496799; a=rsa-sha256; cv=none; b=zmjLOF0GRbM2rdlJRCE/JOu4ty6HQaP9ONIsWEzAuXp7fUSFQRb/BDA/n2QIkaxhrNp9sF acoEDcWQ8JalPaB2qIx7s1lwydHtVrdMGos+lU0d/Ub+l6sbZym23Hze1h0+r7lS7bH+3Z qqc2mwE2IJzGD6O3TLoF5oyjzUrIHlc= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 79.140.42.25 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Madhuparna Bhowmik Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Sven Eckelmann The new CONFIG_PROVE_RCU_LIST requires a condition statement in (h)list_for_each_entry_rcu when the code might be executed in a non RCU non-reader section with the writer lock. Otherwise lockdep might cause a false positive warning like ============================= WARNING: suspicious RCU usage ----------------------------- translation-table.c:940 RCU-list traversed in non-reader section!! batman-adv is (mostly) following the examples from the RCU documentation and is using the normal list-traversal primitives instead of the RCU list-traversal primitives when the writer (spin)lock is held. The remaining users of RCU list-traversal primitives with writer spinlock have to be converted to the same style as the rest of the code. Reported-by: Madhuparna Bhowmik Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/translation-table.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 852932838ddc..a9635c882fe0 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -862,7 +862,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, u8 *tt_change_ptr; spin_lock_bh(&orig_node->vlan_list_lock); - hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) { + hlist_for_each_entry(vlan, &orig_node->vlan_list, list) { num_vlan++; num_entries += atomic_read(&vlan->tt.num_entries); } @@ -888,7 +888,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, (*tt_data)->num_vlan = htons(num_vlan); tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1); - hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) { + hlist_for_each_entry(vlan, &orig_node->vlan_list, list) { tt_vlan->vid = htons(vlan->vid); tt_vlan->crc = htonl(vlan->tt.crc); @@ -937,7 +937,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, int change_offset; spin_lock_bh(&bat_priv->softif_vlan_list_lock); - hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { + hlist_for_each_entry(vlan, &bat_priv->softif_vlan_list, list) { vlan_entries = atomic_read(&vlan->tt.num_entries); if (vlan_entries < 1) continue; @@ -967,7 +967,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, (*tt_data)->num_vlan = htons(num_vlan); tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1); - hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { + hlist_for_each_entry(vlan, &bat_priv->softif_vlan_list, list) { vlan_entries = atomic_read(&vlan->tt.num_entries); if (vlan_entries < 1) continue; From patchwork Fri Mar 6 12:13:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18080 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 2DC2780A65; Fri, 6 Mar 2020 13:13:40 +0100 (CET) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 31B6C801D6 for ; Fri, 6 Mar 2020 13:13:20 +0100 (CET) Received: from kero.packetmixer.de (p200300C597077300B0A48B46F0435C76.dip0.t-ipconnect.de [IPv6:2003:c5:9707:7300:b0a4:8b46:f043:5c76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id E2BB36206B; Fri, 6 Mar 2020 13:13:19 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net Subject: [PATCH 3/3] batman-adv: Replace zero-length array with flexible-array member Date: Fri, 6 Mar 2020 13:13:17 +0100 Message-Id: <20200306121317.28931-4-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200306121317.28931-1-sw@simonwunderlich.de> References: <20200306121317.28931-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1583496800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0GL00Q8Wkr2RGYMViiZ7k1VJPVbpY9k9YZYuaWqu3aA=; b=fVL1xC5lO2uZlvIZ+8mBazjjxG8JuL/3mDyk7fFu981yNUu2ufsxZYTYoG+TWFQ4tgjnQN lwrpSWdFKrAO3oa1PfIOXwKRYcLqjH9MubweJWKLRwqurbQqo9XNCOM07lP7U0Apz5yoVm RTB+3PjaO4d0XgW2y0DU/o/L/h9fLJY= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1583496800; a=rsa-sha256; cv=none; b=WRMQAd8A6ao2oK9mdOlIETskckVIJMSusnrZmcBH1+WwgO+U4Gf6KYzC/67Sj0isXIJG34 6Z52v+KaqZjIUSwwaxzzlLQUFKRCIplodBW1jgZoxFYKXRxpaHmXKq/+i2VEz6TEdjJfXs Nad1n4ZVDcmEjsNiGWuQ9sJB6Ixej6A= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 79.140.42.25 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, "Gustavo A. R. Silva" Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: "Gustavo A. R. Silva" The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by: Gustavo A. R. Silva Signed-off-by: Sven Eckelman Signed-off-by: Simon Wunderlich --- net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 3d21dd83f8cc..b85da4b7a77b 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -88,7 +88,7 @@ struct batadv_dhcp_packet { __u8 sname[64]; __u8 file[128]; __be32 magic; - __u8 options[0]; + __u8 options[]; }; #define BATADV_DHCP_YIADDR_LEN sizeof(((struct batadv_dhcp_packet *)0)->yiaddr)