[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87h8wsudx8.fsf@concordia.ellerman.id.au>
Date: Mon, 28 Aug 2017 21:31:15 +1000
From: Michael Ellerman <mpe@...erman.id.au>
To: Al Viro <viro@...IV.linux.org.uk>,
Paul Mackerras <paulus@...abs.org>
Cc: Nixiaoming <nixiaoming@...wei.com>,
David Hildenbrand <david@...hat.com>,
"agraf\@suse.com" <agraf@...e.com>,
"pbonzini\@redhat.com" <pbonzini@...hat.com>,
"rkrcmar\@redhat.com" <rkrcmar@...hat.com>,
"benh\@kernel.crashing.org" <benh@...nel.crashing.org>,
"kvm-ppc\@vger.kernel.org" <kvm-ppc@...r.kernel.org>,
"kvm\@vger.kernel.org" <kvm@...r.kernel.org>,
"linuxppc-dev\@lists.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce
Al Viro <viro@...IV.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
Powered by blists - more mailing lists