]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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>
Fri, 13 Jan 2017 01:56:58 +0000 (20:56 -0500)
commitd1b9fb84c423d6a6777da3238abf7e08c13bd7f5
treee275bf19a4f2d9960413f7571de2d1de295db8ea
parentbbe48c2f932ec0cae18291b13553a38aa0e86569
target/user: Fix use-after-free of tcmu_cmds if they are expired

[ 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