Skip to content

Commit 784813a

Browse files
Ursula Braundavem330
authored andcommitted
net/smc: restrict non-blocking connect finish
The smc_poll code tries to finish connect() if the socket is in state SMC_INIT and polling of the internal CLC-socket returns with EPOLLOUT. This makes sense for a select/poll call following a connect call, but not without preceding connect(). With this patch smc_poll starts connect logic only, if the CLC-socket is no longer in its initial state TCP_CLOSE. In addition, a poll error on the internal CLC-socket is always propagated to the SMC socket. With this patch the code path mentioned by syzbot https://syzkaller.appspot.com/bug?extid=03faa2dc16b8b64be396 is no longer possible. Signed-off-by: Ursula Braun <[email protected]> Reported-by: [email protected] Signed-off-by: David S. Miller <[email protected]>
1 parent af3e0fc commit 784813a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/smc/af_smc.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,13 +1166,15 @@ static __poll_t smc_poll(struct file *file, struct socket *sock,
11661166
/* delegate to CLC child sock */
11671167
release_sock(sk);
11681168
mask = smc->clcsock->ops->poll(file, smc->clcsock, wait);
1169-
/* if non-blocking connect finished ... */
11701169
lock_sock(sk);
1171-
if ((sk->sk_state == SMC_INIT) && (mask & EPOLLOUT)) {
1172-
sk->sk_err = smc->clcsock->sk->sk_err;
1173-
if (sk->sk_err) {
1174-
mask |= EPOLLERR;
1175-
} else {
1170+
sk->sk_err = smc->clcsock->sk->sk_err;
1171+
if (sk->sk_err) {
1172+
mask |= EPOLLERR;
1173+
} else {
1174+
/* if non-blocking connect finished ... */
1175+
if (sk->sk_state == SMC_INIT &&
1176+
mask & EPOLLOUT &&
1177+
smc->clcsock->sk->sk_state != TCP_CLOSE) {
11761178
rc = smc_connect_rdma(smc);
11771179
if (rc < 0)
11781180
mask |= EPOLLERR;

0 commit comments

Comments
 (0)