mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Al Viro <viro@ZenIV.linux.org.uk>, Paul Mackerras <paulus@ozlabs.org>
Cc: Nixiaoming <nixiaoming@huawei.com>,
	David Hildenbrand <david@redhat.com>,
	"agraf\@suse.com" <agraf@suse.com>,
	"pbonzini\@redhat.com" <pbonzini@redhat.com>,
	"rkrcmar\@redhat.com" <rkrcmar@redhat.com>,
	"benh\@kernel.crashing.org" <benh@kernel.crashing.org>,
	"kvm-ppc\@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
	"kvm\@vger.kernel.org" <kvm@vger.kernel.org>,
	"linuxppc-dev\@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce
Date: Mon, 28 Aug 2017 21:31:15 +1000	[thread overview]
Message-ID: <87h8wsudx8.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20170828052808.GH5426@ZenIV.linux.org.uk>

Al Viro <viro@ZenIV.linux.org.uk> writes:

> On Mon, Aug 28, 2017 at 02:38:37PM +1000, Paul Mackerras wrote:
>> On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote:
>> > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote:
>> > 
>> > > It seems to me that it would be better to do the anon_inode_getfd()
>> > > call before the kvm_get_kvm() call, and go to the fail label if it
>> > > fails.
>> > 
>> > And what happens if another thread does close() on the (guessed) fd?
>> 
>> Chaos ensues, but mostly because we don't have proper mutual exclusion
>> on the modifications to the list.  I'll add a mutex_lock/unlock to
>> kvm_spapr_tce_release() and move the anon_inode_getfd() call inside
>> the mutex.
>> 
>> It looks like the other possible uses of the fd (mmap, and passing it
>> as a parameter to the KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE ioctl on a KVM
>> device fd) are safe.
>
> Frankly, it's a lot saner to have "no failure points past anon_inode_getfd()"
> policy...

Actually I thought that was a hard rule. But I don't see it documented
or mentioned anywhere so I'm not sure now why I thought that.

cheers

      parent reply	other threads:[~2017-08-28 11:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 14:28 nixiaoming
2017-08-22 15:15 ` David Hildenbrand
2017-08-22 15:23   ` David Hildenbrand
2017-08-23  1:43     ` Nixiaoming
2017-08-23  6:06       ` Paul Mackerras
2017-08-23  8:25         ` David Hildenbrand
2017-08-23  9:16           ` David Hildenbrand
2017-08-23 10:17           ` 答复: " Nixiaoming
2017-08-24  1:06           ` Nixiaoming
2017-08-27 21:02         ` Al Viro
2017-08-28  4:38           ` Paul Mackerras
2017-08-28  5:28             ` Al Viro
2017-08-28  6:06               ` Paul Mackerras
2017-08-28 11:31               ` Michael Ellerman [this message]

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=87h8wsudx8.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=agraf@suse.com \
    --cc=benh@kernel.crashing.org \
    --cc=david@redhat.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nixiaoming@huawei.com \
    --cc=paulus@ozlabs.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@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

all inboxes | Powered by JetHome®