OSDN Git Service

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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:50:38 +0000 (14:50 +0100)
commit047b402d1ba3dad09070e4fb9acaf2c38a89ef0d
tree1429cb1b536333bdfa967d81a086018906582f7a
parent4d1f1f1cb0607b4f25ce978ad5f19c8705643981
scsi: target/core: Fix a race condition in the LUN lookup code

[ 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>
drivers/target/target_core_device.c