Skip to content

Commit e321f38

Browse files
Andy Grovergregkh
authored andcommitted
target/user: Fix use-after-free of tcmu_cmds if they are expired
commit d0905ca757bc40bd1ebc261a448a521b064777d7 upstream. 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. 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e5de1c7 commit e321f38

1 file changed

Lines changed: 0 additions & 2 deletions

File tree

drivers/target/target_core_user.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,6 @@ static int tcmu_check_expired_cmd(int id, void *p, void *data)
645645
target_complete_cmd(cmd->se_cmd, SAM_STAT_CHECK_CONDITION);
646646
cmd->se_cmd = NULL;
647647

648-
kmem_cache_free(tcmu_cmd_cache, cmd);
649-
650648
return 0;
651649
}
652650

0 commit comments

Comments
 (0)