scsi: cxlflash: Acquire semaphore before invoking ioctl services
authorUma Krishnan <ukrishn@linux.vnet.ibm.com>
Fri, 11 May 2018 19:05:22 +0000 (14:05 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 18 May 2018 15:22:10 +0000 (11:22 -0400)
commit32a9ae415b8a4258140312f91c71324950d9eba4
treebe7cdfb54d8c0f5b18cfdf06f83fe812a65c3fca
parentd58188c306a010d32a250ae532c3daaae8c57346
scsi: cxlflash: Acquire semaphore before invoking ioctl services

When a superpipe process that makes use of virtual LUNs is terminated or
killed abruptly, there is a possibility that the cxlflash driver could hang
and deprive other operations on the adapter.

The release fop registered to be invoked on a context close, detaches every
LUN associated with the context. The underlying service to detach the LUN
assumes it has been called with the read semaphore held, and releases the
semaphore before any operation that could be time consuming.

When invoked without holding the read semaphore, an opportunity is created
for the semaphore's count to become negative when it is temporarily released
during one of these potential lengthy operations. This negative count
results in subsequent acquisition attempts taking forever, leading to the
hang.

To support the current design point of holding the semaphore on the ioctl()
paths, the release fop should acquire it before invoking any ioctl services.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/cxlflash/superpipe.c