mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 15:53:22 -05:00
smc: move unhash as early as possible in smc_release()
In smc_release() we release smc->clcsock before unhash the smc
sock, but a parallel smc_diag_dump() may be still reading
smc->clcsock, therefore this could cause a use-after-free as
reported by syzbot.
Reported-and-tested-by: [email protected]
Fixes: 51f1de79ad ("net/smc: replace sock_put worker by socket refcounting")
Cc: Ursula Braun <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Reported-by: [email protected]
Reported-by: [email protected]
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
7acf8b36a2
commit
26d92e951f
1 changed files with 3 additions and 1 deletions
|
|
@ -146,6 +146,9 @@ static int smc_release(struct socket *sock)
|
|||
sock_set_flag(sk, SOCK_DEAD);
|
||||
sk->sk_shutdown |= SHUTDOWN_MASK;
|
||||
}
|
||||
|
||||
sk->sk_prot->unhash(sk);
|
||||
|
||||
if (smc->clcsock) {
|
||||
if (smc->use_fallback && sk->sk_state == SMC_LISTEN) {
|
||||
/* wake up clcsock accept */
|
||||
|
|
@ -170,7 +173,6 @@ static int smc_release(struct socket *sock)
|
|||
smc_conn_free(&smc->conn);
|
||||
release_sock(sk);
|
||||
|
||||
sk->sk_prot->unhash(sk);
|
||||
sock_put(sk); /* final sock_put */
|
||||
out:
|
||||
return rc;
|
||||
|
|
|
|||
Loading…
Reference in a new issue