stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2
@ 2020-03-17 20:15 Sven Eckelmann
  2020-03-17 20:15 ` [PATCH 4.9 1/3] batman-adv: update data pointers after skb_cow() Sven Eckelmann
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sven Eckelmann @ 2020-03-17 20:15 UTC (permalink / raw)
  To: stable; +Cc: 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.

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(-)

-- 
2.20.1


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

* [PATCH 4.9 1/3] batman-adv: update data pointers after skb_cow()
  2020-03-17 20:15 [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Sven Eckelmann
@ 2020-03-17 20:15 ` Sven Eckelmann
  2020-03-17 20:15 ` [PATCH 4.9 2/3] batman-adv: Avoid probe ELP information leak Sven Eckelmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sven Eckelmann @ 2020-03-17 20:15 UTC (permalink / raw)
  To: stable; +Cc: Matthias Schiffer, Sven Eckelmann

From: Matthias Schiffer <mschiffer@universe-factory.net>

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")
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/routing.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index f9ffb1825f6d..19059ae26e51 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -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);
 
-- 
2.20.1


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

* [PATCH 4.9 2/3] batman-adv: Avoid probe ELP information leak
  2020-03-17 20:15 [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Sven Eckelmann
  2020-03-17 20:15 ` [PATCH 4.9 1/3] batman-adv: update data pointers after skb_cow() Sven Eckelmann
@ 2020-03-17 20:15 ` Sven Eckelmann
  2020-03-17 20:15 ` [PATCH 4.9 3/3] batman-adv: Use explicit tvlv padding for ELP packets Sven Eckelmann
  2020-03-18 18:01 ` [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Greg KH
  3 siblings, 0 replies; 5+ messages in thread
From: Sven Eckelmann @ 2020-03-17 20:15 UTC (permalink / raw)
  To: stable; +Cc: Sven Eckelmann, Antonio Quartulli, Simon Wunderlich

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")
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/bat_v_elp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 3ff0dc83d04b..11e1a28ff526 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -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",
-- 
2.20.1


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

* [PATCH 4.9 3/3] batman-adv: Use explicit tvlv padding for ELP packets
  2020-03-17 20:15 [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Sven Eckelmann
  2020-03-17 20:15 ` [PATCH 4.9 1/3] batman-adv: update data pointers after skb_cow() Sven Eckelmann
  2020-03-17 20:15 ` [PATCH 4.9 2/3] batman-adv: Avoid probe ELP information leak Sven Eckelmann
@ 2020-03-17 20:15 ` Sven Eckelmann
  2020-03-18 18:01 ` [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Greg KH
  3 siblings, 0 replies; 5+ messages in thread
From: Sven Eckelmann @ 2020-03-17 20:15 UTC (permalink / raw)
  To: stable; +Cc: Sven Eckelmann, Linus Lüssing, Simon Wunderlich

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")
Reported-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_elp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 11e1a28ff526..62df763b2aae 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -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;
-- 
2.20.1


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

* Re: [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2
  2020-03-17 20:15 [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Sven Eckelmann
                   ` (2 preceding siblings ...)
  2020-03-17 20:15 ` [PATCH 4.9 3/3] batman-adv: Use explicit tvlv padding for ELP packets Sven Eckelmann
@ 2020-03-18 18:01 ` Greg KH
  3 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2020-03-18 18:01 UTC (permalink / raw)
  To: Sven Eckelmann; +Cc: stable

On Tue, Mar 17, 2020 at 09:15:37PM +0100, Sven Eckelmann wrote:
> 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

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

end of thread, other threads:[~2020-03-18 18:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-17 20:15 [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Sven Eckelmann
2020-03-17 20:15 ` [PATCH 4.9 1/3] batman-adv: update data pointers after skb_cow() Sven Eckelmann
2020-03-17 20:15 ` [PATCH 4.9 2/3] batman-adv: Avoid probe ELP information leak Sven Eckelmann
2020-03-17 20:15 ` [PATCH 4.9 3/3] batman-adv: Use explicit tvlv padding for ELP packets Sven Eckelmann
2020-03-18 18:01 ` [PATCH 4.9 0/3] batman-adv: Pending fixes; part 2 Greg KH

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).