]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
scsi: core: Fix race on creating sense cache
authorMing Lei <ming.lei@redhat.com>
Fri, 12 Jul 2019 02:08:19 +0000 (10:08 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commitd1b212a17362ec3a9aece5cb4791aaaaf22575ae
treef5c20727e42632f6e4f2a314ff916a47dcb0bf88
parentfc94b12c0dc91bcfd77c1c326ab2bdd13eb0f2e4
scsi: core: Fix race on creating sense cache

BugLink: https://bugs.launchpad.net/bugs/1839036
commit f9b0530fa02e0c73f31a49ef743e8f44eb8e32cc upstream.

When scsi_init_sense_cache(host) is called concurrently from different
hosts, each code path may find that no cache has been created and
allocate a new one. The lack of locking can lead to potentially
overriding a cache allocated by a different host.

Fix the issue by moving 'mutex_lock(&scsi_sense_cache_mutex)' before
scsi_select_sense_cache().

Fixes: 0a6ac4ee7c21 ("scsi: respect unchecked_isa_dma for blk-mq")
Cc: Stable <stable@vger.kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/scsi/scsi_lib.c