Skip to content

Commit

Permalink
net/smc: move sock lock in smc_ioctl()
Browse files Browse the repository at this point in the history
When an SMC socket is connecting it is decided whether fallback to
TCP is needed. To avoid races between connect and ioctl move the
sock lock before the use_fallback check.

Reported-by: [email protected]
Reported-by: [email protected]
Fixes: 1992d99 ("net/smc: take sock lock in smc_ioctl()")
Signed-off-by: Ursula Braun <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Ursula Braun authored and davem330 committed Aug 9, 2018
1 parent bd58c7e commit 7311d66
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1522,12 +1522,16 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,

smc = smc_sk(sock->sk);
conn = &smc->conn;
lock_sock(&smc->sk);
if (smc->use_fallback) {
if (!smc->clcsock)
if (!smc->clcsock) {
release_sock(&smc->sk);
return -EBADF;
return smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg);
}
answ = smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg);
release_sock(&smc->sk);
return answ;
}
lock_sock(&smc->sk);
switch (cmd) {
case SIOCINQ: /* same as FIONREAD */
if (smc->sk.sk_state == SMC_LISTEN) {
Expand Down

0 comments on commit 7311d66

Please sign in to comment.