Re: [PATCH 5/8] loop: only take lo_mutex for the first reference in lo_open

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

 



On 2022/01/27 19:28, Jan Kara wrote:
> So this also relies on disk->open_mutex for correctness. Otherwise a race
> like:
> 
> Thread1			Thread2
> lo_open()
>   if (atomic_inc_return(&lo->lo_refcnt) > 1)
>   mutex_lock_killable(&lo->lo_mutex);
> 			lo_open()
> 			if (atomic_inc_return(&lo->lo_refcnt) > 1)
> 			  return 0;
>   ..
> 
> can result in Thread2 using the loop device before Thread1 actually did the
> "first open" checks. So perhaps one common comment for lo_open + lo_release
> explaining the locking?

Please see https://lkml.kernel.org/r/7bebf860-2415-7eb6-55a1-47dc4439d9e9@xxxxxxxxxxxxxxxxxxx .



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux