Re: [PATCH 5/8] Prevent AUTOCLEAR detach race

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

 



On Tue, Aug 02, 2016 at 07:58:29PM +0200, Stanislav Brabec wrote:
> Kernel needs some time to delete a device after losetup --detach. If the losetup
> --find is called just after losetup --delete, it can sometimes attempt to
> recycle the device that is just being released. To prevent this race,
> clear the AUTOCLEAR flag of the device.
> 
> Signed-off-by: Stanislav Brabec <sbrabec@xxxxxxx>
> ---
>  sys-utils/losetup.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
> index 28cde2b..ba096fe 100644
> --- a/sys-utils/losetup.c
> +++ b/sys-utils/losetup.c
> @@ -720,6 +720,12 @@ int main(int argc, char **argv)
>  				/* We found a device to recycle. Do not check
>  				 * for conflict. If it is conflicting, then
>  				 * user was already warned in past. */
> +				lc.info.lo_flags &= !LO_FLAGS_AUTOCLEAR;
> +				if (loopcxt_set_status(&lc)) {
> +					loopcxt_deinit(&lc);
> +					errx(EXIT_FAILURE, _("%s: failed to re-use loop device"),
> +					      loopcxt_get_device(&lc));
> +				}

This is strange, what if the device we want to reuse has been created
by mount(8) and AUTOCLEAR flag is wanted.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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