diff options
author | Ursula Braun <ubraun@linux.ibm.com> | 2019-08-02 10:47:50 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-09 17:51:47 +0200 |
commit | 5fd5ac854f572487adbbc4aff3ffe649bbb17728 (patch) | |
tree | 5507214cc58fb5eea84b92412352519417b257c5 /net | |
parent | d6dd739e2dcec39f4b17e9c29134cceea23fef0b (diff) | |
download | linux-stable-5fd5ac854f572487adbbc4aff3ffe649bbb17728.tar.gz linux-stable-5fd5ac854f572487adbbc4aff3ffe649bbb17728.tar.bz2 linux-stable-5fd5ac854f572487adbbc4aff3ffe649bbb17728.zip |
net/smc: avoid fallback in case of non-blocking connect
[ Upstream commit cd2063604ea6a8c2683b4eb9b5f4c4da74592d87 ]
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/smc/af_smc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 4b2f555a0db2..a3cc879d2589 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -253,7 +253,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; @@ -1399,7 +1399,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; @@ -1527,7 +1528,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 { |