Skip to contentSkip to conversation

smc: fix potential use after free

PATCH Applied Ursula Braun 2 participants 3 messages Jan 30, 2017

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

cover smc: fix potential use after free

From: Ursula Braun <[email protected]>

Hi Dave,

please add Dan's fix for the smc-code. Thanks, Dan and Dave!

Regards, Ursula Braun

Dan Carpenter (1):
smc: Reset rx/tx buffer descriptor in case of errors

 net/smc/smc_core.c | 5 +++++
 1 file changed, 5 insertions(+)
Signature · 1 line
2.8.4
#1 lore raw

PATCH 1/1 smc: some potential use after free bugs

From: Dan Carpenter <[email protected]>

Say we got really unlucky and these failed on the last iteration, then it could lead to a use after free bug.

Fixes cd6851f30386 ("smc: remote memory buffers (RMBs)")
---
 net/smc/smc_core.c | 5 +++++
 1 file changed, 5 insertions(+)
net/smc/smc_core.c +5 -0
index 8b1d343..0eac633 100644
@@ -532,6 +532,7 @@ int smc_sndbuf_create(struct smc_sock *smc)
 						__GFP_NORETRY);
 		if (!sndbuf_desc->cpu_addr) {
 			kfree(sndbuf_desc);
+			sndbuf_desc = NULL;
 			/* if send buffer allocation has failed,
 			 * try a smaller one
 			 */
@@ -543,6 +544,7 @@ int smc_sndbuf_create(struct smc_sock *smc)
 		if (rc) {
 			kfree(sndbuf_desc->cpu_addr);
 			kfree(sndbuf_desc);
+			sndbuf_desc = NULL;
 			continue; /* if mapping failed, try smaller one */
 		}
 		sndbuf_desc->used = 1;
@@ -596,6 +598,7 @@ int smc_rmb_create(struct smc_sock *smc)
 					     __GFP_NORETRY);
 		if (!rmb_desc->cpu_addr) {
 			kfree(rmb_desc);
+			rmb_desc = NULL;
 			/* if RMB allocation has failed,
 			 * try a smaller one
 			 */
@@ -607,6 +610,7 @@ int smc_rmb_create(struct smc_sock *smc)
 		if (rc) {
 			kfree(rmb_desc->cpu_addr);
 			kfree(rmb_desc);
+			rmb_desc = NULL;
 			continue; /* if mapping failed, try smaller one */
 		}
 		rc = smc_ib_get_memory_region(lgr->lnk[SMC_SINGLE_LINK].roce_pd,
@@ -619,6 +623,7 @@ int smc_rmb_create(struct smc_sock *smc)
 					 DMA_FROM_DEVICE);
 			kfree(rmb_desc->cpu_addr);
 			kfree(rmb_desc);
+			rmb_desc = NULL;
 			continue;
 		}
 		rmb_desc->used = 1;
Signature · 1 line
2.8.4
maintainer Applied
#2 lore raw

Re: [PATCH net-next 1/1] smc: some potential use after free bugs

From: Ursula Braun <[email protected]>
Date: Mon, 30 Jan 2017 10:55:04 +0100

Quoted 8 lines

From: Dan Carpenter <[email protected]>

Say we got really unlucky and these failed on the last iteration, then it could lead to a use after free bug.

Fixes cd6851f30386 ("smc: remote memory buffers (RMBs)")

Applied, thank you.