Re: Race in ovl_copy_up()?

From: Miklos Szeredi
Date: Tue Aug 12 2014 - 05:37:24 EST


On Mon, Aug 11, 2014 at 4:37 PM, David Howells <dhowells@xxxxxxxxxx> wrote:

> In the for-loop in the middle, if you ascend any levels at all, how are you
> protected from racing with copy-ups taking place on those more rootwards
> dentries?
>
> I can see ovl_copy_up_one() using lock_rename() on the workdir and upperdir,
> but there's no relevant lock on the overlayfs fs.

Locking upperdir should be enough protection.

Lets say we have a race:

A: copy_up(a/b/c/d)
B: copy_up(a/b/e/f)

Both ascend to "b" and try to lock "a". The one that wins the lock
acquisition will do the copy-up, the other one will just skip it once
it gets the lock.

Thanks,
Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/