]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
scsi: target: Fix crash during SPEC_I_PT handling
authorMike Christie <michael.christie@oracle.com>
Thu, 2 Jul 2020 01:43:19 +0000 (20:43 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 8 Jul 2020 04:14:34 +0000 (00:14 -0400)
commitf32ba612ef0f8eecaf6d2a5b04076ee7ea9ed039
treea56541b1b169c445b7770687e099af536ab46e99
parent3c006c7d23aac928279f7cbe83bbac4361255d53
scsi: target: Fix crash during SPEC_I_PT handling

__core_scsi3_add_registration clears the t10_pr_registration pr_reg_deve
and does a core_scsi3_lunacl_undepend_item which does an undepend and also
does a kref_put from the get done in __core_scsi3_alloc_registration. So
when we get to the bottom of core_scsi3_decode_spec_i_port the pr_reg_deve
is NULL and we crash when trying to access the local_pr_reg's pr_reg_deve.
We've also done an extra undepend for local_pr_reg and if we didn't crash
on the NULL we would have done an extra kref_put too.

This patch has us do a core_scsi3_lunacl_depend_item for local_pr_reg and
then let __core_scsi3_add_registration handle the cleanup for the
pr_reg_deve. We then just skip the undepend for the acl and tpg for the
local pr_reg.

The error path then works in a similar way, but we always do the
core_scsi3_lunacl_undepend_item since we never call
__core_scsi3_add_registration in that code path.

Link: https://lore.kernel.org/r/1593654203-12442-4-git-send-email-michael.christie@oracle.com
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_pr.c