batman-adv: Merge bugfixes from 2020.3 604/head
authorSven Eckelmann <sven@narfation.org>
Tue, 25 Aug 2020 18:36:05 +0000 (20:36 +0200)
committerSven Eckelmann <sven@narfation.org>
Tue, 25 Aug 2020 18:38:30 +0000 (20:38 +0200)
* Avoid uninitialized chaddr when handling DHCP
* Fix own OGM check in aggregated OGMs
* bla: use netif_rx_ni when not in interrupt context

Signed-off-by: Sven Eckelmann <sven@narfation.org>
batman-adv/Makefile
batman-adv/patches/0046-batman-adv-Avoid-uninitialized-chaddr-when-handling-.patch [new file with mode: 0644]
batman-adv/patches/0047-batman-adv-Fix-own-OGM-check-in-aggregated-OGMs.patch [new file with mode: 0644]
batman-adv/patches/0048-batman-adv-bla-use-netif_rx_ni-when-not-in-interrupt.patch [new file with mode: 0644]

index 75bf5327c73a388f136b713c107eae0ec82771b8..b4f7768464127bb5f1bc7ed9416d54747fdaa0be 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=batman-adv
 
 PKG_VERSION:=2018.1
-PKG_RELEASE:=11
+PKG_RELEASE:=12
 PKG_HASH:=b866b28dbbe5c9238abbdf5abbc30fc526dea56898ce4c1bd76d5c017843048b
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
diff --git a/batman-adv/patches/0046-batman-adv-Avoid-uninitialized-chaddr-when-handling-.patch b/batman-adv/patches/0046-batman-adv-Avoid-uninitialized-chaddr-when-handling-.patch
new file mode 100644 (file)
index 0000000..43a4150
--- /dev/null
@@ -0,0 +1,42 @@
+From: Sven Eckelmann <sven@narfation.org>
+Date: Wed, 22 Jul 2020 20:49:23 +0200
+Subject: batman-adv: Avoid uninitialized chaddr when handling DHCP
+
+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: 2d5b555644b2 ("batman-adv: send every DHCP packet as bat-unicast")
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+Acked-by: Antonio Quartulli <a@unstable.cc>
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+
+Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/fcdf008ffd749246632d1f9423163af5dc3f8c7f
+
+diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
+index 140c61a3f1ecfec4fe23c5ddca19e18e2e86fd56..0c59fefc137196899f97e0fa7882cf55ceebe34c 100644
+--- a/net/batman-adv/gateway_client.c
++++ b/net/batman-adv/gateway_client.c
+@@ -714,8 +714,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)
diff --git a/batman-adv/patches/0047-batman-adv-Fix-own-OGM-check-in-aggregated-OGMs.patch b/batman-adv/patches/0047-batman-adv-Fix-own-OGM-check-in-aggregated-OGMs.patch
new file mode 100644 (file)
index 0000000..1b6f152
--- /dev/null
@@ -0,0 +1,59 @@
+From: Linus Lüssing <linus.luessing@c0d3.blue>
+Date: Fri, 31 Jul 2020 00:22:55 +0200
+Subject: batman-adv: Fix own OGM check in aggregated OGMs
+
+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.
+
+The latter seems to not only be a cosmetic issue, but there were reports
+that this causes issues with various subsystems of batman-adv, too. For
+instance there were reports about issues with DAT and either disabling
+DAT or aggregation seemed to solve it.
+
+Fixing these issues by applying the own OGM check not on the first OGM
+in an aggregate but for each OGM in an aggregate instead.
+
+Fixes: 667996ebeab ("batman-adv: OGMv2 - implement originators logic")
+Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+
+Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d41cc7cb62c184b2fb8ab97fda45815918200001
+
+diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
+index 0458de53cb64b2da51de492ffa27f33068351cc8..04a620fd13014463ed0c7c047f3a61a05d862e39 100644
+--- a/net/batman-adv/bat_v_ogm.c
++++ b/net/batman-adv/bat_v_ogm.c
+@@ -716,6 +716,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.
+        */
+@@ -843,11 +849,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);
diff --git a/batman-adv/patches/0048-batman-adv-bla-use-netif_rx_ni-when-not-in-interrupt.patch b/batman-adv/patches/0048-batman-adv-bla-use-netif_rx_ni-when-not-in-interrupt.patch
new file mode 100644 (file)
index 0000000..2705afa
--- /dev/null
@@ -0,0 +1,31 @@
+From: Jussi Kivilinna <jussi.kivilinna@haltian.com>
+Date: Tue, 18 Aug 2020 17:46:10 +0300
+Subject: batman-adv: bla: use netif_rx_ni when not in interrupt context
+
+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: a9ce0dc43e2c ("batman-adv: add basic bridge loop avoidance code")
+Signed-off-by: Jussi Kivilinna <jussi.kivilinna@haltian.com>
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+
+Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/3747f81a1380b65740fc52fc71c7a3af4c6e49de
+
+diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
+index 0842080a71f4ac89b3fbebc4b95c6c27d1cc4254..ed8259ff0dc7ba129825a369a757b37cc62ce829 100644
+--- a/net/batman-adv/bridge_loop_avoidance.c
++++ b/net/batman-adv/bridge_loop_avoidance.c
+@@ -450,7 +450,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);