Skip to content

Commit

Permalink
net/smc: fix restoring of fallback changes
Browse files Browse the repository at this point in the history
When a listen socket is closed then all non-accepted sockets in its
accept queue are to be released. Inside __smc_release() the helper
smc_restore_fallback_changes() restores the changes done to the socket
without to check if the clcsocket has a file set. This can result in
a crash. Fix this by checking the file pointer first.

Reviewed-by: Ursula Braun <ubraun@linux.ibm.com>
Fixes: f536dff ("net/smc: fix closing of fallback SMC sockets")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Karsten Graul authored and David S. Miller committed Jul 19, 2020
1 parent fd7f3a7 commit 1ad2405
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ EXPORT_SYMBOL_GPL(smc_proto6);

static void smc_restore_fallback_changes(struct smc_sock *smc)
{
smc->clcsock->file->private_data = smc->sk.sk_socket;
smc->clcsock->file = NULL;
if (smc->clcsock->file) { /* non-accepted sockets have no file yet */
smc->clcsock->file->private_data = smc->sk.sk_socket;
smc->clcsock->file = NULL;
}
}

static int __smc_release(struct smc_sock *smc)
Expand Down

0 comments on commit 1ad2405

Please sign in to comment.