[Devel] [PATCH RHEL COMMIT] ve/binfmt_misc: destroy all nodes on ve stop
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Oct 4 20:39:02 MSK 2021
The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit c5a380bac686e9c670fb3db132075fe37f5b58b4
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date: Mon Oct 4 20:39:02 2021 +0300
ve/binfmt_misc: destroy all nodes on ve stop
Patchset description:
zap sb->s_ns + fix memleak in binfmt_misc
Vladimir Davydov (6):
binfmt_misc: do not use sb->s_fs_info
Revert "VE/VFS: use sb->s_ns member to store namespace for mount_ns()
calls"
Revert "ve/sunrpc: use correct pointer to net_namespace in auth_gss.c"
Revert "nfsd/sunrpc/mqueue: use sb->s_ns instead of data in
fill_super"
binfmt_misc: do not use s_ns
binfmt_misc: destroy all nodes on ve stop
https://jira.sw.ru/browse/PSBM-39154
Reviewed-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
======================
This patch description:
Each registered binfmt_misc node pins binfmt_misc mount point, which in
turn pins the owner ve. This means that if we don't clean up binfmt_misc
nodes on ve stop, the mount point as well as the ve struct will leak.
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
(cherry-picked from commit a018c0f03fa1d072e0970d31b5c5f57be5c2cdb5)
Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
(cherry picked from vz8 commit 99728e0f8de999d45ffb6d4f87ab0fad353997be)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
fs/binfmt_misc.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index da0dfe22095c..628d4fc2db94 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -909,16 +909,42 @@ static struct file_system_type bm_fs_type = {
};
MODULE_ALIAS_FS("binfmt_misc");
+static void ve_binfmt_fini(void *data)
+{
+ struct ve_struct *ve = data;
+ struct binfmt_misc *bm_data = ve->binfmt_misc;
+
+ if (!bm_data)
+ return;
+
+ /*
+ * XXX: Note we don't take any locks here. This is safe as long as
+ * nobody uses binfmt_misc outside the owner ve.
+ */
+ while (!list_empty(&bm_data->entries))
+ kill_node(bm_data, list_first_entry(
+ &bm_data->entries, Node, list));
+}
+
+static struct ve_hook ve_binfmt_hook = {
+ .fini = ve_binfmt_fini,
+ .priority = HOOK_PRIO_DEFAULT,
+ .owner = THIS_MODULE,
+};
+
static int __init init_misc_binfmt(void)
{
int err = register_filesystem(&bm_fs_type);
- if (!err)
+ if (!err) {
insert_binfmt(&misc_format);
+ ve_hook_register(VE_SS_CHAIN, &ve_binfmt_hook);
+ }
return err;
}
static void __exit exit_misc_binfmt(void)
{
+ ve_hook_unregister(&ve_binfmt_hook);
unregister_binfmt(&misc_format);
unregister_filesystem(&bm_fs_type);
}
More information about the Devel
mailing list