Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6964399ybc; Thu, 28 Nov 2019 08:26:29 -0800 (PST) X-Google-Smtp-Source: APXvYqw4eaof20Y5s3r0EibYxV0jl4ym8S+63XKBtowA87nO62B0vcWyGZ6oF9TywhsJQrqCILFO X-Received: by 2002:a17:906:4019:: with SMTP id v25mr56888366ejj.11.1574958389087; Thu, 28 Nov 2019 08:26:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574958389; cv=none; d=google.com; s=arc-20160816; b=YDPXqxB3oxma2nxa0eGS14mqEHP3RKX+DvAgLzOYW60Liu6L+7ofULiWSx7DWi1r4t 1Jozi3IR6BROtaeRCcehgG54EGl/KgIy1HVqQHsij8sd3yMvrtV5BZlfzsaRUBvV2cLg Rr2JTkvhDyxGALZ5p7NwUT84ESbLIqvVFpDvNIY+UTxUIMxhWbzckbcnXzJknNfNMysM BdcSS16+OMGlVqNi6zLigP1oLO8w1BhrJRXWhHCEfHuftmttpZ6CFKWqeQc7orocgW8H z0QRY9Vy1NowObGDn20un9zqetsIRJGmcZ8umH1Mkz1xkbq/tgKvEFbvr0mebsbQTXtj oVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=TW6IjVlnc9Fm2QDZlaIzSHN7lFlpr6nIs27nZppi450=; b=b4PWqc9973IapVUXkFSMxoGmnJzUki6f25rnZeePbJevzJuXzkA4lMuvO1sl566IKa Oj6g9NzBQ5pc2KYrKGOZrmkXIbqnp9PgNpZW2AI/43RvfPUfAh4Fd9keCREoWrcsmv86 5QNsO5nkZL1LZ343XWC8K6ELhFHGCBdOoydtENVIAppVwlPDS1mfakE9L6dN7XQKTTAw KVw+RKZa5Q+27N0Ue1uIZ4mfcI2fLJ/I/pFPMDqxIGT3yqBjhG7rTTG1id0DMjoiFSev ugrGkwLNNGBVWCDwDGTsndPv2PhqLqHnvGUWb1KKrqEGuD+Jk2koKo+ooUVRH/PVjv3k 3BHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cz11si12488628edb.155.2019.11.28.08.26.05; Thu, 28 Nov 2019 08:26:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbfK1QYt (ORCPT + 99 others); Thu, 28 Nov 2019 11:24:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58674 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726446AbfK1QYs (ORCPT ); Thu, 28 Nov 2019 11:24:48 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xASGGZWH019825; Thu, 28 Nov 2019 11:24:31 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wjf1v5y8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Nov 2019 11:24:31 -0500 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id xASGGuJw021288; Thu, 28 Nov 2019 11:24:31 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wjf1v5y86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Nov 2019 11:24:31 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id xASGMjB2032468; Thu, 28 Nov 2019 16:24:30 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma03dal.us.ibm.com with ESMTP id 2wevd7ame2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Nov 2019 16:24:30 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xASGOT6B30081516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2019 16:24:29 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5722D7805E; Thu, 28 Nov 2019 16:24:29 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C5437805F; Thu, 28 Nov 2019 16:24:27 +0000 (GMT) Received: from leobras.br.ibm.com (unknown [9.18.235.137]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 28 Nov 2019 16:24:27 +0000 (GMT) Message-ID: <5789f26ca5568f05b9554053a1c6c3309d5c36e8.camel@linux.ibm.com> Subject: Re: [PATCH 1/1] powerpc/kvm/book3s: Fixes possible 'use after release' of kvm From: Leonardo Bras To: Paul Mackerras Cc: Sean Christopherson , kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Benjamin Herrenschmidt , Michael Ellerman , Paolo Bonzini , Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?= Date: Thu, 28 Nov 2019 13:24:22 -0300 In-Reply-To: <20191127225747.GA2317@blackberry> References: <20191126175212.377171-1-leonardo@linux.ibm.com> <20191127225747.GA2317@blackberry> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-PNohgKkP6BiPP+29h/le" User-Agent: Evolution 3.34.1 (3.34.1-1.fc31) MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-28_05:2019-11-28,2019-11-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 spamscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=2 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911280136 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-PNohgKkP6BiPP+29h/le Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2019-11-28 at 09:57 +1100, Paul Mackerras wrote: > There isn't a potential use-after-free here. We are relying on the > property that the release function (kvm_vm_release) cannot be called > in parallel with this function. The reason is that this function > (kvm_vm_ioctl_create_spapr_tce) is handling an ioctl on a kvm VM file > descriptor. That means that a userspace process has the file > descriptor still open. The code that implements the close() system > call makes sure that no thread is still executing inside any system > call that is using the same file descriptor before calling the file > descriptor's release function (in this case, kvm_vm_release). That > means that this kvm_put_kvm() call here cannot make the reference > count go to zero. That was very informative. A lot of things are clear to me now. Thanks for explaining this Paul.=20 Best regards, Leonardo --=-PNohgKkP6BiPP+29h/le Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEMdeUgIzgjf6YmUyOlQYWtz9SttQFAl3f9LYACgkQlQYWtz9S ttTuFRAAzklmvK/yrMAbKL0SscgkU2u5KsQ6td7bys4CpwCyjrFvMpPEhTscVF6l oJ/MuPcpEikVISnJTdqpbnyRp3fyZE105GBKP1LN5aXp+1HxT4DZHggSwuQg0THh 9dce2RIjBaa+dUtLlFselG4xWBkJoUzVM1yNpvxhNLJGc52+mCmDmUeA3icT/NoY uKVtuOBfE7/UK94AhuBUkvVoUNGMPmLof+czvZPIuVc8Vprga3cXIpjLT2lw8Stk nKriyJO0/MVDTEU6mcqUYRfHUW2c2SAeae3AGz0HiXfPX3ar0Xl+wCd8vX+yO07S QmkWlKnvyBQi7WSHwg54xtbPDQBxig0PwOrG2OTDlZDuWT3PfGvYy9q2C5FOABcH xgxe4fas0u1dw/MY/JKo/DnJBq7L+aIu2faQDCRV6E/BI6s7t84nkEqALxQAmDvK uGPEtt2L/5Y/V9h78kJG501Xfz0TESuSfa9dTlOkUTvgKz0MCogTJFVI5wgPGYS+ PK9aGMCRNzggyNprKsy+V76fvWy5LyR4L1ZfvToSVpTkd3kXV6prD2oRH2hYuVTX +MGhuqMf56WNUug++Yc82DAHTNJAwMpAs9nOwK7xoOwIs+4t5di4PdjK1KjwFhlO SIDljErVyer2WdJSIvW+CaUczw8qlrx4qqus8ffqI/Jnf64fZPQ= =hQv1 -----END PGP SIGNATURE----- --=-PNohgKkP6BiPP+29h/le--