stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: stable@vger.kernel.org
Cc: Matthias Schiffer <mschiffer@universe-factory.net>,
	Sven Eckelmann <sven@narfation.org>,
	Simon Wunderlich <sw@simonwunderlich.de>
Subject: [PATCH 4.14 06/15] batman-adv: update data pointers after skb_cow()
Date: Mon, 16 Mar 2020 23:30:23 +0100	[thread overview]
Message-ID: <20200316223032.6236-7-sven@narfation.org> (raw)
In-Reply-To: <20200316223032.6236-1-sven@narfation.org>

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: 7cdcf6dddc42 ("batman-adv: add UNICAST_4ADDR packet type")
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/routing.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index cd82cff716c7..f59aac06733e 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -950,14 +950,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
 	struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL;
 	int check, hdr_size = sizeof(*unicast_packet);
 	enum batadv_subtype subtype;
-	struct ethhdr *ethhdr;
 	int ret = NET_RX_DROP;
 	bool is4addr, is_gw;
 
 	unicast_packet = (struct batadv_unicast_packet *)skb->data;
-	unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
-	ethhdr = eth_hdr(skb);
-
 	is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
 	/* the caller function should have already pulled 2 bytes */
 	if (is4addr)
@@ -977,12 +973,14 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
 	if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
 		goto free_skb;
 
+	unicast_packet = (struct batadv_unicast_packet *)skb->data;
+
 	/* packet for me */
 	if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
 		/* If this is a unicast packet from another backgone gw,
 		 * drop it.
 		 */
-		orig_addr_gw = ethhdr->h_source;
+		orig_addr_gw = eth_hdr(skb)->h_source;
 		orig_node_gw = batadv_orig_hash_find(bat_priv, orig_addr_gw);
 		if (orig_node_gw) {
 			is_gw = batadv_bla_is_backbone_gw(skb, orig_node_gw,
@@ -997,6 +995,8 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
 		}
 
 		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


  parent reply	other threads:[~2020-03-16 22:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16 22:30 [PATCH 4.14 00/15] batman-adv: Pending fixes Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 01/15] batman-adv: Avoid spurious warnings from bat_v neigh_cmp implementation Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 02/15] batman-adv: Always initialize fragment header priority Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 03/15] batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 04/15] batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 05/15] batman-adv: Fix internal interface indices types Sven Eckelmann
2020-03-16 22:30 ` Sven Eckelmann [this message]
2020-03-16 22:30 ` [PATCH 4.14 07/15] batman-adv: Avoid race in TT TVLV allocator helper Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 08/15] batman-adv: Fix TT sync flags for intermediate TT responses Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 09/15] batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 10/15] batman-adv: Fix debugfs path for renamed hardif Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 11/15] batman-adv: Fix debugfs path for renamed softif Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 12/15] batman-adv: Fix duplicated OGMs on NETDEV_UP Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 13/15] batman-adv: Avoid free/alloc race when handling OGM2 buffer Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 14/15] batman-adv: Avoid free/alloc race when handling OGM buffer Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 15/15] batman-adv: Don't schedule OGM for disabled interface Sven Eckelmann
2020-03-17 10:14 ` [PATCH 4.14 00/15] batman-adv: Pending fixes Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200316223032.6236-7-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=mschiffer@universe-factory.net \
    --cc=stable@vger.kernel.org \
    --cc=sw@simonwunderlich.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).