net/smc: fixes 2021-09-20
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
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().
--- net/smc/smc_clc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/smc/smc_clc.c +2 -1
@@ -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
PATCH 2/2 net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work
In reply to Karsten GraulThe 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().
--- net/smc/smc_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/smc/smc_core.c +2 -0
@@ -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
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 insmc_clc_prfx_set()net/smc: fix 'workqueue leaked lock' insmc_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