net/x25: fix call timeouts in blocking connects
authorMartin Schiller <ms@dev.tdt.de>
Fri, 5 Aug 2022 06:18:10 +0000 (08:18 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 9 Aug 2022 03:48:51 +0000 (20:48 -0700)
commit944e594cfa84ec552831489c244e02589d826b11
treeb4219f76da4247b7270cf520bacfe420795dd365
parent8eb6fcc9a7cb4337ba985a397d892af5c0ddb0e7
net/x25: fix call timeouts in blocking connects

When a userspace application starts a blocking connect(), a CALL REQUEST
is sent, the t21 timer is started and the connect is waiting in
x25_wait_for_connection_establishment(). If then for some reason the t21
timer expires before any reaction on the assigned logical channel (e.g.
CALL ACCEPT, CLEAR REQUEST), there is sent a CLEAR REQUEST and timer
t23 is started waiting for a CLEAR confirmation. If we now receive a
CLEAR CONFIRMATION from the peer, x25_disconnect() is called in
x25_state2_machine() with reason "0", which means "normal" call
clearing. This is ok, but the parameter "reason" is used as sk->sk_err
in x25_disconnect() and sock_error(sk) is evaluated in
x25_wait_for_connection_establishment() to check if the call is still
pending. As "0" is not rated as an error, the connect will stuck here
forever.

To fix this situation, also check if the sk->sk_state changed form
TCP_SYN_SENT to TCP_CLOSE in the meantime, which is also done by
x25_disconnect().

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
Link: https://lore.kernel.org/r/20220805061810.10824-1-ms@dev.tdt.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/x25/af_x25.c