net/smc: fix fastopen for non-blocking connect()
PATCH 1/1 net/smc: fix fastopen for non-blocking connect()
From: Ursula Braun <[email protected]>
FASTOPEN does not work with SMC-sockets. Since SMC allows fallback to TCP native during connection start, the FASTOPEN setsockopts trigger this fallback, if the SMC-socket is still in state SMC_INIT.
But if a FASTOPEN setsockopt is called after a non-blocking connect(), this is broken, and fallback does not make sense.
This change complements
commit cd2063604ea6 ("net/smc: avoid fallback in case of non-blocking connect") and fixes the syzbot reported problem "WARNING in smc_unhash_sk".
--- net/smc/af_smc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/af_smc.c +1 -1
@@ -1732,7 +1732,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,case TCP_FASTOPEN_KEY :case TCP_FASTOPEN_NO_COOKIE :/* option not supported by SMC */ -if (sk->sk_state ==SMC_INIT ) { +if (sk->sk_state ==SMC_INIT && !smc->connect_nonblock) {smc_switch_to_fallback (smc); smc->fallback_rsn =SMC_CLC_DECL_OPTUNSUPP ; }else {
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Karsten Graul <[email protected]>
Date: Fri, 15 Nov 2019 12:39:30 +0100
Quoted 11 lines
From: Ursula Braun <[email protected]>
FASTOPEN does not work with SMC-sockets. Since SMC allows fallback to TCP native during connection start, the FASTOPEN setsockopts trigger this fallback, if the SMC-socket is still in state
SMC_INIT.
But if a FASTOPEN setsockopt is called after a non-blockingconnect(), this is broken, and fallback does not make sense.
This change complements
commitcd2063604ea6("net/smc: avoid fallback in case of non-blocking connect") and fixes the syzbot reported problem "WARNING insmc_unhash_sk".
Quoted 4 lines
Reported-by [email protected]Fixes e1bbdd570474 ("net/smc: reduce sock_put() for fallback sockets")Signed-off-by Ursula Braun <[email protected]>Signed-off-by Karsten Graul <[email protected]>
Applied and queued up for -stable, thanks.