Skip to content

Commit

Permalink
net/smc: avoid fallback in case of non-blocking connect
Browse files Browse the repository at this point in the history
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: 50717a3 ("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>
  • Loading branch information
Ursula Braun authored and David S. Miller committed Aug 5, 2019
1 parent f9cedf1 commit cd20636
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit cd20636

Please sign in to comment.