diff mbox

[4/4] UBUNTU: SAUCE: (no-up) target/user: Fix use-after-free of tcmu_cmds if they are expired

Message ID 1481220077-3812-5-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner Dec. 8, 2016, 6:01 p.m. UTC
From: Andy Grover <agrover@redhat.com>

BugLink: http://bugs.launchpad.net/bugs/1646204

Don't free the cmd in tcmu_check_expired_cmd, it's still referenced by
an entry in our cmd_id->cmd idr. If userspace ever resumes processing,
tcmu_handle_completions() will use the now-invalid cmd pointer.

Instead, don't free cmd. It will be freed by tcmu_handle_completion() if
userspace ever recovers, or tcmu_free_device if not.

Cc: stable@vger.kernel.org
Reported-by: Bryant G Ly <bgly@us.ibm.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/target/target_core_user.c | 2 --
 1 file changed, 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 542db45..a59a390 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -662,8 +662,6 @@  static int tcmu_check_expired_cmd(int id, void *p, void *data)
 	target_complete_cmd(cmd->se_cmd, SAM_STAT_CHECK_CONDITION);
 	cmd->se_cmd = NULL;
 
-	kmem_cache_free(tcmu_cmd_cache, cmd);
-
 	return 0;
 }