Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Tejun Heo
Hello, On Sun, Sep 27, 2015 at 04:10:41AM +0800, Herbert Xu wrote: > Well guess what the bug that you have discovered supposedly due to > a missing barrier in netlink_connect has nothing to do with the > barrier. Instead it is caused by a logical error elsewhere that > would have gone unnoticed o

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Herbert Xu
On Sat, Sep 26, 2015 at 04:05:18PM -0400, Tejun Heo wrote: > > Frankly, I don't understand what you've been trying to achieve. > You're actively disregarding best practices (like terminating > synchronization where it starts) and reach the target state by doing a > browian motion in the solution s

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Tejun Heo
Hello, On Sun, Sep 27, 2015 at 03:55:48AM +0800, Herbert Xu wrote: > Well I disagree. When I say that it returns to user-space I really > mean that the next time we use portid via the same call path that > triggered the connect we must be checking nlk->bound anyway. > > Good luck finding more bu

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Herbert Xu
On Sat, Sep 26, 2015 at 03:52:45PM -0400, Tejun Heo wrote: > > Ah, yeah, you're right. We need to check that there because it may > contain a garbage value. I still think it'd better to use > netlink_bound() test in connect() too tho. Well I disagree. When I say that it returns to user-space I

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Tejun Heo
Hello, On Sun, Sep 27, 2015 at 03:49:16AM +0800, Herbert Xu wrote: > If the autobind is not complete then netlink_getname must return > zero rather than some garbage portid that belongs to somebody > else's socket. That's what we did before any of this lockless > code was introduced. > > If you

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Herbert Xu
On Sat, Sep 26, 2015 at 03:45:54PM -0400, Tejun Heo wrote: > Hello, Herbert. > > On Sun, Sep 27, 2015 at 03:41:10AM +0800, Herbert Xu wrote: > > Thread 1Thread 2 > > sendmsg getsockname > > netlink_autobindnetlink_getname > > > >

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Tejun Heo
Hello, Herbert. On Sun, Sep 27, 2015 at 03:41:10AM +0800, Herbert Xu wrote: > Thread 1 Thread 2 > sendmsg getsockname > netlink_autobindnetlink_getname > > Thread 2 should not have to do anything special to guarantee that >

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Herbert Xu
On Sat, Sep 26, 2015 at 02:09:03PM -0400, Tejun Heo wrote: > > > @@ -1628,7 +1632,7 @@ static int netlink_getname(struct socket *sock, > > struct sockaddr *addr, > > nladdr->nl_pid = nlk->dst_portid; > > nladdr->nl_groups = netlink_group_mask(nlk->dst_group); > > } else

Re: netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Tejun Heo
Hello, Herbert. On Sat, Sep 26, 2015 at 09:16:21PM +0800, Herbert Xu wrote: > You misunderstood what I wrote. I was not basing this on whether > user-space transitions contained a barrier, but on the fact that > the next syscall must recheck nlk->bound before using nlk->portid. But that isn't wh

netlink: Add netlink_bound helper and use it in netlink_getname

2015-09-26 Thread Herbert Xu
On Fri, Sep 25, 2015 at 11:01:13AM -0400, Tejun Heo wrote: > > I'm not even sure we guarantee memory barrier on kernel/user > crossings. In practice, we probably have enough barriers (e.g. some > syscall traps imply barrier) but I can't think of a reason why we'd > guarantee the existence of barr