On Mon, Oct 02, 2023 at 09:40:15AM +0300, Amir Goldstein wrote: > On Mon, Oct 2, 2023 at 5:37 AM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > > > > ovl_permission() accesses ->layers[...].mnt; we can't have ->layers > > freed without an RCU delay on fs shutdown. Fortunately, kern_unmount_array() > > used to drop those mounts does include an RCU delay, so freeing is > > delayed; unfortunately, the array passed to kern_unmount_array() is > > formed by mangling ->layers contents and that happens without any > > delays. > > > > Use a separate array instead; local if we have a few layers, > > kmalloc'ed if there's a lot of them. If allocation fails, > > fall back to kern_unmount() for individual mounts; it's > > not a fast path by any stretch of imagination. > > If that is the case, then having 3 different code paths seems > quite an excessive over optimization... > > I think there is a better way - > layout the mounts array linearly in ofs->mounts[] to begin with, > remove .mnt out of ovl_layer and use ofs->mounts[layer->idx] to > get to a layer's mount. > > I can try to write this patch to see how it ends up looking. Fine by me; about the only problem I see is the cache footprint... How many layers do you consider the normal use, actually?