From: Paolo Bonzini Date: Wed, 27 Nov 2019 18:32:32 +0000 Subject: Re: [PATCH] KVM: Add separate helper for putting borrowed reference to kvm Message-Id: <6beeff56-7676-5dfd-a578-1732730f8963@redhat.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="ffsTa9Xe2Ee0ZdRuXdoWLUmRFeQM2p1Zu" List-Id: References: <20191021225842.23941-1-sean.j.christopherson@intel.com> <20191126171416.GA22233@linux.intel.com> <0009c6c1bb635098fa68cb6db6414634555039fe.camel@linux.ibm.com> In-Reply-To: To: Leonardo Bras , Sean Christopherson Cc: Paul Mackerras , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ffsTa9Xe2Ee0ZdRuXdoWLUmRFeQM2p1Zu Content-Type: multipart/mixed; boundary="aqZUHOq3nlK4WoWx9AL9jxCe3XQdlu06R" --aqZUHOq3nlK4WoWx9AL9jxCe3XQdlu06R Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 27/11/19 19:24, Leonardo Bras wrote: > By what I could undestand up to now, these functions that use borrowed > references can only be called while the reference (file descriptor) > exists.=20 > So, suppose these threads, where: > - T1 uses a borrowed reference, and=20 > - T2 is releasing the reference (close, release): Nit: T2 is releasing the *last* reference (as implied by your reference to close/release). >=20 > T1=09=09=09=09| T2 > kvm_get_kvm()=09=09=09| > ...=09=09=09=09| kvm_put_kvm() > kvm_put_kvm_no_destroy()=09| >=20 > The above would not trigger a use-after-free bug, but will cause a > memory leak. Is my above understanding right? Yes, this is correct. Paolo --aqZUHOq3nlK4WoWx9AL9jxCe3XQdlu06R-- --ffsTa9Xe2Ee0ZdRuXdoWLUmRFeQM2p1Zu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAl3ewUAACgkQv/vSX3jH roNHAwf/V5jw3UuEAUr+qwFRt1WbZT7kDY6RcpqwfR7drS3cV9JoPkLaa/vuvUnj TvZG7Q2ZVR0m2JALj914WOuC5pmAYy8HVawrFbooQ4T5mtc2akQzVD0eshLankPo RZjfY2ijPzfY+tajHzQJ09U9Rzc33YvOZGmao/zV8/QXtFQokF1549ZJQyZPTVM0 cgiRO5mVfl0/IbchPvczCrgXIT0P4Ca9w+BN7xn1+HFGO8rvUtwaG5ZxVhUfk58B LArJb8NkIGNDdoh3DF27nHNXak0C95hD1ENiPKVK6RrEkr/wJc6ffOS8eAdUu5yl WmgTspYVIA7RjqLbTwLXHOQwKrvG7A== =Shjy -----END PGP SIGNATURE----- --ffsTa9Xe2Ee0ZdRuXdoWLUmRFeQM2p1Zu--