netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net/smc: fix fastopen for non-blocking connect()
@ 2019-11-15 11:39 Karsten Graul
  2019-11-16 21:04 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Karsten Graul @ 2019-11-15 11:39 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

From: Ursula Braun <ubraun@linux.ibm.com>

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: syzbot+8488cc4cf1c9e09b8b86@syzkaller.appspotmail.com
Fixes: e1bbdd570474 ("net/smc: reduce sock_put() for fallback sockets")
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 8edf1619f0e4..737b49909a7a 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -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 {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net/smc: fix fastopen for non-blocking connect()
  2019-11-15 11:39 [PATCH net] net/smc: fix fastopen for non-blocking connect() Karsten Graul
@ 2019-11-16 21:04 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-11-16 21:04 UTC (permalink / raw)
  To: kgraul; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

From: Karsten Graul <kgraul@linux.ibm.com>
Date: Fri, 15 Nov 2019 12:39:30 +0100

> From: Ursula Braun <ubraun@linux.ibm.com>
> 
> 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: syzbot+8488cc4cf1c9e09b8b86@syzkaller.appspotmail.com
> Fixes: e1bbdd570474 ("net/smc: reduce sock_put() for fallback sockets")
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-16 21:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15 11:39 [PATCH net] net/smc: fix fastopen for non-blocking connect() Karsten Graul
2019-11-16 21:04 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).