Skip to contentSkip to conversation

net/smc: fix fastopen for non-blocking connect()

PATCH In review Karsten Graul 2 participants 2 messages Nov 15, 2019 – Nov 16, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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".

Reported-by [email protected]
Fixes e1bbdd570474 ("net/smc: reduce sock_put() for fallback sockets")
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/af_smc.c +1 -1
index 8edf1619f0e4..737b49909a7a 100644
@@ -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
maintainer
#1 lore raw

From: 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-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".

Quoted 4 lines
Reported-by [email protected]
Fixes e1bbdd570474 ("net/smc: reduce sock_put() for fallback sockets")

Applied and queued up for -stable, thanks.