lkml.org 
[lkml]   [2016]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] net: ip, diag -- Add diag interface for raw sockets
On Tue, Sep 27, 2016 at 08:39:59AM -0700, Eric Dumazet wrote:
...
> > + }
> > + if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
> > + sk = NULL;
>
> Minor detail, but note that raw sockets do not use rcu (yet)
>
> Since you have read_lock(&hashinfo->lock), no writer can suddenly change
> sk->sk_refcnt to a zero value.
>
> Therefore, a mere "sock_hold(sk)" should be enough to get a reference on
> the socket.
>
> Using atomic_inc_not_zero() also works, but might distract/confuse the
> next guy trying to understand this code ;)

Oh, I see. Thanks Eric! I'll update the patch (hopefully tonight)
and send it out (need to finish urgent task atm).

\
 
 \ /
  Last update: 2016-09-27 17:46    [W:0.030 / U:1.492 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site