All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] net/smc: fixes 2021-09-20
@ 2021-09-20 19:18 Karsten Graul
  2021-09-20 19:18 ` [PATCH net 1/2] net/smc: add missing error check in smc_clc_prfx_set() Karsten Graul
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Karsten Graul @ 2021-09-20 19:18 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, linux-s390, Heiko Carstens, Guvenc Gulce, Julian Wiedmann

Please apply the following patches for smc to netdev's net tree.

The first patch adds a missing error check, and the second patch
fixes a possible leak of a lock in a worker.

Karsten Graul (2):
  net/smc: add missing error check in smc_clc_prfx_set()
  net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work

 net/smc/smc_clc.c  | 3 ++-
 net/smc/smc_core.c | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] net/smc: add missing error check in smc_clc_prfx_set()
  2021-09-20 19:18 [PATCH net 0/2] net/smc: fixes 2021-09-20 Karsten Graul
@ 2021-09-20 19:18 ` Karsten Graul
  2021-09-20 19:18 ` [PATCH net 2/2] net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work Karsten Graul
  2021-09-21 10:10 ` [PATCH net 0/2] net/smc: fixes 2021-09-20 patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Karsten Graul @ 2021-09-20 19:18 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, linux-s390, Heiko Carstens, Guvenc Gulce, Julian Wiedmann

Coverity stumbled over a missing error check in smc_clc_prfx_set():

*** CID 1475954:  Error handling issues  (CHECKED_RETURN)
/net/smc/smc_clc.c: 233 in smc_clc_prfx_set()
>>>     CID 1475954:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "kernel_getsockname" without checking return value (as is done elsewhere 8 out of 10 times).
233     	kernel_getsockname(clcsock, (struct sockaddr *)&addrs);

Add the return code check in smc_clc_prfx_set().

Fixes: c246d942eabc ("net/smc: restructure netinfo for CLC proposal msgs")
Reported-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 net/smc/smc_clc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index e286dafd6e88..6ec1ebe878ae 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -230,7 +230,8 @@ static int smc_clc_prfx_set(struct socket *clcsock,
 		goto out_rel;
 	}
 	/* get address to which the internal TCP socket is bound */
-	kernel_getsockname(clcsock, (struct sockaddr *)&addrs);
+	if (kernel_getsockname(clcsock, (struct sockaddr *)&addrs) < 0)
+		goto out_rel;
 	/* analyze IP specific data of net_device belonging to TCP socket */
 	addr6 = (struct sockaddr_in6 *)&addrs;
 	rcu_read_lock();
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work
  2021-09-20 19:18 [PATCH net 0/2] net/smc: fixes 2021-09-20 Karsten Graul
  2021-09-20 19:18 ` [PATCH net 1/2] net/smc: add missing error check in smc_clc_prfx_set() Karsten Graul
@ 2021-09-20 19:18 ` Karsten Graul
  2021-09-21 10:10 ` [PATCH net 0/2] net/smc: fixes 2021-09-20 patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Karsten Graul @ 2021-09-20 19:18 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, linux-s390, Heiko Carstens, Guvenc Gulce, Julian Wiedmann

The abort_work is scheduled when a connection was detected to be
out-of-sync after a link failure. The work calls smc_conn_kill(),
which calls smc_close_active_abort() and that might end up calling
smc_close_cancel_work().
smc_close_cancel_work() cancels any pending close_work and tx_work but
needs to release the sock_lock before and acquires the sock_lock again
afterwards. So when the sock_lock was NOT acquired before then it may
be held after the abort_work completes. Thats why the sock_lock is
acquired before the call to smc_conn_kill() in __smc_lgr_terminate(),
but this is missing in smc_conn_abort_work().

Fix that by acquiring the sock_lock first and release it after the
call to smc_conn_kill().

Fixes: b286a0651e44 ("net/smc: handle incoming CDC validation message")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 net/smc/smc_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index af227b65669e..8280c938be80 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -1474,7 +1474,9 @@ static void smc_conn_abort_work(struct work_struct *work)
 						   abort_work);
 	struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
 
+	lock_sock(&smc->sk);
 	smc_conn_kill(conn, true);
+	release_sock(&smc->sk);
 	sock_put(&smc->sk); /* sock_hold done by schedulers of abort_work */
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] net/smc: fixes 2021-09-20
  2021-09-20 19:18 [PATCH net 0/2] net/smc: fixes 2021-09-20 Karsten Graul
  2021-09-20 19:18 ` [PATCH net 1/2] net/smc: add missing error check in smc_clc_prfx_set() Karsten Graul
  2021-09-20 19:18 ` [PATCH net 2/2] net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work Karsten Graul
@ 2021-09-21 10:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-21 10:10 UTC (permalink / raw)
  To: Karsten Graul; +Cc: davem, kuba, netdev, linux-s390, hca, guvenc, jwi

Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Mon, 20 Sep 2021 21:18:13 +0200 you wrote:
> Please apply the following patches for smc to netdev's net tree.
> 
> The first patch adds a missing error check, and the second patch
> fixes a possible leak of a lock in a worker.
> 
> Karsten Graul (2):
>   net/smc: add missing error check in smc_clc_prfx_set()
>   net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work
> 
> [...]

Here is the summary with links:
  - [net,1/2] net/smc: add missing error check in smc_clc_prfx_set()
    https://git.kernel.org/netdev/net/c/6c9073198065
  - [net,2/2] net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work
    https://git.kernel.org/netdev/net/c/a18cee4791b1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-21 10:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 19:18 [PATCH net 0/2] net/smc: fixes 2021-09-20 Karsten Graul
2021-09-20 19:18 ` [PATCH net 1/2] net/smc: add missing error check in smc_clc_prfx_set() Karsten Graul
2021-09-20 19:18 ` [PATCH net 2/2] net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work Karsten Graul
2021-09-21 10:10 ` [PATCH net 0/2] net/smc: fixes 2021-09-20 patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.