Skip to content

Commit

Permalink
target/user: Fix use-after-free of tcmu_cmds if they are expired
Browse files Browse the repository at this point in the history
[ Upstream commit d0905ca ]

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>
  • Loading branch information
Andy Grover authored and Sasha Levin committed Jan 15, 2017
1 parent 3386c47 commit fcc5da2
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions drivers/target/target_core_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit fcc5da2

Please sign in to comment.