[Devel] [PATCH vz10] fs/kernfs, ve: pin the VE that mounted a kernfs instance

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Sep 29 12:06:37 MSK 2026


> kernfs_get_tree() stores a bare get_exec_env() pointer in
> kernfs_super_info, and since commit 8d1abf587552 ("fs/kernfs, ve:
> hide entries from a VE without invalidating the dentry")
> kernfs_dop_revalidate() compares it against the caller's VE to decide
> between dropping the dentry and answering -ENOENT. Nothing backs that
> pointer with a reference: if the mount is pinned from outside - the
> host bind-mounted a Container's sysfs, or holds an fd inside it - the
> superblock outlives the Container, info->ve dangles, and a later
> Container whose ve_struct is allocated at the same address is mistaken
> for the creator of the instance. Its lookups then take the
> d_invalidate() path on the dead instance and detach the mounts placed
> on top of it.
> 
> Take a css reference on the VE for the lifetime of the superblock, so
> the comparison always names the VE that really created the instance.

This race of ve pointer reused and superblock being given to other ve
(the one which reused the pointer) is supper low probability. Each new
ve will get its own netns and thus it's own sysfs sb, it wont ever look
on the old ve superblock and thus on this stale matching ve pointer.

So practically we can avoid extra reference to ve here, as an Admin
giving old ve kernfs superblock to a new ve is not realy our usecase and
only breaks sysfs visibility.

Except that looks good.

Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

-- 
Pavel Tikhomirov <ptikhomirov at virtuozzo.com>


More information about the Devel mailing list