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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+rthh85wArTd9w7S_GhzbzMxrMRjWBym-4cEzc3MmkkUx+bsg@mail.gmail.com>
Date:	Wed, 4 Mar 2015 21:39:52 +0100
From:	Mathias Krause <minipli@...glemail.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
	Olivier Mauras <olivier@...ras.ch>,
	Rainer Weikusat <rweikusat@...gmbh.com>,
	PaX Team <pageexec@...email.hu>
Subject: Re: [PATCH net] af_unix: don't poll dead peers

On 4 March 2015 at 21:21, Eric Dumazet <eric.dumazet@...il.com> wrote:
> On Wed, 2015-03-04 at 21:07 +0100, Mathias Krause wrote:
>> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
>> index 526b6edab018..0da9d7eeed17 100644
>> --- a/net/unix/af_unix.c
>> +++ b/net/unix/af_unix.c
>> @@ -2233,10 +2233,14 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
>>       writable = unix_writable(sk);
>>       other = unix_peer_get(sk);
>>       if (other) {
>> -             if (unix_peer(other) != sk) {
>> +             unix_state_lock(other);
>> +             if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) != sk) {
>> +                     unix_state_unlock(other);
>>                       sock_poll_wait(file, &unix_sk(other)->peer_wait, wait);
>>                       if (unix_recvq_full(other))
>>                               writable = 0;
>> +             } else {
>> +                     unix_state_unlock(other);
>>               }
>>               sock_put(other);
>>       }
>
>
> Using locks in _poll() is going to be tremendously expensive for some
> applications still using poll() or select() ?

I've no idea but we're already taking this very lock in the
unix_peer_get() call a few lines above.
My tests survived ~12 hours of stress testing without taking the lock,
too. But I'm not at all familiar with the locking semantics here, but
quite a few other locations in af_unix.c take the lock prior testing
the flag.
I'm happy either way -- with or without lock.

>
> This might be find for a stable candidate, but...
>I I
> It seems RCU locking might be more appropriate in this fast path.
>
> Please take a look at struct socket" and its "struct socket_wq __rcu
> *wq;"
>
> (commit 43815482370c510c569fd18edb57afcb0fa8cab6 for details)

I guess that would require more intrusive rewrites of the code I'm,
unfortunately, incapable to do right now. Maybe you are?

Thanks,
Mathias
--
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