b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: Update pointer to ethhdr after skb_copy
@ 2010-04-25 23:24 Sven Eckelmann
  2010-04-26  8:59 ` Marek Lindner
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Eckelmann @ 2010-04-25 23:24 UTC (permalink / raw)
  To: b.a.t.m.a.n

We must ensure that all pointer to a socket buffer are updated when we
copy a socket buffer and free our reference to the old one.
Another part of the kernel could also free its reference which maybe
removes the buffer completely. In that situation we would would feed
wrong information to the routing algorithm after the memory area is
written again by someone else.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv-kernelland/routing.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/batman-adv-kernelland/routing.c b/batman-adv-kernelland/routing.c
index d717999..53749d3 100644
--- a/batman-adv-kernelland/routing.c
+++ b/batman-adv-kernelland/routing.c
@@ -747,6 +747,7 @@ int recv_bat_packet(struct sk_buff *skb,
 		skb = skb_copy(skb, GFP_ATOMIC);
 		if (!skb)
 			return NET_RX_DROP;
+		ethhdr = (struct ethhdr *)skb_mac_header(skb);
 		kfree_skb(skb_old);
 	}
 
@@ -805,6 +806,7 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
 			if (!skb)
 				return NET_RX_DROP;
 			icmp_packet = (struct icmp_packet_rr *)skb->data;
+			ethhdr = (struct ethhdr *)skb_mac_header(skb);
 			kfree_skb(skb_old);
 		}
 
@@ -865,6 +867,7 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
 			if (!skb)
 				return NET_RX_DROP;
 			icmp_packet = (struct icmp_packet *) skb->data;
+			ethhdr = (struct ethhdr *)skb_mac_header(skb);
 			kfree_skb(skb_old);
 		}
 
@@ -960,6 +963,7 @@ int recv_icmp_packet(struct sk_buff *skb)
 			if (!skb)
 				return NET_RX_DROP;
 			icmp_packet = (struct icmp_packet_rr *)skb->data;
+			ethhdr = (struct ethhdr *)skb_mac_header(skb);
 			kfree_skb(skb_old);
 		}
 
@@ -1106,6 +1110,7 @@ int recv_unicast_packet(struct sk_buff *skb)
 		if (!skb)
 			return NET_RX_DROP;
 		unicast_packet = (struct unicast_packet *) skb->data;
+		ethhdr = (struct ethhdr *)skb_mac_header(skb);
 		kfree_skb(skb_old);
 	}
 
-- 
1.7.0.5


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

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Update pointer to ethhdr after skb_copy
  2010-04-25 23:24 [B.A.T.M.A.N.] [PATCH] batman-adv: Update pointer to ethhdr after skb_copy Sven Eckelmann
@ 2010-04-26  8:59 ` Marek Lindner
  2010-04-26  9:24   ` Sven Eckelmann
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Lindner @ 2010-04-26  8:59 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Monday 26 April 2010 07:24:13 Sven Eckelmann wrote:
> We must ensure that all pointer to a socket buffer are updated when we
> copy a socket buffer and free our reference to the old one.
> Another part of the kernel could also free its reference which maybe
> removes the buffer completely. In that situation we would would feed
> wrong information to the routing algorithm after the memory area is
> written again by someone else.

Good catch !


> @@ -960,6 +963,7 @@ int recv_icmp_packet(struct sk_buff *skb)
>  			if (!skb)
>  				return NET_RX_DROP;
>  			icmp_packet = (struct icmp_packet_rr *)skb->data;
> +			ethhdr = (struct ethhdr *)skb_mac_header(skb);
>  			kfree_skb(skb_old);
>  		}
> 
> @@ -1106,6 +1110,7 @@ int recv_unicast_packet(struct sk_buff *skb)
>  		if (!skb)
>  			return NET_RX_DROP;
>  		unicast_packet = (struct unicast_packet *) skb->data;
> +		ethhdr = (struct ethhdr *)skb_mac_header(skb);
>  		kfree_skb(skb_old);
>  	}

I was about to commit your patch when I fell over these last 2 changes. I 
can't see why we need them. What did I miss ?

Regards,
Marek


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

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Update pointer to ethhdr after skb_copy
  2010-04-26  8:59 ` Marek Lindner
@ 2010-04-26  9:24   ` Sven Eckelmann
  2010-04-26 10:27     ` Marek Lindner
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Eckelmann @ 2010-04-26  9:24 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

[-- Attachment #1: Type: Text/Plain, Size: 814 bytes --]

Marek Lindner wrote:
> > @@ -1106,6 +1110,7 @@ int recv_unicast_packet(struct sk_buff *skb)
> > 
> >  		if (!skb)
> >  		
> >  			return NET_RX_DROP;
> >  		
> >  		unicast_packet = (struct unicast_packet *) skb->data;
> > 
> > +		ethhdr = (struct ethhdr *)skb_mac_header(skb);
> > 
> >  		kfree_skb(skb_old);
> >  	
> >  	}
> 
> I was about to commit your patch when I fell over these last 2 changes. I
> can't see why we need them. What did I miss ?

They are not really needed, but just wanted to have them in for later usage 
and to have it more consistent (otherwise copy and paste easily leads to funny 
effects for some people which cannot be reproduced by the maintainers). So it 
could be removed in recv_icmp_packet and recv_unicast_packet if you prefer it.

Best regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Update pointer to ethhdr after skb_copy
  2010-04-26  9:24   ` Sven Eckelmann
@ 2010-04-26 10:27     ` Marek Lindner
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2010-04-26 10:27 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Monday 26 April 2010 17:24:13 Sven Eckelmann wrote:
> They are not really needed, but just wanted to have them in for later
>  usage  and to have it more consistent (otherwise copy and paste easily
>  leads to funny effects for some people which cannot be reproduced by the
>  maintainers). So it could be removed in recv_icmp_packet and
>  recv_unicast_packet if you prefer it.

Ok, I somehow figured that this was meant to combat copy & paste but I wanted 
to make sure.  :-)
Your patch was applied in revision 1640.

Thanks,
Marek

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

end of thread, other threads:[~2010-04-26 10:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-25 23:24 [B.A.T.M.A.N.] [PATCH] batman-adv: Update pointer to ethhdr after skb_copy Sven Eckelmann
2010-04-26  8:59 ` Marek Lindner
2010-04-26  9:24   ` Sven Eckelmann
2010-04-26 10:27     ` Marek Lindner

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