From patchwork Sun May 29 19:25:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16311 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id ACF2E81819; Sun, 29 May 2016 21:25:58 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=Zo1eZyx4; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id B6D7C81818 for ; Sun, 29 May 2016 21:25:56 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C609FD0000000000002E16.dip0.t-ipconnect.de [IPv6:2003:c5:93c6:9fd::2e16]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 280091100E7; Sun, 29 May 2016 21:25:56 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1464549956; bh=raBhMpo5bSbWz2EWiLwKycYFbc0pGIvs+amQdx1Vlg4=; h=From:To:Cc:Subject:Date:From; b=Zo1eZyx4s+VauUj/olf98RRjaOkTdvBd/raZLpZCJpeq9kATHNlGrYD38NLjEHT6J RCzSJNniWXz4vIEurpASZxP2eSaPtIsviCm40uQW2W7r7r+A0aPm1wQwcNWe0TlhqZ 9Q6pMzUBqc++qnBg52GHs+e24zZB4Da0IxtnXr38= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 29 May 2016 21:25:52 +0200 Message-Id: <1464549952-27830-1-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.8.1 Subject: [B.A.T.M.A.N.] [PATCH-maint] batman-adv: Fix ICMP RR ethernet access after skb_linearize X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" The skb_linearize may reallocate the skb. This makes the calculated pointer for ethhdr invalid. But it the pointer is used later to fill in the RR field of the batadv_icmp_packet_rr packet. Instead re-evaluate eth_hdr after the skb_linearize+skb_cow to fix the pointer and avoid the invalid read. Fixes: bb69cb678d37 ("batman-adv: generalize batman-adv icmp packet handling") Signed-off-by: Sven Eckelmann --- net/batman-adv/routing.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 0c0c30e..27e07dd 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -374,6 +374,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, if (skb_cow(skb, ETH_HLEN) < 0) goto out; + ethhdr = eth_hdr(skb); icmph = (struct batadv_icmp_header *)skb->data; icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph; if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN)