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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6a4bb567-8970-476d-a800-6f24ccbc397f@riseup.net>
Date: Wed, 27 Nov 2024 10:05:33 +0100
From: "Fernando F. Mancera" <ffmancera@...eup.net>
To: Paolo Abeni <pabeni@...hat.com>, Eric Dumazet <edumazet@...gle.com>
Cc: netdev@...r.kernel.org, willemb@...gle.com
Subject: Re: [PATCH net] udp: call sock_def_readable() if socket is not
 SOCK_FASYNC

Hi Paolo,

On 27/11/2024 08:46, Paolo Abeni wrote:
> Hi,
> 
> I'm sorry for the latency here.
> 
> On 11/26/24 19:41, Eric Dumazet wrote:
>> On Tue, Nov 26, 2024 at 7:32 PM Eric Dumazet <edumazet@...gle.com> wrote:
>>>
>>> On Tue, Nov 26, 2024 at 6:56 PM Fernando Fernandez Mancera
>>> <ffmancera@...eup.net> wrote:
>>>>
>>>> If a socket is not SOCK_FASYNC, sock_def_readable() needs to be called
>>>> even if receive queue was not empty. Otherwise, if several threads are
>>>> listening on the same socket with blocking recvfrom() calls they might
>>>> hang waiting for data to be received.
>>>>
>>>
>>> SOCK_FASYNC seems completely orthogonal to the issue.
>>>
>>> First sock_def_readable() should wakeup all threads, I wonder what is happening.
>>
>> Oh well, __skb_wait_for_more_packets() is using
>> prepare_to_wait_exclusive(), so in this case sock_def_readable() is
>> waking only one thread.
> 
> Very likely whatever I'll add here will be of little use, still...
> 
> AFAICS prepare_to_wait_exclusive() is there since pre git times, so its
> usage not be the cause of behaviors changes.
> 

I don't think the problem is on the usage of prepare_to_wait_exclusive() 
but on the fact that after 612b1c0dec5bc7367f90fc508448b8d0d7c05414 
sock_def_readable() is not being called everytime 
__udp_enqueue_schedule_skb() is called, instead it is called when the 
socket was empty before. On a single thread scenario this is completely 
fine but some issues were reported on scenarios involving multiple 
threads. Please see: https://bugzilla.redhat.com/2308477

>>> UDP can store incoming packets into sk->sk_receive_queue and
>>> udp_sk(sk)->reader_queue
>>>
>>> Paolo, should __skb_wait_for_more_packets() for UDP socket look at both queues ?
> 
> That in case multiple threads are woken-up and thread-1 splices
> sk_receive_queue into reader_queue before thread-2 has any chance of
> checking the first, I guess?
> 
> With prepare_to_wait_exclusive, checking a single queue should be ok.
> 

The scenario I have to reproduce this easily is the following:
1. Create 1 UDP socket
2. Create 5 threads and let them run into a blocking recvfrom()
3. Send 5 small UDP datagrams from main thread to the UDP socket
4. The 5 threads independently terminate after receiving 1 datagram.

This, doesn't work after 612b1c0dec5bc7367f90fc508448b8d0d7c05414 as the 
first time we call __udp_enqueue_schedule_skb() we call 
sock_def_readable() and it wakes up a single thread which receives the 
packet and terminates. The following times we call 
__udp_enqueue_schedule_skb() we are avoiding the sock_def_readable() 
call. This causes the other threads are not being woke up and they are 
blocked waiting on the recvfrom() forever.

Thank you, Fernando.

> /P
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ