netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: sk_buff: memset(skb,0) after alloc in skb_clone
@ 2013-09-10  4:48 Govindarajulu Varadarajan
  2013-09-10 12:40 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Govindarajulu Varadarajan @ 2013-09-10  4:48 UTC (permalink / raw)
  To: davem, netdev; +Cc: Govindarajulu Varadarajan

The following patch memset the skb to 0 after alloc. We do this in
__alloc_skb_head, __alloc_skb, build_skb. We are missing this in
skb_clone.

The following call to __skb_clone in skb_clone does not copy all the
members of sk_buff. If we donot clear the skb to 0, we will have some
uninitialized members in new skb.

Signed-off-by: Govindarajulu Varadarajan <govindarajulu90@gmail.com>
---
 net/core/skbuff.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d81cff1..fc78f66 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -891,6 +891,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
 		n = kmem_cache_alloc(skbuff_head_cache, gfp_mask);
 		if (!n)
 			return NULL;
+		memset(n, 0, offsetof(struct sk_buff, tail));
 
 		kmemcheck_annotate_bitfield(n, flags1);
 		kmemcheck_annotate_bitfield(n, flags2);
-- 
1.8.4

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

* Re: [PATCH net-next] net: sk_buff: memset(skb,0) after alloc in skb_clone
@ 2013-09-10  6:33 Erik Hugne
  0 siblings, 0 replies; 4+ messages in thread
From: Erik Hugne @ 2013-09-10  6:33 UTC (permalink / raw)
  To: govindarajalu90; +Cc: netdev

Dont think this is necessary. Use GFP_ZERO mask in the skb_clone() call instead.

//E

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

* Re: [PATCH net-next] net: sk_buff: memset(skb,0) after alloc in skb_clone
  2013-09-10  4:48 [PATCH net-next] net: sk_buff: memset(skb,0) after alloc in skb_clone Govindarajulu Varadarajan
@ 2013-09-10 12:40 ` Eric Dumazet
  2013-09-12  6:21   ` Govindarajulu Varadarajan
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2013-09-10 12:40 UTC (permalink / raw)
  To: Govindarajulu Varadarajan; +Cc: davem, netdev

On Tue, 2013-09-10 at 10:18 +0530, Govindarajulu Varadarajan wrote:
> The following patch memset the skb to 0 after alloc. We do this in
> __alloc_skb_head, __alloc_skb, build_skb. We are missing this in
> skb_clone.
> 
> The following call to __skb_clone in skb_clone does not copy all the
> members of sk_buff. If we donot clear the skb to 0, we will have some
> uninitialized members in new skb.

Which ones exactly ?

I would rather make sure all fields are properly copied.

Your patch is incomplete, because it doesn't handle the fast clone case.

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

* Re: [PATCH net-next] net: sk_buff: memset(skb,0) after alloc in skb_clone
  2013-09-10 12:40 ` Eric Dumazet
@ 2013-09-12  6:21   ` Govindarajulu Varadarajan
  0 siblings, 0 replies; 4+ messages in thread
From: Govindarajulu Varadarajan @ 2013-09-12  6:21 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Govindarajulu Varadarajan, davem, netdev



On Tue, 10 Sep 2013, Eric Dumazet wrote:

> On Tue, 2013-09-10 at 10:18 +0530, Govindarajulu Varadarajan wrote:
>> The following patch memset the skb to 0 after alloc. We do this in
>> __alloc_skb_head, __alloc_skb, build_skb. We are missing this in
>> skb_clone.
>>
>> The following call to __skb_clone in skb_clone does not copy all the
>> members of sk_buff. If we donot clear the skb to 0, we will have some
>> uninitialized members in new skb.
>
> Which ones exactly ?
>
> I would rather make sure all fields are properly copied.
>
> Your patch is incomplete, because it doesn't handle the fast clone case.

Sorry, my bad. Didnt check the __copy_skb_header completely.

thanks
//govind

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

end of thread, other threads:[~2013-09-12  6:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-10  4:48 [PATCH net-next] net: sk_buff: memset(skb,0) after alloc in skb_clone Govindarajulu Varadarajan
2013-09-10 12:40 ` Eric Dumazet
2013-09-12  6:21   ` Govindarajulu Varadarajan
  -- strict thread matches above, loose matches on Subject: below --
2013-09-10  6:33 Erik Hugne

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