* [PATCH net] net/smc: avoid fallback in case of non-blocking connect
@ 2019-08-02 8:47 Karsten Graul
2019-08-05 20:25 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Karsten Graul @ 2019-08-02 8:47 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, gor, heiko.carstens, raspl, ubraun
From: Ursula Braun <ubraun@linux.ibm.com>
FASTOPEN is not possible with SMC. sendmsg() with msg_flag MSG_FASTOPEN
triggers a fallback to TCP if the socket is in state SMC_INIT.
But if a nonblocking connect is already started, fallback to TCP
is no longer possible, even though the socket may still be in state
SMC_INIT.
And if a nonblocking connect is already started, a listen() call
does not make sense.
Reported-by: syzbot+bd8cc73d665590a1fcad@syzkaller.appspotmail.com
Fixes: 50717a37db032 ("net/smc: nonblocking connect rework")
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
net/smc/af_smc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index f5ea09258ab0..5b932583e407 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -263,7 +263,7 @@ static int smc_bind(struct socket *sock, struct sockaddr *uaddr,
/* Check if socket is already active */
rc = -EINVAL;
- if (sk->sk_state != SMC_INIT)
+ if (sk->sk_state != SMC_INIT || smc->connect_nonblock)
goto out_rel;
smc->clcsock->sk->sk_reuse = sk->sk_reuse;
@@ -1390,7 +1390,8 @@ static int smc_listen(struct socket *sock, int backlog)
lock_sock(sk);
rc = -EINVAL;
- if ((sk->sk_state != SMC_INIT) && (sk->sk_state != SMC_LISTEN))
+ if ((sk->sk_state != SMC_INIT && sk->sk_state != SMC_LISTEN) ||
+ smc->connect_nonblock)
goto out;
rc = 0;
@@ -1518,7 +1519,7 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
goto out;
if (msg->msg_flags & MSG_FASTOPEN) {
- 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.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net/smc: avoid fallback in case of non-blocking connect
2019-08-02 8:47 [PATCH net] net/smc: avoid fallback in case of non-blocking connect Karsten Graul
@ 2019-08-05 20:25 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-08-05 20:25 UTC (permalink / raw)
To: kgraul; +Cc: netdev, linux-s390, gor, heiko.carstens, raspl, ubraun
From: Karsten Graul <kgraul@linux.ibm.com>
Date: Fri, 2 Aug 2019 10:47:50 +0200
> From: Ursula Braun <ubraun@linux.ibm.com>
>
> FASTOPEN is not possible with SMC. sendmsg() with msg_flag MSG_FASTOPEN
> triggers a fallback to TCP if the socket is in state SMC_INIT.
> But if a nonblocking connect is already started, fallback to TCP
> is no longer possible, even though the socket may still be in state
> SMC_INIT.
> And if a nonblocking connect is already started, a listen() call
> does not make sense.
>
> Reported-by: syzbot+bd8cc73d665590a1fcad@syzkaller.appspotmail.com
> Fixes: 50717a37db032 ("net/smc: nonblocking connect rework")
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-05 20:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-02 8:47 [PATCH net] net/smc: avoid fallback in case of non-blocking connect Karsten Graul
2019-08-05 20:25 ` 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).