lkml.org 
[lkml]   [2023]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH gmem FIXUP] kvm: guestmem: do not use a file system
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.

\
 
 \ /
  Last update: 2023-10-09 04:18    [W:2.100 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site