Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4266009ybb; Tue, 7 Apr 2020 04:11:53 -0700 (PDT) X-Google-Smtp-Source: APiQypKfdgkDbBl6lHNLPqvVxPDUftXG7y6VomJfVwHoxzuyuafABCOp/3j+YJIehXGaUkYtykl6 X-Received: by 2002:a9d:3b8b:: with SMTP id k11mr1022830otc.245.1586257912953; Tue, 07 Apr 2020 04:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586257912; cv=none; d=google.com; s=arc-20160816; b=RHPoOwUsnAh4zXZKcxpz+nlkq61KA4Jz0XiKeCkRHdomDJKLzHMuYiRVLVO4331Shy dl4BWt/ZZZrapAPZqpUYLGGI5xc0vQaxwnJYth6GI7HpMG0xACEn0IZM9HDZLtt8akUJ U3Bi/NtjWSw+/eG+IlK+ajlI5k+nRARnWIkgCmVchLNZPbQB5qma0t/AfpVjiypQiriF sJg5yct0oeAjdb7NyiQGwEjg4BYHzi81hXnVrzX8hXaoOoY9q5v+nEY38jgjTqNi3XnD fOgjQKtgtNowRslpGeg0dQ424iqlMB0B83jwRnmmc4bam/U2aL1KX6PjQlkhLy61x4+w t1HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:organization:references:in-reply-to:subject:cc:to:from :date; bh=MyDlWZ9srk3UkAUw0dt/ZSk9YA8HcdBUWJuqIvqVeU0=; b=nozudVIh+ICUbrpXrdZ1I/H6J0OOtNLV9yh07diteKBzcYL6sZyKWsRGbcyxjrFHNn DT0y3tqx3xbxVrtCSKGsk4+ze0Zga6q9l7qGijcSY7ehaVth7vi4xsGpYMxE3SjtZpL9 RrmmmXCGaI11rS/d8sAQG9OCQTfs3sXkO2nLe186JnewOd2IHPxrYH6vz+r9S5itNtxP OmSO+ETottuQbA4F9OenBvLGF27MCeztNS/KYCQtB+j1K3ZrnWA5fWvHpKG+dpY+qFx6 ieWc0GOW0SyvX83mCn49mdLZ+2LjUjn6BSikmL5iXC7Lgra72w1N1h1y/MR9+76e7KrW /3Ew== 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 u7si1167190oth.8.2020.04.07.04.11.40; Tue, 07 Apr 2020 04:11:52 -0700 (PDT) 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 S1728483AbgDGLK5 (ORCPT + 99 others); Tue, 7 Apr 2020 07:10:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54452 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728333AbgDGLKw (ORCPT ); Tue, 7 Apr 2020 07:10:52 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 037B4imE108346 for ; Tue, 7 Apr 2020 07:10:51 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 3082j8mv1g-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 07 Apr 2020 07:10:51 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Apr 2020 12:10:22 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 7 Apr 2020 12:10:19 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 037BAio653936380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Apr 2020 11:10:44 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CA03A4054; Tue, 7 Apr 2020 11:10:44 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00ACEA4060; Tue, 7 Apr 2020 11:10:44 +0000 (GMT) Received: from p-imbrenda (unknown [9.145.8.150]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 7 Apr 2020 11:10:43 +0000 (GMT) Date: Tue, 7 Apr 2020 13:05:22 +0200 From: Claudio Imbrenda To: David Hildenbrand Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Vasily Gorbik , Heiko Carstens , Cornelia Huck , Janosch Frank , Christian Borntraeger Subject: Re: [PATCH v2 3/5] KVM: s390: vsie: Fix possible race when shadowing region 3 tables In-Reply-To: <20200403153050.20569-4-david@redhat.com> References: <20200403153050.20569-1-david@redhat.com> <20200403153050.20569-4-david@redhat.com> Organization: IBM X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20040711-0020-0000-0000-000003C33E85 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20040711-0021-0000-0000-0000221BFC1A Message-Id: <20200407130522.189a9a3f@p-imbrenda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-07_03:2020-04-07,2020-04-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 malwarescore=0 suspectscore=2 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004070095 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 3 Apr 2020 17:30:48 +0200 David Hildenbrand wrote: > We have to properly retry again by returning -EINVAL immediately in > case somebody else instantiated the table concurrently. We missed to > add the goto in this function only. The code now matches the other, > similar shadowing functions. > > We are overwriting an existing region 2 table entry. All allocated > pages are added to the crst_list to be freed later, so they are not > lost forever. However, when unshadowing the region 2 table, we > wouldn't trigger unshadowing of the original shadowed region 3 table > that we replaced. It would get unshadowed when the original region 3 > table is modified. As it's not connected to the page table hierarchy > anymore, it's not going to get used anymore. However, for a limited > time, this page table will stick around, so it's in some sense a > temporary memory leak. > > Identified by manual code inspection. I don't think this classifies as > stable material. > > Fixes: 998f637cc4b9 ("s390/mm: avoid races on region/segment/page > table shadowing") Signed-off-by: David Hildenbrand > --- > arch/s390/mm/gmap.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c > index b93dd54b234a..24ef30fb0833 100644 > --- a/arch/s390/mm/gmap.c > +++ b/arch/s390/mm/gmap.c > @@ -1844,6 +1844,7 @@ int gmap_shadow_r3t(struct gmap *sg, unsigned > long saddr, unsigned long r3t, goto out_free; > } else if (*table & _REGION_ENTRY_ORIGIN) { > rc = -EAGAIN; /* Race with shadow */ > + goto out_free; > } > crst_table_init(s_r3t, _REGION3_ENTRY_EMPTY); > /* mark as invalid as long as the parent table is not > protected */ Reviewed-by: Claudio Imbrenda