Re: [PATCH] net: fix a lockdep splat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le mercredi 22 septembre 2010 Ã 21:23 -0700, David Miller a Ãcrit :
> From: David Miller <davem@xxxxxxxxxxxxx>
> Date: Wed, 22 Sep 2010 20:53:24 -0700 (PDT)
> 
> > From: Eric Dumazet <eric.dumazet@xxxxxxxxx>
> > Date: Thu, 23 Sep 2010 00:43:39 +0200
> > 
> >> (A) (this is used in net/sunrpc/xprtsock.c)
> >> read_lock(&sk->sk_callback_lock) (without blocking BH)
> >> <BH>
> >> spin_lock(&sk->sk_slock.slock);
> >> ...
> >> read_lock(&sk->sk_callback_lock);
> >> ...
> > 
> > What's the exact path that leads to this?  I looked quickly and couldn't
> > find which sunrpc callback override does it.
> 
> Sorry, I'm being unusually dense at the moment, ignore this question :-)

No problem ;)

But we might answer it anyway for other readers :

vi +1417 net/sunrpc/xprtsock.c

static void xs_udp_write_space(struct sock *sk)
{
        read_lock(&sk->sk_callback_lock);

// We can be interrupted here and call INPUT_PATH()

        /* from net/core/sock.c:sock_def_write_space */
        if (sock_writeable(sk))
                xs_write_space(sk);

        read_unlock(&sk->sk_callback_lock);
}

INPUT_PATH()
{
	spin_lock(&sk->slock);
	queue skb to receive queue or backlog
	spin_unlock(&sk->slock);
}


If another cpu does (C), we can deadlock.

C)
spin_lock_bh(&sk->sk_slock)
...
write_lock_bh(&sk->sk_callback_lock)
...

Then we can have a deadlock with (A)

CPU1 [A]                                CPU2 [C]
read_lock(&sk->sk_callback_lock)
<BH>                                    spin_lock_bh(&sk->sk_slock)
<wait to spin_lock(slock)>
                                        <wait to write_lock_bh(callback_lock)>


It seems only TCP stack contains [C] cases, in very unlikely paths, but still...

Since all AF_INET sockets share the same af_callback_key 
*and* the same af_family_slock_keys, lockdep warned Tetsuo because
 it detects an UDP [A] case and a TCP [C] case.



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


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux