Skip to contentSkip to conversation

net/smc: fixes 2021-09-20

PATCH Applied Karsten Graul 2 participants 4 messages Sep 20, 2021 – Sep 21, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net/smc: fixes 2021-09-20

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(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 net/smc: add missing error check in smc_clc_prfx_set()

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()

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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")
---
 net/smc/smc_clc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/smc/smc_clc.c +2 -1
index e286dafd6e88..6ec1ebe878ae 100644
@@ -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();
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work

In reply to Karsten Graul

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")
---
 net/smc/smc_core.c | 2 ++
 1 file changed, 2 insertions(+)
net/smc/smc_core.c +2 -0
index af227b65669e..8280c938be80 100644
@@ -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 */
 }
 
Signature · 1 line
2.25.1
#3 lore raw
In reply to Karsten Graul
This series was applied to netdev/net.git (refs/heads/master):

Hello:

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

Quoted 10 lines · 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