mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 15:53:22 -05:00
net/smc: Don't call clcsock shutdown twice when smc shutdown
[ Upstream commit bacb6c1e47691cda4a95056c21b5487fb7199fcc ] When applications call shutdown() with SHUT_RDWR in userspace, smc_close_active() calls kernel_sock_shutdown(), and it is called twice in smc_shutdown(). This fixes this by checking sk_state before do clcsock shutdown, and avoids missing the application's call of smc_shutdown(). Link: https://lore.kernel.org/linux-s390/[email protected]/ Fixes: 606a63c9783a ("net/smc: Ensure the active closing peer first closes clcsock") Signed-off-by: Tony Lu <[email protected]> Reviewed-by: Wen Gu <[email protected]> Acked-by: Karsten Graul <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
5e44178864
commit
3b96164039
1 changed files with 7 additions and 1 deletions
|
|
@ -1658,8 +1658,10 @@ static __poll_t smc_poll(struct file *file, struct socket *sock,
|
|||
static int smc_shutdown(struct socket *sock, int how)
|
||||
{
|
||||
struct sock *sk = sock->sk;
|
||||
bool do_shutdown = true;
|
||||
struct smc_sock *smc;
|
||||
int rc = -EINVAL;
|
||||
int old_state;
|
||||
int rc1 = 0;
|
||||
|
||||
smc = smc_sk(sk);
|
||||
|
|
@ -1686,7 +1688,11 @@ static int smc_shutdown(struct socket *sock, int how)
|
|||
}
|
||||
switch (how) {
|
||||
case SHUT_RDWR: /* shutdown in both directions */
|
||||
old_state = sk->sk_state;
|
||||
rc = smc_close_active(smc);
|
||||
if (old_state == SMC_ACTIVE &&
|
||||
sk->sk_state == SMC_PEERCLOSEWAIT1)
|
||||
do_shutdown = false;
|
||||
break;
|
||||
case SHUT_WR:
|
||||
rc = smc_close_shutdown_write(smc);
|
||||
|
|
@ -1696,7 +1702,7 @@ static int smc_shutdown(struct socket *sock, int how)
|
|||
/* nothing more to do because peer is not involved */
|
||||
break;
|
||||
}
|
||||
if (smc->clcsock)
|
||||
if (do_shutdown && smc->clcsock)
|
||||
rc1 = kernel_sock_shutdown(smc->clcsock, how);
|
||||
/* map sock_shutdown_cmd constants to sk_shutdown value range */
|
||||
sk->sk_shutdown |= how + 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue