netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] pull request for net: batman-adv 2020-08-24
@ 2020-08-24 16:21 Simon Wunderlich
  2020-08-24 16:21 ` [PATCH 1/3] batman-adv: Avoid uninitialized chaddr when handling DHCP Simon Wunderlich
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Simon Wunderlich @ 2020-08-24 16:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Simon Wunderlich

Hi David,

here are some bugfixes which we would like to have integrated into net.

Please pull or let me know of any problem!

Thank you,
      Simon

The following changes since commit 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5:

  Linux 5.9-rc1 (2020-08-16 13:04:57 -0700)

are available in the Git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-net-for-davem-20200824

for you to fetch changes up to 279e89b2281af3b1a9f04906e157992c19c9f163:

  batman-adv: bla: use netif_rx_ni when not in interrupt context (2020-08-18 19:40:03 +0200)

----------------------------------------------------------------
Here are some batman-adv bugfixes:

 - Avoid uninitialized memory access when handling DHCP, by Sven Eckelmann

 - Fix check for own OGM in OGM receive handler, by Linus Luessing

 - Fix netif_rx access for non-interrupt context in BLA, by Jussi Kivilinna

----------------------------------------------------------------
Jussi Kivilinna (1):
      batman-adv: bla: use netif_rx_ni when not in interrupt context

Linus Lüssing (1):
      batman-adv: Fix own OGM check in aggregated OGMs

Sven Eckelmann (1):
      batman-adv: Avoid uninitialized chaddr when handling DHCP

 net/batman-adv/bat_v_ogm.c             | 11 ++++++-----
 net/batman-adv/bridge_loop_avoidance.c |  5 ++++-
 net/batman-adv/gateway_client.c        |  6 ++++--
 3 files changed, 14 insertions(+), 8 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] batman-adv: Avoid uninitialized chaddr when handling DHCP
  2020-08-24 16:21 [PATCH 0/3] pull request for net: batman-adv 2020-08-24 Simon Wunderlich
@ 2020-08-24 16:21 ` Simon Wunderlich
  2020-08-24 16:21 ` [PATCH 2/3] batman-adv: Fix own OGM check in aggregated OGMs Simon Wunderlich
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Simon Wunderlich @ 2020-08-24 16:21 UTC (permalink / raw)
  To: davem
  Cc: netdev, b.a.t.m.a.n, Sven Eckelmann, syzbot+ab16e463b903f5a37036,
	Antonio Quartulli, Simon Wunderlich

From: Sven Eckelmann <sven@narfation.org>

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 <sven@narfation.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 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)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] batman-adv: Fix own OGM check in aggregated OGMs
  2020-08-24 16:21 [PATCH 0/3] pull request for net: batman-adv 2020-08-24 Simon Wunderlich
  2020-08-24 16:21 ` [PATCH 1/3] batman-adv: Avoid uninitialized chaddr when handling DHCP Simon Wunderlich
@ 2020-08-24 16:21 ` Simon Wunderlich
  2020-08-24 16:21 ` [PATCH 3/3] batman-adv: bla: use netif_rx_ni when not in interrupt context Simon Wunderlich
  2020-08-25  1:17 ` [PATCH 0/3] pull request for net: batman-adv 2020-08-24 David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Simon Wunderlich @ 2020-08-24 16:21 UTC (permalink / raw)
  To: davem
  Cc: netdev, b.a.t.m.a.n, Linus Lüssing, Sven Eckelmann,
	Simon Wunderlich

From: Linus Lüssing <linus.luessing@c0d3.blue>

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 <linus.luessing@c0d3.blue>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] batman-adv: bla: use netif_rx_ni when not in interrupt context
  2020-08-24 16:21 [PATCH 0/3] pull request for net: batman-adv 2020-08-24 Simon Wunderlich
  2020-08-24 16:21 ` [PATCH 1/3] batman-adv: Avoid uninitialized chaddr when handling DHCP Simon Wunderlich
  2020-08-24 16:21 ` [PATCH 2/3] batman-adv: Fix own OGM check in aggregated OGMs Simon Wunderlich
@ 2020-08-24 16:21 ` Simon Wunderlich
  2020-08-25  1:17 ` [PATCH 0/3] pull request for net: batman-adv 2020-08-24 David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Simon Wunderlich @ 2020-08-24 16:21 UTC (permalink / raw)
  To: davem
  Cc: netdev, b.a.t.m.a.n, Jussi Kivilinna, Sven Eckelmann, Simon Wunderlich

From: Jussi Kivilinna <jussi.kivilinna@haltian.com>

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 <jussi.kivilinna@haltian.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] pull request for net: batman-adv 2020-08-24
  2020-08-24 16:21 [PATCH 0/3] pull request for net: batman-adv 2020-08-24 Simon Wunderlich
                   ` (2 preceding siblings ...)
  2020-08-24 16:21 ` [PATCH 3/3] batman-adv: bla: use netif_rx_ni when not in interrupt context Simon Wunderlich
@ 2020-08-25  1:17 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-08-25  1:17 UTC (permalink / raw)
  To: sw; +Cc: netdev, b.a.t.m.a.n

From: Simon Wunderlich <sw@simonwunderlich.de>
Date: Mon, 24 Aug 2020 18:21:08 +0200

> here are some bugfixes which we would like to have integrated into net.
> 
> Please pull or let me know of any problem!

Pulled, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-25  1:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24 16:21 [PATCH 0/3] pull request for net: batman-adv 2020-08-24 Simon Wunderlich
2020-08-24 16:21 ` [PATCH 1/3] batman-adv: Avoid uninitialized chaddr when handling DHCP Simon Wunderlich
2020-08-24 16:21 ` [PATCH 2/3] batman-adv: Fix own OGM check in aggregated OGMs Simon Wunderlich
2020-08-24 16:21 ` [PATCH 3/3] batman-adv: bla: use netif_rx_ni when not in interrupt context Simon Wunderlich
2020-08-25  1:17 ` [PATCH 0/3] pull request for net: batman-adv 2020-08-24 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).