Skip to contentSkip to conversation

net/smc: fixes for -net

PATCH In review Karsten Graul 2 participants 4 messages Oct 23, 2019 – Oct 26, 2019

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

cover net/smc: fixes for -net

Fixes for the net tree, covering a memleak when closing SMC fallback sockets and fix SMC-R connection establishment when vlan-ids are used.

Ursula Braun (2):
net/smc: fix closing of fallback SMC sockets net/smc: keep vlan_id for SMC-R in smc_listen_work()

 net/smc/af_smc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 net/smc: fix closing of fallback SMC sockets

From: Ursula Braun <[email protected]>

For SMC sockets forced to fallback to TCP, the file is propagated from the outer SMC to the internal TCP socket. When closing the SMC socket, the internal TCP socket file pointer must be restored to the original NULL value, otherwise memory leaks may show up (found with CONFIG_DEBUG_KMEMLEAK).

The internal TCP socket is released in smc_clcsock_release(), which calls __sock_release() function in net/socket.c. This calls the needed iput(SOCK_INODE(sock)) only, if the file pointer has been reset to the original NULL-value.

Fixes 07603b230895 ("net/smc: propagate file from SMC to TCP socket")
---
 net/smc/af_smc.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/smc/af_smc.c +7 -0
index 5b932583e407..d9566e84f2f9 100644
@@ -123,6 +123,12 @@ struct proto smc_proto6 = {
 };
 EXPORT_SYMBOL_GPL(smc_proto6);
 
+static void smc_restore_fallback_changes(struct smc_sock *smc)
+{
+	smc->clcsock->file->private_data = smc->sk.sk_socket;
+	smc->clcsock->file = NULL;
+}
+
 static int __smc_release(struct smc_sock *smc)
 {
 	struct sock *sk = &smc->sk;
@@ -141,6 +147,7 @@ static int __smc_release(struct smc_sock *smc)
 		}
 		sk->sk_state = SMC_CLOSED;
 		sk->sk_state_change(sk);
+		smc_restore_fallback_changes(smc);
 	}
 
 	sk->sk_prot->unhash(sk);
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 net/smc: keep vlan_id for SMC-R in smc_listen_work()

In reply to Karsten Graul

From: Ursula Braun <[email protected]>

Creating of an SMC-R connection with vlan-id fails, because smc_listen_work() determines the vlan_id of the connection, saves it in struct smc_init_info ini, but clears the ini area again if SMC-D is not applicable.
This patch just resets the ISM device before investigating SMC-R availability.

Fixes bc36d2fc93eb ("net/smc: consolidate function parameters")
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/af_smc.c +1 -1
index d9566e84f2f9..cea3c36ea0da 100644
@@ -1298,8 +1298,8 @@ static void smc_listen_work(struct work_struct *work)
 	/* check if RDMA is available */
 	if (!ism_supported) { /* SMC_TYPE_R or SMC_TYPE_B */
 		/* prepare RDMA check */
-		memset(&ini, 0, sizeof(ini));
 		ini.is_smcd = false;
+		ini.ism_dev = NULL;
 		ini.ib_lcl = &pclc->lcl;
 		rc = smc_find_rdma_device(new_smc, &ini);
 		if (rc) {
Signature · 1 line
2.17.1
maintainer
#3 lore raw
In reply to Karsten Graul

From: Karsten Graul <[email protected]>
Date: Wed, 23 Oct 2019 15:44:04 +0200

Quoted 3 lines

Fixes for the net tree, covering a memleak when closing SMC fallback sockets and fix SMC-R connection establishment when vlan-ids are used.

Series applied, thanks.