]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
scsi: target/core: Fix a race condition in the LUN lookup code
authorBart Van Assche <bvanassche@acm.org>
Tue, 2 Apr 2019 19:58:05 +0000 (12:58 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
commit62614202ec2c522b8953d84221c1728af2626724
tree30b101fd5a4f60bfa228d52a3afc8ce22b5be62e
parent8bb67105d5cbea439ec331664c10361983b94370
scsi: target/core: Fix a race condition in the LUN lookup code

BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit 63f7479439c95bcd49b7dd4af809862c316c71a3 ]

The rcu_dereference(deve->se_lun) expression occurs twice in the LUN lookup
functions. Since these expressions are not serialized against deve->se_lun
assignments each of these expressions may yield a different result. Avoid
that the wrong LUN pointer is stored in se_cmd by reading deve->se_lun only
once.

Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Fixes: 29a05deebf6c ("target: Convert se_node_acl->device_list[] to RCU hlist") # v4.10
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/target/target_core_device.c