Re: smp_rmb() in consume_skb

2012-10-11 Thread Mulyadi Santosa
Hi :)

On Thu, Oct 11, 2012 at 7:20 PM, Kshemendra KP  wrote:
>  void consume_skb(struct sk_buff * skb)
>  {
>  if (unlikely(!skb))
>   return;
>  if (likley (atomic_read (&skb->users) == 1))
>   smp_rmb()
> > need for this
> barrier
>
> ..
>   __kfree_skb();
>  }

In most cases, read barrier is needed to make sure all
cores/processors see the latest data updates

Specificly, in this case, i think it is done to prevent memory free
race. Which..if not well prevented, could lead to double free. And
that's bad.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


smp_rmb() in consume_skb

2012-10-11 Thread Kshemendra KP
Hi,

When I was looking into consume_skb() routine (net/core/skbuff.c),
there is smp_rmb() read barrier is present.
It is not clear why this is needed here.  Basically this routine frees
sk_buff if only one user reference is theere

 void consume_skb(struct sk_buff * skb)
 {
 if (unlikely(!skb))
  return;
 if (likley (atomic_read (&skb->users) == 1))
  smp_rmb()
 > need for this
barrier

..
  __kfree_skb();
 }


Regards

Kshemendra
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies