diff options
author | Andy Grover <agrover@redhat.com> | 2016-11-21 19:35:30 -0500 |
---|---|---|
committer | Bart Van Assche <bart.vanassche@sandisk.com> | 2016-12-15 10:34:58 -0500 |
commit | d0905ca757bc40bd1ebc261a448a521b064777d7 (patch) | |
tree | b1a44e58386d0be4b2d49534dcac50c7e36b29ac | |
parent | 8dcf07be2d0bcbfcebc49b9451a4feaf83e3428b (diff) |
target/user: Fix use-after-free of tcmu_cmds if they are expired
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>
-rw-r--r-- | drivers/target/target_core_user.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 1bf1d37aa2e3..2e331008d30b 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c | |||
@@ -686,8 +686,6 @@ static int tcmu_check_expired_cmd(int id, void *p, void *data) | |||
686 | target_complete_cmd(cmd->se_cmd, SAM_STAT_CHECK_CONDITION); | 686 | target_complete_cmd(cmd->se_cmd, SAM_STAT_CHECK_CONDITION); |
687 | cmd->se_cmd = NULL; | 687 | cmd->se_cmd = NULL; |
688 | 688 | ||
689 | kmem_cache_free(tcmu_cmd_cache, cmd); | ||
690 | |||
691 | return 0; | 689 | return 0; |
692 | } | 690 | } |
693 | 691 | ||