From patchwork Thu Aug 22 19:25:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13774118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A545EC3DA4A for ; Thu, 22 Aug 2024 19:27:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4456F6B0143; Thu, 22 Aug 2024 15:26:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CC988004F; Thu, 22 Aug 2024 15:26:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 185A66B0208; Thu, 22 Aug 2024 15:26:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E1CA46B0143 for ; Thu, 22 Aug 2024 15:26:54 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9FCC21C3483 for ; Thu, 22 Aug 2024 19:26:54 +0000 (UTC) X-FDA: 82480863948.13.9E0ED3F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 4FCC98000B for ; Thu, 22 Aug 2024 19:26:51 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AWYXOXwt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uSMO7MVO; spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724354703; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b=lyTvWZkLAKARq7Vo0lMZM3+3r/O91Oi9xuOS/YCMN3ILvOKi8pa35ZOa1DMrw+i835ZZV8 XZA/3yBXkR7bk0ShP+O7hCQqvTBbZFUewAJcMmaF9KswOsVtxFbWzb6n30jeO4axUEdAvF rTljEiIWHhrLRImu6EvHrgtHPrTlD0U= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AWYXOXwt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uSMO7MVO; spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354703; a=rsa-sha256; cv=pass; b=bIpk6Sa4gcgXZPZQ5zOx2/sC5R1cKjif9nqhNOo5fFFjNNdjivXPSc5NFgX0Ux586kaDWJ ahKChLgOR03IhDZb5wMm66DZE5FuxzNHSQi5qCwSfM2gUEBj2zUmmUS2BqWlsLNzeuUoX4 XLY8qL3xkJUwylTiaOfQ6KacpiGy+3k= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MIMWZZ026341; Thu, 22 Aug 2024 19:26:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b= AWYXOXwtcwa/oPvCiQWRg7oPYBPF5QX2rb2x12UPjET1DPQPE6tI2H9J0T/mrj6c 3H5y0jXlShWrNqdQNz4JBQkf8EiTtkFOp/tn1GMnqO4I2aNbvUEYdpLjlY0neyTZ SQWceC3+lS5eNhR5TPs0CDKKxaNJtGMxNDYrL2B6FSlwQ90P7O+2clF1JYFE1jLw g7IWygBwoskfQmJgYANaX90hEvFmEzHWzvNUadOTUS6KTZjC1fBOO7tTlhGd90f7 aBrBqpHYJhR3DcmK2B4SBW+MFNs3oa5877aowBcCCExO/KVrV31TVuUDIPdNT0qt NtLDLuVaTxFh0BjkRLm+WQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4v2wa2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:43 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJJGAK028263; Thu, 22 Aug 2024 19:26:43 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bct87sx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=plmq3VUVrJRCD8HI0Ty1JLfa2jrog+NTZIpo9qEUpMsSFwQOQTxH++T4RWpYhzLA2RQhWuE2f+kWpaCZ5oxDl1brUs7ZPqQRDlgk3iNEphNGvPwyK6M1K6Iy7QSEkCag/RstKHXN6OnIId2V+VkkDzjyM3zCHm9i+cAs2zWjTLX9cnC6SJUbJGwDo5QBWJ1K9kZkDTq48PxYP6CxD3G/3h+8q/pEXIKdNsQuv396YkcrZ7qgS+O98zth3rqDZb01VTUMktZzO1h83CkqThdDFD+nTZ5GS5eGpuTA0nfJPhrwiAoDoJZAJ4wx3YCy+By0z2a5TabPOYZXdrf5eSvguA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b=tK+hCrVZ9ik0DVkxBDcIA7BeCwzDwyJBX8zzSf7sPiYAlz+CsHSH0h4uAgMqkoNSLYdzk9yuUI5s2JYVqYGmWnNrXC/9ycO8ztDChQIuNjI0TlMYCUG2aB5zRQrLQWj6r4k67HCYPrcTZqkT2vvV+W0DXytqX9yMUkL5H6mGkjdeCR6RR4Ez6BPyLR5xHEc9UU7lrLqZTAgbcVygkI2fm+Yse36UpIsWmOdIbljclKP3UwVlokAYYV3fKSAkqKt16lVIzg5ar6ldFtdCJ6R7NeaybNKbMzK9lzVtiMok3PKuTcL+fsDz/nZmsoQGcvsJnEVrcQwok0hFq6Q5OdRV3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b=uSMO7MVOAYf1FGZNGPiiB/lbHpRnPlKaTfhIwJqlxrRjKhIdikWmcM16XiD6Lri+fbcOYAZ6sRykPFSqWobdpxV+//HhQovJdSkjQP5FWyvsOxEl62pRokpgZZ9WsRVmiB+tkMEmXvneT8tfl/6yFPnlWnSWOsFOoIPeoH0GB2M= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:38 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 19:26:38 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" Subject: [PATCH v7 15/21] mm: Change failure of MAP_FIXED to restoring the gap on failure Date: Thu, 22 Aug 2024 15:25:37 -0400 Message-ID: <20240822192543.3359552-16-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::13) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 57581fdd-0d88-45fa-21cc-08dcc2e05795 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: CpCtepK9bkSLT3PwkCq7o7yb3+mxs7b+XxMfGtT42wy6SqexosZEbf4Pr2ScHD5LbA1luF7MHno5mEdfSXCF2CRtjrrlNf7Zzpr+w3JgfkJ6kSyTMEfaJ2CcEYIpqtBfCaq7MGgxybj/vBe4b238HdfoiMDqY8WaYqTnYdxcj1QJynfjzCp60vRkb4h06Sa+MziYrNTy3Atouk3pNCXmRaKpnp3bDB4Vc3NRXroqWrM7BuLJMMobyC6zK/4h1AJv+6zBB6e2kg/AUdmVxXhxuDX/5mIQJ0nozlCpBzaslvfKsJp7QYpLAVV2No3rea5HFvDH6+ViPUdw4A37zuiWikCUNzi6R1inEEh2hvjKosRtANfRYtooRmLRRfFUK5To6We+YIRpk8kHbX09s5l0C9sYRCSYRtbxFeWiPWYhal9HojR2NlLtw/TAhc8CrgsUl4sFXQ7RCIXOBNIVaZIqhfM/v3hOjA6zvxlmwgNP6N1lGDXbmKQNefWbXQR1OvlnjzKciprXy2EflPmjpurMX+VAMFVc9kmX2Nn8tyRvNw7qFMKVH1MrBNWqemOKdcQ5vOUuTymHIZjjmtYF24ByuP+IzR8YcVDECMXbSXXBcHmRkSP0Aa8t9ekFh7kqS1omVBCK/Mw7Ib0yoe+eopFrFjVxRAHSZ/YirFnhb6to7CE+aVhFTe5dvAujn90uuwXUtvEjOx8kIrTmid1MgeeV2jBogZsC/vbVUO1UhzfVCGy7jYGRl/aECWwmdUubStYecuLzcLa52ccNX2XmG75mSIdPS44oeCJoC+ShJa2Mvf33b+aoV0l8RFeKddTAfBNuxsI5h6mooStKR8YnuRaD5EYn3U5KMdlUMIg2XMybONr1qsBggKnCHG2P5lM8weRQK+phAK6J8dnQ5IUPeTYpVBheTvAtHUQpyws8kC3NZ5Gcn0EAr8aOhYF68yEvfEE3v6Z5Rshmoh9Pj5zjg0/TkXTD/BJthU2aFxHfCq+TAriZCbjik+20feoWL5u/4+hV8D/BH1lxqizo1rcf1gov5tGInnxhbwc7gGrYLHC+0EaMaw/EI0yXjx9a6h8tydRoYHDXA3IC1hP/8rHX6Ue+KnoQIU6zxLkerRnGyb8AvM2+fg4vWUwCEB4brfgpiOVAqYqydA3wFhZ8xX2SILqLUvapprIrSyu9d1MnyDX7RVCVS0wFDCbI1rBqSe0JZC3jzQBwaK/5/dPd8aE+I24wJe+pUEOzTNwsmiZAAB1AQeWPk/a5+TVYbv3A9VciPTg/lMTOisYs5CJJ0J/iqLflSa8Krqe0FF2xpiY4Xelwnp0D6UB0PkgeU3uKR0sp/hMgGxFY4axL0vU2jks/8ODBDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OU8q14i5FdYt8lsuES22JZX38MDgXIaGT8v+ahiIzjn/5kNTYnT+rJbTwZGgXlZfgXMtv4so4J12jIl05bWFBPX4s0eRzqkDeBswLqcYB4pgCG4liQ3LqjBXnw7cH5y4nVxzfSdbmdWH6lFC1vtUr9pB70wMG/yzI6ytE1SOfaxX0mUh6BFi9itYt67b3I9SHE0Qfnjtycv5y1cRznnyT3dtLkavEauTE1lM+ShxJGs56WO8ShPMZ94rzpNQz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EqCIYztVZQrU0kqa4IbJIlatbvyNUrEw8f2iQa6qYdH3WIZs/tTc8zS6LWDMTK7QBTWrg0gMY8hSTb3aiMCsizi3ozKkQ4b21a4p4uzGno78bU/7yPiDBsdJbbYfDTeZEcNiQQvO+i936cLyXopbAzh2kAm1JyLjikCgjYIIFd6NKW/ZaS+d2X/lclz+dIPko03TnPjGoYYUy+9mD4APvFpwl37ggiGRddDiIBa6uMY+jsrBYRTpQyKurWNHFymI1PE7f4j+xakquEzqXO0+0jxKdyXw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 42vEWhJ9kcjTlPez7aP61r/0bLOszU9+oWu+LkfUx5+mumOVVzZ/O5YIsE5mUiEmMIBDslJCFl9znfAsFY0CwbhL14fB2/9DrXWihLGPW1Q3XH+aGOrTn/KC0zHYcWhFuiVkxKi80QmDHzghAaqGYXMXLCG0LQmYXzIei0n4nC3pMdSbpJCSfttoeT0ieLYY7kj9/SiWkTLp44OaD0VZTgRTxVSHW0EUWH1srfZKOUwx9HAuIiKu9ajJB0cfBIOnDU55kPu+TmAbsn7nB6rZbaeNGT8RkV04hSOYqtv+rIeirl9k+17M+hAVe+yHKeYEUu4P8gZfJvn5GCP1DnX1t08SSWbOOwNOKv62en2o51rIBJcvqaL/nvTLwcNrYH5cpts3NYzddC6O9Kl9eGy8laIGCWNgQU7Ok+Xl3y+sB12p+yKy1vDiAtTcG4XZRJgEQlvz4hRIQSy32kSkPPPltgAJO3M5eghXBhhwqmW6YdEK564PrDVHyjfIRInXHUtrkLAU88Cf3LNt/KlNKxTKe9Qui25ZDWYpAbkK9fuw5iFDcqUtAE2NB4X3DSV71ZXlgh5IJGjU5lusGtjJUBcERGybhW60CQST8biIPyaS6lM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57581fdd-0d88-45fa-21cc-08dcc2e05795 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:37.9639 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rb0TTYoLKo4wr8wOPmfYzMlSr2YRDr4Sm6Ss6JYLp2kQs+EGFOuIM74DYbnbkqW+g1XTDpPNSV6azLPOTHNzOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: 172SnK5gjyVSOoobUO6vUBRuQDIcSWNi X-Proofpoint-GUID: 172SnK5gjyVSOoobUO6vUBRuQDIcSWNi X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4FCC98000B X-Stat-Signature: ci8fw33xb8umu7e1ijfr6q1tc7q8f6ze X-Rspam-User: X-HE-Tag: 1724354811-416524 X-HE-Meta: U2FsdGVkX1+gyAcBsGMLyrW5SCWEABQej96i4rVs0TbTf2WFT0suV16fKaZdy4uNytfNnqIpVBDDS+oOOpxqcpxZInfo4j/WYbu882toIKGQ4323qA3YGdCl/0ykfRLWyre6V59haNb2iPGtSM966trvoITmmUfopzr9FMzM2AjmpnXimeYZcgQckcjMoVv5y+JlKa/R6Zv5NJkuwqMLhuiShVsUwPCAhLIdzfL0HRu8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+ABMeKVGP2S+y7kQZEM/JnbIuvS5PABEBNPjOG9NM4fXTZ1sWxPiasLE3fuu4iqWN3N5SviN14FB0sdnZss7Ssp0pUo9OeREJv4ttr9R4AShYtjhmOuqR+k3ElMCYf4lyFk+9/dWbUjBleQ2xL2mjIepGvjmpVt1aifqcFi80mEhlxMBrZjfSuVlfapCqvx/d2LhoN2YnnOQN+l75+ObAtiS148Q3e+RY8BHLq1+667n4QRaW5nr9wc= 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: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Prior to call_mmap(), the vmas that will be replaced need to clear the way for what may happen in the call_mmap(). This clean up work includes clearing the ptes and calling the close() vm_ops. Some users do more setup than can be restored by calling the vm_ops open() function. It is safer to store the gap in the vma tree in these cases. That is to say that the failure scenario that existed before the MAP_FIXED gap exposure is restored as it is safer than trying to undo a partial mapping. Since abort_munmap_vmas() is only reattaching vmas with this change, the function is renamed to reattach_vmas(). There is also a secondary failure that may occur if there is not enough memory to store the gap. In this case, the vmas are reattached and resources freed. If the system cannot complete the call_mmap() and fails to allocate with GFP_KERNEL, then the system will print a warning about the failure. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 3 +-- mm/vma.c | 4 +-- mm/vma.h | 78 +++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 6550d9470d3a..217da37ef71d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1622,8 +1622,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_unacct_memory(charged); abort_munmap: - if (vms.nr_pages) - abort_munmap_vmas(&mas_detach, vms.closed_vm_ops); + vms_abort_munmap_vmas(&vms, &mas_detach); validate_mm(mm); return error; } diff --git a/mm/vma.c b/mm/vma.c index 3715c5c17ab3..8dc60dcb6e8d 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -883,7 +883,7 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, munmap_gather_failed: end_split_failed: modify_vma_failed: - abort_munmap_vmas(mas_detach, /* closed = */ false); + reattach_vmas(mas_detach); start_split_failed: map_count_exceeded: return error; @@ -928,7 +928,7 @@ int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; clear_tree_failed: - abort_munmap_vmas(&mas_detach, /* closed = */ false); + reattach_vmas(&mas_detach); gather_failed: validate_mm(mm); return error; diff --git a/mm/vma.h b/mm/vma.h index 756dd42a6ec4..f710812482a1 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -82,6 +82,22 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, unsigned long start, unsigned long end, pgoff_t pgoff); +static inline int vma_iter_store_gfp(struct vma_iterator *vmi, + struct vm_area_struct *vma, gfp_t gfp) + +{ + if (vmi->mas.status != ma_start && + ((vmi->mas.index > vma->vm_start) || (vmi->mas.last < vma->vm_start))) + vma_iter_invalidate(vmi); + + __mas_set_range(&vmi->mas, vma->vm_start, vma->vm_end - 1); + mas_store_gfp(&vmi->mas, vma, gfp); + if (unlikely(mas_is_err(&vmi->mas))) + return -ENOMEM; + + return 0; +} + /* * init_vma_munmap() - Initializer wrapper for vma_munmap_struct * @vms: The vma munmap struct @@ -127,24 +143,58 @@ void vms_clean_up_area(struct vma_munmap_struct *vms, struct ma_state *mas_detach, bool mm_wr_locked); /* - * abort_munmap_vmas - Undo any munmap work and free resources + * reattach_vmas() - Undo any munmap work and free resources + * @mas_detach: The maple state with the detached maple tree * * Reattach any detached vmas and free up the maple tree used to track the vmas. */ -static inline void abort_munmap_vmas(struct ma_state *mas_detach, bool closed) +static inline void reattach_vmas(struct ma_state *mas_detach) { struct vm_area_struct *vma; mas_set(mas_detach, 0); - mas_for_each(mas_detach, vma, ULONG_MAX) { + mas_for_each(mas_detach, vma, ULONG_MAX) vma_mark_detached(vma, false); - if (closed && vma->vm_ops && vma->vm_ops->open) - vma->vm_ops->open(vma); - } __mt_destroy(mas_detach->tree); } +/* + * vms_abort_munmap_vmas() - Undo as much as possible from an aborted munmap() + * operation. + * @vms: The vma unmap structure + * @mas_detach: The maple state with the detached maple tree + * + * Reattach any detached vmas, free up the maple tree used to track the vmas. + * If that's not possible because the ptes are cleared (and vm_ops->closed() may + * have been called), then a NULL is written over the vmas and the vmas are + * removed (munmap() completed). + */ +static inline void vms_abort_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach) +{ + if (!vms->nr_pages) + return; + + if (vms->clear_ptes) + return reattach_vmas(mas_detach); + + /* + * Aborting cannot just call the vm_ops open() because they are often + * not symmetrical and state data has been lost. Resort to the old + * failure method of leaving a gap where the MAP_FIXED mapping failed. + */ + if (unlikely(vma_iter_store_gfp(vms->vmi, NULL, GFP_KERNEL))) { + pr_warn_once("%s: (%d) Unable to abort munmap() operation\n", + current->comm, current->pid); + /* Leaving vmas detached and in-tree may hamper recovery */ + reattach_vmas(mas_detach); + } else { + /* Clean up the insertion of unfortunate the gap */ + vms_complete_munmap_vmas(vms, mas_detach); + } +} + int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, @@ -297,22 +347,6 @@ static inline struct vm_area_struct *vma_prev_limit(struct vma_iterator *vmi, return mas_prev(&vmi->mas, min); } -static inline int vma_iter_store_gfp(struct vma_iterator *vmi, - struct vm_area_struct *vma, gfp_t gfp) -{ - if (vmi->mas.status != ma_start && - ((vmi->mas.index > vma->vm_start) || (vmi->mas.last < vma->vm_start))) - vma_iter_invalidate(vmi); - - __mas_set_range(&vmi->mas, vma->vm_start, vma->vm_end - 1); - mas_store_gfp(&vmi->mas, vma, gfp); - if (unlikely(mas_is_err(&vmi->mas))) - return -ENOMEM; - - return 0; -} - - /* * These three helpers classifies VMAs for virtual memory accounting. */