Skip to contentSkip to conversation

batman-adv: Pending fixes; part 2

PATCH In review Sven Eckelmann 2 participants 5 messages Mar 17, 2020 – Mar 18, 2020 Stable branch

lore
Share & tools
lore
#0 lore raw

cover batman-adv: Pending fixes; part 2

Hi,

I've already send a couple of missing patches for stable linux-4.9.y. But I've noticed that there were some other ones which I skipped but which I now saw while checking for missing patches in linux-4.4.y.

Kind regards,
Sven

Matthias Schiffer (1):
batman-adv: update data pointers after skb_cow()

Sven Eckelmann (2):
batman-adv: Avoid probe ELP information leak
batman-adv: Use explicit tvlv padding for ELP packets

 net/batman-adv/bat_v_elp.c | 12 ++++++++----
 net/batman-adv/routing.c   |  5 ++++-
 2 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 batman-adv: update data pointers after skb_cow()

From: Matthias Schiffer <[email protected]>

commit bc44b78157f621ff2a2618fe287a827bcb094ac4 upstream.

batadv_check_unicast_ttvn() calls skb_cow(), so pointers into the SKB data must be (re)set after calling it. The ethhdr variable is dropped altogether.

Fixes 78fc6bbe0aca ("batman-adv: add UNICAST_4ADDR packet type")
---
 net/batman-adv/routing.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/batman-adv/routing.c +4 -1
index f9ffb1825f6d..19059ae26e51 100644
@@ -930,7 +930,6 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
 	bool is4addr;
 
 	unicast_packet = (struct batadv_unicast_packet *)skb->data;
-	unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
 
 	is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
 	/* the caller function should have already pulled 2 bytes */
@@ -951,9 +950,13 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
 	if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
 		return NET_RX_DROP;
 
+	unicast_packet = (struct batadv_unicast_packet *)skb->data;
+
 	/* packet for me */
 	if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
 		if (is4addr) {
+			unicast_4addr_packet =
+				(struct batadv_unicast_4addr_packet *)skb->data;
 			subtype = unicast_4addr_packet->subtype;
 			batadv_dat_inc_counter(bat_priv, subtype);
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/3 batman-adv: Avoid probe ELP information leak

In reply to Sven Eckelmann

commit 88d0895d0ea9d4431507d576c963f2ff9918144d upstream.

The probe ELPs for WiFi interfaces are expanded to contain at least BATADV_ELP_MIN_PROBE_SIZE bytes. This is usually a lot more than the number of bytes which the template ELP packet requires.

These extra padding bytes were not initialized and thus could contain data which were previously stored at the same location. It is therefore required to set it to some predefined or random values to avoid leaking private information from the system transmitting these kind of packets.

Fixes e4623c913508 ("batman-adv: Avoid probe ELP information leak")
---
 net/batman-adv/bat_v_elp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/batman-adv/bat_v_elp.c +3 -1
index 3ff0dc83d04b..11e1a28ff526 100644
@@ -191,6 +191,7 @@ batadv_v_elp_wifi_neigh_probe(struct batadv_hardif_neigh_node *neigh)
 	struct sk_buff *skb;
 	int probe_len, i;
 	int elp_skb_len;
+	void *tmp;
 
 	/* this probing routine is for Wifi neighbours only */
 	if (!batadv_is_wifi_netdev(hard_iface->net_dev))
@@ -222,7 +223,8 @@ batadv_v_elp_wifi_neigh_probe(struct batadv_hardif_neigh_node *neigh)
 		 * the packet to be exactly of that size to make the link
 		 * throughput estimation effective.
 		 */
-		skb_put(skb, probe_len - hard_iface->bat_v.elp_skb->len);
+		tmp = skb_put(skb, probe_len - hard_iface->bat_v.elp_skb->len);
+		memset(tmp, 0, probe_len - hard_iface->bat_v.elp_skb->len);
 
 		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
 			   "Sending unicast (probe) ELP packet on interface %s to %pM\n",
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/3 batman-adv: Use explicit tvlv padding for ELP packets

In reply to Sven Eckelmann

commit f4156f9656feac21f4de712fac94fae964c5d402 upstream.

The announcement messages of batman-adv COMPAT_VERSION 15 have the possibility to announce additional information via a dynamic TVLV part. This part is optional for the ELP packets and currently not parsed by the Linux implementation. Still out-of-tree versions are using it to transport things like neighbor hashes to optimize the rebroadcast behavior.

Since the ELP broadcast packets are smaller than the minimal ethernet packet, it often has to be padded. This is often done (as specified in RFC894) with octets of zero and thus work perfectly fine with the TVLV part (making it a zero length and thus empty). But not all ethernet compatible hardware seems to follow this advice. To avoid ambiguous situations when parsing the TVLV header, just force the 4 bytes (TVLV length + padding) after the required ELP header to zero.

Fixes d6f94d91f766 ("batman-adv: ELP - adding basic infrastructure")
---
 net/batman-adv/bat_v_elp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/batman-adv/bat_v_elp.c +5 -3
index 11e1a28ff526..62df763b2aae 100644
@@ -335,21 +335,23 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
  */
 int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
 {
+	static const size_t tvlv_padding = sizeof(__be32);
 	struct batadv_elp_packet *elp_packet;
 	unsigned char *elp_buff;
 	u32 random_seqno;
 	size_t size;
 	int res = -ENOMEM;
 
-	size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN;
+	size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN + tvlv_padding;
 	hard_iface->bat_v.elp_skb = dev_alloc_skb(size);
 	if (!hard_iface->bat_v.elp_skb)
 		goto out;
 
 	skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN);
-	elp_buff = skb_put(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
+	elp_buff = skb_put(hard_iface->bat_v.elp_skb,
+			   BATADV_ELP_HLEN + tvlv_padding);
 	elp_packet = (struct batadv_elp_packet *)elp_buff;
-	memset(elp_packet, 0, BATADV_ELP_HLEN);
+	memset(elp_packet, 0, BATADV_ELP_HLEN + tvlv_padding);
 
 	elp_packet->packet_type = BATADV_ELP;
 	elp_packet->version = BATADV_COMPAT_VERSION;
Signature · 1 line
2.20.1
#4 lore raw
In reply to Sven Eckelmann
Quoted 5 lines · Sven Eckelmann

Hi,

I've already send a couple of missing patches for stable linux-4.9.y. But I've noticed that there were some other ones which I skipped but which I now saw while checking for missing patches in linux-4.4.y.

All now queued up, thanks!

greg k-h