public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH gmem FIXUP] kvm: guestmem: do not use a file system
Date: Mon, 9 Oct 2023 14:26:36 -0700	[thread overview]
Message-ID: <ZSRwDItBbsn2IfWl@google.com> (raw)
In-Reply-To: <20231009204037.GK800259@ZenIV>

On Mon, Oct 09, 2023, Al Viro wrote:
> On Mon, Oct 09, 2023 at 01:20:06PM -0700, Sean Christopherson wrote:
> > On Mon, Oct 09, 2023, Al Viro wrote:
> > > On Mon, Oct 09, 2023 at 07:32:48AM -0700, Sean Christopherson wrote:
> > > 
> > > > Yeah, we found that out the hard way.  Is using the "secure" variant to get a
> > > > per-file inode a sane approach, or is that abuse that's going to bite us too?
> > > > 
> > > > 	/*
> > > > 	 * Use the so called "secure" variant, which creates a unique inode
> > > > 	 * instead of reusing a single inode.  Each guest_memfd instance needs
> > > > 	 * its own inode to track the size, flags, etc.
> > > > 	 */
> > > > 	file = anon_inode_getfile_secure(anon_name, &kvm_gmem_fops, gmem,
> > > > 					 O_RDWR, NULL);
> > > 
> > > Umm...  Is there any chance that your call site will ever be in a module?
> > > If not, you are probably OK with that variant.
> > 
> > Yes, this code can be compiled as a module.  I assume there issues with the inode
> > outliving the module?
> 
> The entire file, actually...  If you are using that mechanism in a module, you
> need to initialize kvm_gmem_fops.owner to THIS_MODULE; AFAICS, you don't have
> that done.

Ah, that's handled indirectly handled by a chain of refcounted objects.  Every
VM that KVM creates gets a reference to the module, and each guest_memfd instance
gets a reference to its owning VM.

Thanks much for the help!

  reply	other threads:[~2023-10-09 21:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 18:06 [PATCH gmem FIXUP] kvm: guestmem: do not use a file system Paolo Bonzini
2023-09-29  2:22 ` Sean Christopherson
2023-10-09  2:22   ` Al Viro
2023-10-09  2:35     ` Al Viro
2023-10-09 14:32     ` Sean Christopherson
2023-10-09 20:06       ` Al Viro
2023-10-09 20:20         ` Sean Christopherson
2023-10-09 20:40           ` Al Viro
2023-10-09 21:26             ` Sean Christopherson [this message]
2023-10-10  0:09               ` Al Viro
2023-10-10  0:27                 ` Sean Christopherson
2023-10-10  0:37                   ` Al Viro
2023-10-10 23:30                     ` Sean Christopherson
2023-10-11 15:06                       ` Xu Yilun
2023-10-11 17:57                       ` Paolo Bonzini
2023-10-13 16:55                         ` Sean Christopherson
2023-10-16 15:19                           ` Paolo Bonzini
2023-10-09  2:16 ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZSRwDItBbsn2IfWl@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox