]> git.itanic.dy.fi Git - linux-stable/commitdiff
target/user: Fix use-after-free of tcmu_cmds if they are expired
authorAndy Grover <agrover@redhat.com>
Tue, 22 Nov 2016 00:35:30 +0000 (16:35 -0800)
committerSasha Levin <alexander.levin@verizon.com>
Sun, 15 Jan 2017 14:49:52 +0000 (09:49 -0500)
[ Upstream commit d0905ca757bc40bd1ebc261a448a521b064777d7 ]

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>
Tested-by: Bryant G Ly <bgly@us.ibm.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
drivers/target/target_core_user.c

index 9a1b314f64824e4d6d0dcd3f1dcb56968832de2e..90e55b469c1ea3a502a14cfbbeb1787695e23a6e 100644 (file)
@@ -587,8 +587,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;
 }