Re: [PATCH net v5] net: ax25: Fix deadlock caused by skb_recv_datagram in ax25_recvmsg
From: Eric Dumazet <edumazet@google.com>
Date: 2022-06-14 14:48:24
Also in:
linux-hams, lkml
From: Eric Dumazet <edumazet@google.com>
Date: 2022-06-14 14:48:24
Also in:
linux-hams, lkml
On Tue, Jun 14, 2022 at 2:26 AM Duoming Zhou [off-list ref] wrote:
The skb_recv_datagram() in ax25_recvmsg() will hold lock_sock
and block until it receives a packet from the remote. If the client
doesn`t connect to server and calls read() directly, it will not
receive any packets forever. As a result, the deadlock will happen.
The fail log caused by deadlock is shown below:
This patch replaces skb_recv_datagram() with an open-coded variant of it
releasing the socket lock before the __skb_wait_for_more_packets() call
and re-acquiring it after such call in order that other functions that
need socket lock could be executed.
what's more, the socket lock will be released only when recvmsg() will
block and that should produce nicer overall behavior.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Thomas Osterried <redacted>
Signed-off-by: Duoming Zhou <redacted>
Reported-by: Thomas Habets <thomas@@habets.se>
Acked-by: Paolo Abeni <pabeni@redhat.com>
---Reviewed-by: Eric Dumazet <edumazet@google.com>