Re: [PATCH gmem FIXUP] kvm: guestmem: do not use a file system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux