lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 24 Jun 2015 17:26:01 +0200
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	ratheesh kannoth <ratheesh.ksz@...il.com>
Cc:	netdev <netdev@...r.kernel.org>,
	linux-newbie <linux-newbie@...r.kernel.org>
Subject: Re: sock_hold and sock_put

On Wed, 2015-06-24 at 19:44 +0530, ratheesh kannoth wrote:
> On Wed, Jun 24, 2015 at 6:16 PM, Eric Dumazet <eric.dumazet@...il.com> wrote:
> > You misunderstood the comment.
> >
> > Comment only stated that sock_hold() must be used in contexts where
> > caller owns a reference (and will eventually release it later with
> > sock_put().
> >
> > There is nothing about having a lock here.
> 
> Thanks. I think, i did not put the question right.
> 
> I understood the comment perfectly. Suppose i need to use the
> sock_hold in some callbacks ( say netdev_notifier chain callback)
> function. How can i gurantee race won't happen at the point where i
> call sock_hold().
>  If i put the question  in another way - say kernel is doing a
> sock_put() on a socket, and at the same time  the   netdev_callback
> function( that i implemented ) is called on another core ( in smp
> machine ). and the  callback is  holding (sock_hold()) on the same
> sock.

You can not possibly use sock_hold() from the callback, unless you
already took a reference on the socket _before_ callback was called, to
make sure socket would not disappear.

Its hard to understand what you try to do here.

If you worry because socket would disappear when "kernel is doing a
sock_put()", then it means you did not take the needed extra reference
to make sure callback would access a valid socket.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ