On Thu, Sep 28, 2023 at 02:06:51PM -0400, Paolo Bonzini wrote: > Use a run-of-the-mill anonymous inode, there is nothing useful > being provided by kvm_gmem_fs. > - inode = alloc_anon_inode(mnt->mnt_sb); > - if (IS_ERR(inode)) > - return PTR_ERR(inode); > + fd = get_unused_fd_flags(0); > + if (fd < 0) > + return fd; > > - err = security_inode_init_security_anon(inode, &qname, NULL); > - if (err) > - goto err_inode; > + gmem = kzalloc(sizeof(*gmem), GFP_KERNEL); > + if (!gmem) { > + err = -ENOMEM; > + goto err_fd; > + } > + > + file = anon_inode_getfile(anon_name, &kvm_gmem_fops, gmem, > + O_RDWR); > + inode = file->f_inode; > + WARN_ON(file->f_mapping != inode->i_mapping); > > inode->i_private = (void *)(unsigned long)flags; > inode->i_op = &kvm_gmem_iops; That's very badly broken. The whole point of anon_inode_getfile() is that *ALL* resulting files share the same inode. You are not allowed to modify the damn thing.