On Wed, Mar 30, 2016 at 10:08:10PM -0700, Alexei Starovoitov wrote: > On Thu, Mar 31, 2016 at 07:01:15AM +0200, Michal Kubecek wrote: > > On Wed, Mar 30, 2016 at 06:18:42PM -0700, Alexei Starovoitov wrote: > > > > > > kinda heavy patch to shut up lockdep. > > > Can we do > > > old_fp = rcu_dereference_protected(sk->sk_filter, > > > sock_owned_by_user(sk) || > > > lockdep_rtnl_is_held()); > > > and it always be correct? > > > I think right now tun is the only such user, but if it's correct > > > for tun, it's correct for future users too. If not correct then > > > not correct for tun either. > > > Or I'm missing something? > > > > Already discussed here: > > > > http://thread.gmane.org/gmane.linux.kernel/2158069/focus=405853 > > I saw that. My point above was challenging 'less accurate' part. > Daniel's point was that lockdep_rtnl_is_held() does not mean "we hold RTNL" but "someone holds RTNL" so that some other task holding RTNL at the moment could make the check happy even when called by someone supposed to own the socket.
So I guess the key question is if avoiding this type of false negative is important enough to justify the extra complexity (taking into account this race would have to happen every time the check is performed to really hide a locking issue). Michal Kubecek