Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-25 Thread Tejun Heo
Hello, Herbert. On Fri, Sep 25, 2015 at 11:39:57AM +0800, Herbert Xu wrote: > +static inline bool netlink_bound(struct netlink_sock *nlk) > +{ > + bool bound = READ_ONCE(nlk->bound); > + > + /* Ensure nlk is hashed and visible. */ > + if (bound) > + smp_rmb(); > + > +

Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-25 Thread Tejun Heo
Hello, Herbert. On Fri, Sep 25, 2015 at 09:43:27AM +0800, Herbert Xu wrote: > Well had you said this in the first place I would've fixed it a > long time ago. There aren't any in-kernel users right now and > even if there were they'd have to do a connect/bind/sendmsg on > the same socket in two

Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-25 Thread Tejun Heo
Hello, Herbert. On Fri, Sep 25, 2015 at 09:43:27AM +0800, Herbert Xu wrote: > Well had you said this in the first place I would've fixed it a > long time ago. There aren't any in-kernel users right now and > even if there were they'd have to do a connect/bind/sendmsg on > the same socket in two

Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-25 Thread Tejun Heo
Hello, Herbert. On Fri, Sep 25, 2015 at 11:39:57AM +0800, Herbert Xu wrote: > +static inline bool netlink_bound(struct netlink_sock *nlk) > +{ > + bool bound = READ_ONCE(nlk->bound); > + > + /* Ensure nlk is hashed and visible. */ > + if (bound) > + smp_rmb(); > + > +

Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-24 Thread Herbert Xu
On Thu, Sep 24, 2015 at 08:24:56PM -0700, Linus Torvalds wrote: > > The above looks very suspicious. You're right Linus. I've added the READ_ONCE there. The reason I kept the conditional is because the helper is always called in a context where the result is used as part of an if statement.

Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-24 Thread Linus Torvalds
On Thu, Sep 24, 2015 at 6:43 PM, Herbert Xu wrote: > On Thu, Sep 24, 2015 at 04:05:10PM -0400, Tejun Heo wrote: > > +static inline bool netlink_bound(struct netlink_sock *nlk) > +{ > + /* Ensure nlk is hashed and visible. */ > + if (nlk->bound) > + smp_rmb(); > + > +

netlink: Add barrier to netlink_connect for theoretical case

2015-09-24 Thread Herbert Xu
On Thu, Sep 24, 2015 at 04:05:10PM -0400, Tejun Heo wrote: > > > I've decided to apply this and queue it up for -stable. Thanks Dave! > This is mostly correct; however, if there are or can be in-kernel > users which create the client side of netlink socket, it isn't. Let's > say such in-kernel

netlink: Add barrier to netlink_connect for theoretical case

2015-09-24 Thread Herbert Xu
On Thu, Sep 24, 2015 at 04:05:10PM -0400, Tejun Heo wrote: > > > I've decided to apply this and queue it up for -stable. Thanks Dave! > This is mostly correct; however, if there are or can be in-kernel > users which create the client side of netlink socket, it isn't. Let's > say such in-kernel

Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-24 Thread Linus Torvalds
On Thu, Sep 24, 2015 at 6:43 PM, Herbert Xu wrote: > On Thu, Sep 24, 2015 at 04:05:10PM -0400, Tejun Heo wrote: > > +static inline bool netlink_bound(struct netlink_sock *nlk) > +{ > + /* Ensure nlk is hashed and visible. */ > + if (nlk->bound) > +

Re: netlink: Add barrier to netlink_connect for theoretical case

2015-09-24 Thread Herbert Xu
On Thu, Sep 24, 2015 at 08:24:56PM -0700, Linus Torvalds wrote: > > The above looks very suspicious. You're right Linus. I've added the READ_ONCE there. The reason I kept the conditional is because the helper is always called in a context where the result is used as part of an if statement.