@@ -1431,8 +1431,15 @@ static struct file_system_type mqueue_fs_type = {
int mq_init_ns(struct ipc_namespace *ns)
{
- struct mqueue_fs_context *ctx;
- struct fs_context *fc;
+ struct mqueue_fs_context ctx = {
+ .fc.ops = &mqueue_fs_context_ops,
+ .fc.fs_type = &mqueue_fs_type,
+ .fc.cred = current_cred(),
+ .fc.user_ns = current_user_ns(),
+ .fc.purpose = FS_CONTEXT_FOR_NEW,
+ .ipc_ns = ns,
+ };
+ struct super_block *sb;
struct vfsmount *mnt;
int ret;
@@ -1443,29 +1450,32 @@ int mq_init_ns(struct ipc_namespace *ns)
ns->mq_msg_default = DFLT_MSG;
ns->mq_msgsize_default = DFLT_MSGSIZE;
- fc = vfs_new_fs_context(&mqueue_fs_type, NULL, 0, FS_CONTEXT_FOR_NEW);
- if (IS_ERR(fc))
- return PTR_ERR(fc);
-
- ctx = container_of(fc, struct mqueue_fs_context, fc);
- put_ipc_ns(ctx->ipc_ns);
- ctx->ipc_ns = get_ipc_ns(ns);
+ ret = security_fs_context_alloc(&ctx.fc, NULL);
+ if (ret < 0)
+ return ret;
- ret = vfs_get_tree(fc);
+ ret = vfs_get_tree(&ctx.fc);
if (ret < 0)
goto out_fc;
- mnt = kern_mount_data_fc(fc);
+ mnt = kern_mount_data_fc(&ctx.fc);
if (IS_ERR(mnt)) {
ret = PTR_ERR(mnt);
- goto out_fc;
+ goto out_root;
}
ns->mq_mnt = mnt;
ret = 0;
out_fc:
- put_fs_context(fc);
+ security_fs_context_free(&ctx.fc);
return ret;
+
+out_root:
+ sb = ctx.fc.root->d_sb;
+ dput(ctx.fc.root);
+ ctx.fc.root = NULL;
+ deactivate_super(sb);
+ goto out_fc;
}
void mq_clear_sbinfo(struct ipc_namespace *ns)