From: "Linus Lüssing" <linus.luessing@web.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH next 2/2] batman-adv: fix potential kernel paging error for unicast transmissions
Date: Sat, 27 Jul 2013 03:24:45 +0200 [thread overview]
Message-ID: <1374888285-20775-2-git-send-email-linus.luessing@web.de> (raw)
In-Reply-To: <1374888285-20775-1-git-send-email-linus.luessing@web.de>
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 <linus.luessing@web.de>
---
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;
--
1.7.10.4
next prev parent reply other threads:[~2013-07-27 1:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-27 1:24 [B.A.T.M.A.N.] [PATCH next 1/2] batman-adv: check return type of unicast packet preparations Linus Lüssing
2013-07-27 1:24 ` Linus Lüssing [this message]
2013-07-28 20:17 ` [B.A.T.M.A.N.] [PATCH next 2/2] batman-adv: fix potential kernel paging error for unicast transmissions Antonio Quartulli
2013-08-02 4:05 ` Marek Lindner
2013-08-02 7:18 ` Antonio Quartulli
2013-08-02 8:04 ` Linus Lüssing
2013-07-28 20:14 ` [B.A.T.M.A.N.] [PATCH next 1/2] batman-adv: check return type of unicast packet preparations Antonio Quartulli
2013-08-02 4:02 ` Marek Lindner
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=1374888285-20775-2-git-send-email-linus.luessing@web.de \
--to=linus.luessing@web.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/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