From patchwork Mon Aug 24 16:21:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18153 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 C1A8F8048A; Mon, 24 Aug 2020 18:30:49 +0200 (CEST) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 29E6D8010F for ; Mon, 24 Aug 2020 18:30:46 +0200 (CEST) Received: from kero.packetmixer.de (p200300c5970d68d0e0160e8a82c5fd76.dip0.t-ipconnect.de [IPv6:2003:c5:970d:68d0:e016:e8a:82c5:fd76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 92AA76205E; Mon, 24 Aug 2020 18:21:14 +0200 (CEST) From: Simon Wunderlich To: davem@davemloft.net Subject: [PATCH 1/3] batman-adv: Avoid uninitialized chaddr when handling DHCP Date: Mon, 24 Aug 2020 18:21:09 +0200 Message-Id: <20200824162111.29220-2-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200824162111.29220-1-sw@simonwunderlich.de> References: <20200824162111.29220-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=1598286646; 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=uDCN1bAanxSVwYKLfioX796nmmxpa6n9BAyBGA0ffgs=; b=Sn2l2lmg7hoKurMD1PQdIZHdadagvFF+HOn6OqYWmsFlRNPl1yCrzztmrXNqy9wUqW8NgC h7lSF79ce7+abOtULwL+QUZMIkhQ4CK3fEhyvurZ0md1l40olFK9ZXgSwlu9IXvgYqRGzz I7V/ZSq/enwRKhiR2ksIRYvgN3mZt30= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1598286646; a=rsa-sha256; cv=none; b=H4ItI6WGhJ2vnECQ8xhZPyl1xzKsZd9vIJGDsLLym5zLVkmzrIuR6e1d2bpYW5USk4AUFo 19X9qzqIRIfiFmDWaeGztWqpLDbIvJ4H7FUVr/jG7fxwy0pZD05aZaXt2mIbIOpGLw7S6V WsOZ2fy4dJnQdUGit63C0Nc17GaYpAA= 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 Message-ID-Hash: SQCWR3PWFOS55V7BWTWEMAY24UMOMIDX X-Message-ID-Hash: SQCWR3PWFOS55V7BWTWEMAY24UMOMIDX X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com, Antonio Quartulli X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann The gateway client code can try to optimize the delivery of DHCP packets to avoid broadcasting them through the whole mesh. But also transmissions to the client can be optimized by looking up the destination via the chaddr of the DHCP packet. But the chaddr is currently only done when chaddr is fully inside the non-paged area of the skbuff. Otherwise it will not be initialized and the unoptimized path should have been taken. But the implementation didn't handle this correctly. It didn't retrieve the correct chaddr but still tried to perform the TT lookup with this uninitialized memory. Reported-by: syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com Fixes: 6c413b1c22a2 ("batman-adv: send every DHCP packet as bat-unicast") Signed-off-by: Sven Eckelmann Acked-by: Antonio Quartulli Signed-off-by: Simon Wunderlich --- net/batman-adv/gateway_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index a18dcc686dc3..ef3f85b576c4 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -703,8 +703,10 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET; /* store the client address if the message is going to a client */ - if (ret == BATADV_DHCP_TO_CLIENT && - pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) { + if (ret == BATADV_DHCP_TO_CLIENT) { + if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) + return BATADV_DHCP_NO; + /* check if the DHCP packet carries an Ethernet DHCP */ p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET; if (*p != BATADV_DHCP_HTYPE_ETHERNET) From patchwork Mon Aug 24 16:21:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18145 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 EF594803C3; Mon, 24 Aug 2020 18:21:17 +0200 (CEST) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 5DB59803C3 for ; Mon, 24 Aug 2020 18:21:15 +0200 (CEST) Received: from kero.packetmixer.de (p200300c5970d68d0e0160e8a82c5fd76.dip0.t-ipconnect.de [IPv6:2003:c5:970d:68d0:e016:e8a:82c5:fd76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 0E7546206B; Mon, 24 Aug 2020 18:21:15 +0200 (CEST) From: Simon Wunderlich To: davem@davemloft.net Subject: [PATCH 2/3] batman-adv: Fix own OGM check in aggregated OGMs Date: Mon, 24 Aug 2020 18:21:10 +0200 Message-Id: <20200824162111.29220-3-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200824162111.29220-1-sw@simonwunderlich.de> References: <20200824162111.29220-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=1598286075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m6UpbYzzZdiAMxZ8X+QgSfswPgBEA2iWFoGd/xsGcHc=; b=jHAZTdguIvXdQFV2eyB4LkQqED64eq+lZ8R7QDvVw1bxGjCh8JCyk+HcAHK9QKe2GCGmMn rLdWp6sAXQyROogjhXI2ajATPGMW/mgOpyrGmvBNNPQ+jh1RvwIlJf2rKBVm6b0JPWkNYD 49zMnYvQWG5ueu9Mzf0t+xk6/nt2ZAc= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1598286075; a=rsa-sha256; cv=none; b=AZaIJvn8c2D0Flv2mZaYhhZcpuj1cFSdAZQgEjCQNJTo+eih1G0wgl27cpTsfAqMcWJv2K A+Tl3VcDO/uA4xZ89uz2brWJ4qGVLbwu3waWOV++xelgOPLlqx3ejjttFM4/JqIVbJsfad LKBcgvoifgu3wxTQcnTSaypRTU4Jzpw= 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 Message-ID-Hash: WROOCRBT3WECMDR2ENHSWNB5JTXRND6E X-Message-ID-Hash: WROOCRBT3WECMDR2ENHSWNB5JTXRND6E X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Linus Lüssing The own OGM check is currently misplaced and can lead to the following issues: For one thing we might receive an aggregated OGM from a neighbor node which has our own OGM in the first place. We would then not only skip our own OGM but erroneously also any other, following OGM in the aggregate. For another, we might receive an OGM aggregate which has our own OGM in a place other then the first one. Then we would wrongly not skip this OGM, leading to populating the orginator and gateway table with ourself. Fixes: 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic") Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_v_ogm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 0f8495b9eeb1..717fe657561d 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -881,6 +881,12 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset, ntohl(ogm_packet->seqno), ogm_throughput, ogm_packet->ttl, ogm_packet->version, ntohs(ogm_packet->tvlv_len)); + if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) { + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, + "Drop packet: originator packet from ourself\n"); + return; + } + /* If the throughput metric is 0, immediately drop the packet. No need * to create orig_node / neigh_node for an unusable route. */ @@ -1008,11 +1014,6 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, if (batadv_is_my_mac(bat_priv, ethhdr->h_source)) goto free_skb; - ogm_packet = (struct batadv_ogm2_packet *)skb->data; - - if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) - goto free_skb; - batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX); batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES, skb->len + ETH_HLEN); From patchwork Mon Aug 24 16:21:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18152 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 E182780408; Mon, 24 Aug 2020 18:30:48 +0200 (CEST) Received: from simonwunderlich.de (packetmixer.de [IPv6:2001:4d88:2000:24::c0de]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 2E3CF803EF for ; Mon, 24 Aug 2020 18:30:46 +0200 (CEST) Received: from kero.packetmixer.de (p200300c5970d68d0e0160e8a82c5fd76.dip0.t-ipconnect.de [IPv6:2003:c5:970d:68d0:e016:e8a:82c5:fd76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 64F0E6206D; Mon, 24 Aug 2020 18:21:15 +0200 (CEST) From: Simon Wunderlich To: davem@davemloft.net Subject: [PATCH 3/3] batman-adv: bla: use netif_rx_ni when not in interrupt context Date: Mon, 24 Aug 2020 18:21:11 +0200 Message-Id: <20200824162111.29220-4-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200824162111.29220-1-sw@simonwunderlich.de> References: <20200824162111.29220-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=1598286646; 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=pfO+5zaXvrrC0abQF7dV2Fy65Zshw6ESAN+H5PSMO2k=; b=Fi+RJOsEsGqBfDDuDJkFuLCJqXjoy8pAGI5JqWtdm8NlLsFddC4wfEMgFXfAZTUXcAvLIG 7eagKE+QYVp+OI/BVQyv0/+tyVXct02cyHr8wzQDqKezCOd2nXaK5qOTAs9may56QLkso/ 5QfwMsXVEmdvwerTiu0OyKwO84Ipji8= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1598286646; a=rsa-sha256; cv=none; b=m0XcdcescKUV2ysDjEwf0+0NZ/h4PBDQrELo//rHGwxk/tARwQOAU/8W0MST+O7t5CWkYC XHc7CjNe3F9Dr8c1HMOUsrafDo4AUMB/DhCIsW1GW+c2Zjs1qd4Ie1LySl0TrjnbosMt7b 0F+cB38McrMKlPGcHLdEYbfDtkYT6to= 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 Message-ID-Hash: PEFQ3YETO4GT5HCEW5DZN5OVIRJI6Q27 X-Message-ID-Hash: PEFQ3YETO4GT5HCEW5DZN5OVIRJI6Q27 X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Jussi Kivilinna X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Jussi Kivilinna batadv_bla_send_claim() gets called from worker thread context through batadv_bla_periodic_work(), thus netif_rx_ni needs to be used in that case. This fixes "NOHZ: local_softirq_pending 08" log messages seen when batman-adv is enabled. Fixes: 23721387c409 ("batman-adv: add basic bridge loop avoidance code") Signed-off-by: Jussi Kivilinna Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bridge_loop_avoidance.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 91a04ca373dc..8500f56cbd10 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -437,7 +437,10 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac, batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, skb->len + ETH_HLEN); - netif_rx(skb); + if (in_interrupt()) + netif_rx(skb); + else + netif_rx_ni(skb); out: if (primary_if) batadv_hardif_put(primary_if);