From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58524C388F7 for ; Wed, 4 Nov 2020 09:41:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2F6220679 for ; Wed, 4 Nov 2020 09:41:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="scOIzNnk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2F6220679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7B9EB6B0036; Wed, 4 Nov 2020 04:41:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 769416B005D; Wed, 4 Nov 2020 04:41:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60BC36B0068; Wed, 4 Nov 2020 04:41:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 347C06B0036 for ; Wed, 4 Nov 2020 04:41:55 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D265E181AC9CC for ; Wed, 4 Nov 2020 09:41:54 +0000 (UTC) X-FDA: 77446244148.22.lamp48_1d09d55272c0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id A373818038E67 for ; Wed, 4 Nov 2020 09:41:54 +0000 (UTC) X-HE-Tag: lamp48_1d09d55272c0 X-Filterd-Recvd-Size: 7086 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Nov 2020 09:41:53 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A4933w4023583; Wed, 4 Nov 2020 04:41:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=zdRbraW1F2GIaa1UV8CaG7ZHN3GkfsDk51ocD6Ao0uA=; b=scOIzNnkJXQfwShsDUxhQ5uolcyuMOX8cG+RIERaFDl98wAsBZ5YsPlEimw+C77IhP+3 Oxjc/hGOVfGXMUlFC3rSBijUJ0Bf3N20AoPaJXPcOhZxxp/bKXfaMTsSadZxHWLOH4VW WOVYV6Vij642VqSpywYqAtPyZ3SgJksEQAVj3K9SFih/EShyg+wk4o7ogVqdT54G6iDa BD/UTHIUprNrcyFTJPsmoVX65dja9uyD1pU1neWCrM/myXumIf4oZ5PVlshrKL+1tOzk SZiXW30GxvFexGVVloC/kPSADyUfXOPJaOLPRz9TjUluiH4AsZMtOT+d3Tmue/0iPVzT dQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 34kqdana48-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Nov 2020 04:41:38 -0500 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0A494B4g028017; Wed, 4 Nov 2020 04:41:38 -0500 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 34kqdana3g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Nov 2020 04:41:37 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A49Qceh031125; Wed, 4 Nov 2020 09:41:35 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 34h01uc0wh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Nov 2020 09:41:35 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A49fXSr3408582 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Nov 2020 09:41:33 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3181311C04C; Wed, 4 Nov 2020 09:41:33 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95A4311C052; Wed, 4 Nov 2020 09:41:32 +0000 (GMT) Received: from pomme.local (unknown [9.145.163.138]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Nov 2020 09:41:32 +0000 (GMT) Subject: Re: [PATCH] x86/mpx: fix recursive munmap() corruption To: Dmitry Safonov <0x7f454c46@gmail.com>, Christophe Leroy , Michael Ellerman Cc: Dave Hansen , Thomas Gleixner , Dave Hansen , mhocko@suse.com, rguenther@suse.de, x86@kernel.org, LKML , stable@vger.kernel.org, luto@amacapital.net, linux-mm@kvack.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, vbabka@suse.cz References: <20190401141549.3F4721FE@viggo.jf.intel.com> <87d0lht1c0.fsf@concordia.ellerman.id.au> <6718ede2-1fcb-1a8f-a116-250eef6416c7@linux.vnet.ibm.com> <4f43d4d4-832d-37bc-be7f-da0da735bbec@intel.com> <4e1bbb14-e14f-8643-2072-17b4cdef5326@linux.vnet.ibm.com> <87k1faa2i0.fsf@concordia.ellerman.id.au> <9c2b2826-4083-fc9c-5a4d-c101858dd560@linux.vnet.ibm.com> <12313ba8-75b5-d44d-dbc0-0bf2c87dfb59@csgroup.eu> <452b347c-0a86-c710-16ba-5a98c12a47e3@linux.vnet.ibm.com> <02389b9c-141c-f5b7-756a-516599063766@gmail.com> From: Laurent Dufour Message-ID: <3d93d41c-24fb-d24e-53f1-9dcb5c8d6394@linux.vnet.ibm.com> Date: Wed, 4 Nov 2020 10:41:32 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <02389b9c-141c-f5b7-756a-516599063766@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-04_06:2020-11-04,2020-11-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 malwarescore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011040068 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Le 03/11/2020 =C3=A0 22:08, Dmitry Safonov a =C3=A9crit=C2=A0: > Hi Laurent, Christophe, Michael, all, >=20 > On 11/3/20 5:11 PM, Laurent Dufour wrote: >> Le 23/10/2020 =C3=A0 14:28, Christophe Leroy a =C3=A9crit=C2=A0: > [..] >>>>> That seems like it would work for CRIU and make sense in general? >>>> >>>> Sorry for the late answer, yes this would make more sense. >>>> >>>> Here is a patch doing that. >>>> >>> >>> In your patch, the test seems overkill: >>> >>> +=C2=A0=C2=A0=C2=A0 if ((start <=3D vdso_base && vdso_end <=3D end) |= |=C2=A0 /* 1=C2=A0=C2=A0 */ >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (vdso_base <=3D start && = start < vdso_end) || /* 3,4 */ >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (vdso_base < end && end <= =3D vdso_end))=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* 2,3 */ >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mm->context.vdso_base =3D= mm->context.vdso_end =3D 0; >>> >>> What about >>> >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (start < vdso_end && vdso_start < e= nd) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mm->context.vdso_ba= se =3D mm->context.vdso_end =3D 0; >>> >>> This should cover all cases, or am I missing something ? >>> >>> >>> And do we really need to store vdso_end in the context ? >>> I think it should be possible to re-calculate it: the size of the VDS= O >>> should be (&vdso32_end - &vdso32_start) + PAGE_SIZE for 32 bits VDSO, >>> and (&vdso64_end - &vdso64_start) + PAGE_SIZE for the 64 bits VDSO. >> >> Thanks Christophe for the advise. >> >> That is covering all the cases, and indeed is similar to the Michael's >> proposal I missed last year. >> >> I'll send a patch fixing this issue following your proposal. >=20 > It's probably not necessary anymore. I've sent patches [1], currently i= n > akpm, the last one forbids splitting of vm_special_mapping. > So, a user is able munmap() or mremap() vdso as a whole, but not partly= . Hi Dmitry, That's a good thing too, but I think my patch is still valid in the Power= PC=20 code, fixing a bad check, even if some corner cases are handled earlier i= n the code. > [1]: > https://lore.kernel.org/linux-mm/20201013013416.390574-1-dima@arista.co= m/ >=20 > Thanks, > Dmitry >=20