From patchwork Sat Jul 27 01:24:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 3215 Return-Path: Received: from mout.web.de (mout.web.de [212.227.17.12]) by open-mesh.org (Postfix) with ESMTP id B179C6021BD for ; Sat, 27 Jul 2013 03:25:04 +0200 (CEST) Received: from localhost ([46.246.33.183]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0LbZpT-1UMNgj0pvH-00lDvR for ; Sat, 27 Jul 2013 03:25:04 +0200 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 27 Jul 2013 03:24:45 +0200 Message-Id: <1374888285-20775-2-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1374888285-20775-1-git-send-email-linus.luessing@web.de> References: <1374888285-20775-1-git-send-email-linus.luessing@web.de> MIME-Version: 1.0 X-Provags-ID: V03:K0:X+FYrnYnR6o7JFlKfwBLw+fxKQRY3Vmw/848usAH/7k9jn3YfxC uCoiqaURNNyHL/dOIVnHj0SOlLGsf8eRJUhnaEu2ioxLx1CcV6uwBaxWStjFHO0rSo5jV/4 xg1IAfnPXJPp48ccRlurpVQaGmAEeCgX0/uT+dO5ulF1j3xuP7aI2+FXE8VrhOM+bTjAtwA 2Bm6+71beJkCJjSrUglhw== Subject: [B.A.T.M.A.N.] [PATCH next 2/2] batman-adv: fix potential kernel paging error for unicast transmissions X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jul 2013 01:25:04 -0000 batadv_send_skb_prepare_unicast(_4addr) might reallocate the skb's data. If it does then our ethhdr pointer is not valid anymore in batadv_send_skb_unicast(), resulting in a kernel paging error. This patch fixes this issue by storing the few bytes we are interested in on the stack before modifying the skb. Signed-off-by: Linus Lüssing Acked-by: Antonio Quartulli --- unicast.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unicast.c b/unicast.c index 4c5a1aa..c636fd5 100644 --- a/unicast.c +++ b/unicast.c @@ -395,6 +395,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv, struct sk_buff *skb, int packet_type, int packet_subtype) { + uint8_t dest[ETH_ALEN]; struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct batadv_unicast_packet *unicast_packet; struct batadv_orig_node *orig_node; @@ -426,6 +427,8 @@ find_router: if (!neigh_node) goto out; + memcpy(dest, ethhdr->h_dest, sizeof(dest)); + switch (packet_type) { case BATADV_UNICAST: if (!batadv_unicast_prepare_skb(skb, orig_node)) @@ -450,7 +453,7 @@ find_router: * try to reroute it because the ttvn contained in the header is less * than the current one */ - if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest)) + if (batadv_tt_global_client_is_roaming(bat_priv, dest)) unicast_packet->ttvn = unicast_packet->ttvn - 1; dev_mtu = neigh_node->if_incoming->net_dev->mtu;