Re: [PATCH] mount: Fix race in loop device reuse code

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

 



On Thu 20-01-22 22:46:57, Tetsuo Handa wrote:
> On 2022/01/20 20:47, Jan Kara wrote:
> > Fix the problem by rechecking that loop device is still attached after
> > opening the device. This makes sure the kernel will not autoclear the
> > device anymore.
> 
> Since this block is marked as /* overlap -- full size and offset match
> (reuse) */ , can just checking that neither loopcxt_get_fd() nor
> loopcxt_get_info() failed guarantee that full size and offset still
> match? Isn't there possibility that autoclear of file1 completes and
> another thread again assigns file2 (with different size or offset) right
> before /* Open loop device to block device autoclear... */ line? Don't we
> need to compare with more robust identifier like device:inode pair?

I was considering that as well (even had it coded in an early version) but
then decided agaist it. The underlying file, offset, size can change even
while you have the loop device open (through LOOP_CHANGE_FD,
LOOP_SET_STATUS, ...). So checking after having the loop device open is no
better than checking before and I could not come up with realistic scenario
where checking later would significantly help.

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux