Re: [PATCH v2 04/30] cxlflash: Fix potential oops following LUN removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Sep 21, 2015, at 7:11 AM, Tomas Henzl <thenzl@xxxxxxxxxx> wrote:
> On 16.9.2015 23:27, Matthew R. Ochs wrote:
>> When a LUN is removed, the sdev that is associated with the LUN
>> remains intact until its reference count drops to 0. In order
>> to prevent an sdev from being removed while a context is still
>> associated with it, obtain an additional reference per-context
>> for each LUN attached to the context.
>> 
>> This resolves a potential Oops in the release handler when a
>> dealing with a LUN that has already been removed.
>> 
>> Signed-off-by: Matthew R. Ochs <mrochs@xxxxxxxxxxxxxxxxxx>
>> Signed-off-by: Manoj N. Kumar <manoj@xxxxxxxxxxxxxxxxxx>
>> Suggested-by: Brian King <brking@xxxxxxxxxxxxxxxxxx>
>> ---
>> drivers/scsi/cxlflash/superpipe.c | 36 ++++++++++++++++++++++++------------
>> 1 file changed, 24 insertions(+), 12 deletions(-)
>> 
>> diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
>> index fa513ba..1fa4af6 100644
>> --- a/drivers/scsi/cxlflash/superpipe.c
>> +++ b/drivers/scsi/cxlflash/superpipe.c
>> @@ -880,6 +880,9 @@ static int _cxlflash_disk_detach(struct scsi_device *sdev,
>> 			sys_close(lfd);
>> 	}
>> 
>> +	/* Release the sdev reference that bound this LUN to the context */
>> +	scsi_device_put(sdev);
>> +
> 
> I'm not sure here with the use if scsi_device_get+put, also I don't quite well
> understand what you are going to fix here and how can it happen.
> The scsi_device_get takes an additional module reference, so if used from
> a module it shouldn't be held for a long time.

The issue here is that the user context needs to be bound to the device so that
in the event that device goes away, it doesn't completely go away until the user
context is done using it. Without it, it is possible to crash when the context is
being freed.

Essentially this is the same as incrementing the count when an open is performed
on the device. The device can be removed (and is hidden upon doing so) but is
not actually freed until the reference is resolved (close()).

> Is it possible for a user to rmmod the czlflash module
> after the disk attach function is called?

Not while a user is present.


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux