From patchwork Fri Nov 15 12:36:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13876167 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 8ADB4D6DDF3 for ; Fri, 15 Nov 2024 12:37:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10ED66B0092; Fri, 15 Nov 2024 07:37:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E6136B0093; Fri, 15 Nov 2024 07:37:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D43126B0096; Fri, 15 Nov 2024 07:37:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A99B06B0092 for ; Fri, 15 Nov 2024 07:37:32 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5ACFB1A15F7 for ; Fri, 15 Nov 2024 12:37:32 +0000 (UTC) X-FDA: 82788278622.25.1263858 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf28.hostedemail.com (Postfix) with ESMTP id BF629C000A for ; Fri, 15 Nov 2024 12:36:42 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GutEOMx6; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Gw1PDfXA; spf=pass (imf28.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731674072; 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=0YO6r84z6d4rGgD1e8mQW4WUPkS0navErPTnR081+LE=; b=Q+OFIrO5xjlxlKb59mA3x5AsgYHL7gqlWoKxp25Jba556qps1IZVilHdMAKN3BgNRoxIlE p645ruvPOa2hOpRHUrZLVnIqL587ZJcoAD1YL+tNifTV6NMnvLgN6Lvpuxg93ZPWRqNKIi V5+4GrBnkbDo/3RMaXBlYwu6OurS2Bc= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GutEOMx6; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Gw1PDfXA; spf=pass (imf28.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1731674072; a=rsa-sha256; cv=pass; b=EipZZxm5XTREn3e3grbvGF2FV9Tar0KRrJK6FEKtf7vfNJweIdnrg1r0N/tQYWHUri/VIg fAxcz9QbWxsJmYSGBONKYAmR7xLL1V6/DXAxLO2C9RHEcImQ4BGKe56prcqANmuZi6HW5W nyvESYseTLD6YMszAkG/vle6+KwkbHk= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFAH4VP030282; Fri, 15 Nov 2024 12:37:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=0YO6r84z6d4rGgD1e8mQW4WUPkS0navErPTnR081+LE=; b= GutEOMx6MiSjMMA8ufsOVfF9BfPzNWusbZrMb/+3dF19/UrbEWV72tGoNfAGlzV4 QcMONCgpXzpEBipFjNO0y80sax/JxtJ1c1Bpu5s22ACH0fQTtp78RpXrxZmdgi0s huvhyC8a2rrzvHO8S/reAyU8e7wfYOggFrueQvzdf0HS1nh5uFbriu28dFxFWas/ cfi3jtx/Ll0N54mPRjt5hAvi0tDuuvaXpZ3dEHVCEUS1LR4f9b400t14I/pwulEU +gWsXht2JxTb5d9yjji/zI8fZtsDpPHDDmZ3nxiPWf5NdxBULCiE9vQWhHgdMIec f47IGbPoFw4J8rBkGmI+Gg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0n539t3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:37:14 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFAVLFM000376; Fri, 15 Nov 2024 12:37:12 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42tbpbjcxt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:37:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oV83LeQve76m8QAG/X8OqOiBRb8FJLeOuYXKq4JcMfNgDJtPXlf7CENWaXxZYK9a5fd2v9vyuoLlRR0CR5N+np8mQvjjKe2P1y4cz1Rdph6BVZya21KNQM7wP1Y4AkcEsW/x8Vi2pse/vtooZDpNETZd53cTg4hRkKQ0X51wmmBSpDsfRSvF8VbvXQQHElHfVnaewYcKQKMx0EZWIkiNi6I+a+4V8xwERj4iSGYBbmKwhz+ubjtw9JvSVV1lnli/BbOxH2EzcD9eQLkhi3GCVcGOVoQnirKrA0McpL/VRjfVILtpQCof23rQ/Zbk6DkAlvWOeVYohU/eHl6Wq6/Z9g== 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=0YO6r84z6d4rGgD1e8mQW4WUPkS0navErPTnR081+LE=; b=KZ6f1+AUGGlbM4FL5slrDDEcsVbq5eDYyfTz77AGlGyVQf+yPs5Wsm/2JzT7gRyRnBpj7MdJbYw6sxgYaDcDeNA99SXACIVgvq1tmY/ZowjJps0ajWzVlRzpy5sf633xs7sgTVq5nmqO+njoYGJMvtA3Qhv01s1NAVh6JIam5liq5Iai8rhPjsEAxJGCnuJ9WycOM2anmm3XPxmtBRkFzWNIhfMg20/LcWKZiieLdzF4UnGZdURziQABo+jKreEgPRuL30RYO9E4L2waOxyW4P8J/V6riboaWlCQn0YnzOYaIY8ejaZH8YTn8P+RtUFkSRfsCR/Mh3aRSHC8FVywdA== 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=0YO6r84z6d4rGgD1e8mQW4WUPkS0navErPTnR081+LE=; b=Gw1PDfXAa5WVCgPjLJ70KiTvE3FOn2WyIDCvoZcZuuIuv5ZU0MwHYuOg/F0hBJCo1uD2WWgTsNYiAKDIGb8ntwzBF6/HfAZPuNLUNU2WndZE68DWWcEuG2t0b+mMcgDZU8CqAHfpHpXSvafj5gPjXYnCEjdbZ1diRGQDYV6YeT4= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SA6PR10MB8136.namprd10.prod.outlook.com (2603:10b6:806:438::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Fri, 15 Nov 2024 12:37:07 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%7]) with mapi id 15.20.8137.027; Fri, 15 Nov 2024 12:37:07 +0000 From: Lorenzo Stoakes To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller Subject: [PATCH 5.10.y 2/4] mm: unconditionally close VMAs on error Date: Fri, 15 Nov 2024 12:36:52 +0000 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0450.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::30) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SA6PR10MB8136:EE_ X-MS-Office365-Filtering-Correlation-Id: 779c2df2-6419-4dde-1372-08dd057237aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: 2Wa/Pjh+MfjDfwQUMMLyVsHbUhLz1pOUhXQbgVN+SSqMREUJloiSRwkqCN/BJzAAM3ctpIZsPSbw6ws1MAGqC5tXbV/DdUKFQ22t5bYcjcRWJzveva7EUrLAWMj3Q3qjquSrR+4hCz2Oj7TYVdX6wEffF6dtsI+IN8ciA1ZjVozsZTndQYrvD58gNmtXYXuyKPqxucsmQMExiwM2jG9/uSJabrH+NKIYc8LP6m2o7M5nJI7ydxRJo5mv07hFF3ltDZTPo+1dggunW8ypKv32W7j9GLiSsKgtH+hdf0xQmxSyg+9e6leDc15MuDzZPx4/rpO1lSqvW9HmSL4qkjwbbrw8oclgaYXRNxnzFXIx/ttMIBHTFI71glff1COqeOwyUGA9wBooFZsVwjr4+hwor5bpnh6HTQ4oaRmaEK7IcctPaMPPif0j9Lb++kjFshu2vqCcpf+vl86pIs8I88YrEmBBibOZ/NHLbwwdVB0MK6fqzAPTMFFnfrdBWycc6edbQjKN3vfXUWssGd6NjCySQlgLxnGb9TpIuuKoJNp7PLOTCBdwCt/RNXMIxMeORZuoZwUgXcmlrWE0FC2AKTwzlt4nl58fvUFlUkdSJ4MjHTr2IFIez/mD+XGgl02XroNOVSCgY+tfW+4iTp6PA5/n1wQm+lPZdxXEbo2/+k2LXsLD565CK/8YY1eZsB23ZdyPK9uevVrCPvL6QDt5ETmAWYcI/Nr1C7P/rMSp1VD7XroFTy7704lzsWZv9PX74f5vX4QP60IbRf6XktNQOh7hcTjoM4kYmH5VF4SzSfeH8iTxrXB9+5by3JloVOLpuiTq5+4V/NKC79AowvZj4UKtwMcZOB7tDz9FudtlmnG8ButZ2g+A81s+JggWefyoEzuuFO5JmHmVY+v3WQF+iXY+yf/83uGqiz4OfTpSUHFP0kshFFTBG/a+/Cjb/FWKtNOYbunsu5n1s6DoXoHU+HZb+dvJnOLxKHRLs8eOeGV99lD7891lTOjW/Y7Y3BzzNdKw5G3/K28bOW1umen6eoE9WrEvKH+YOlpBkFe2wrJoy3QK+ez0kko8uLJ+DhCA/31Pa8/he4fC23PWw6FZ/V3jFmTvEMxAdKiiHvPWKb66eiJI1jim7Ns123Z7Gfv5hDwF4RGz3Sz8wTZTM8RAWTf8b4l9lvrpOTeAF79GCF5B9M5e3k9EkMr87gEdopLIbmGto85tnWJS/whqXXcZnBgv9shlqMGtZKGy6Nxu+uoO35BhlGMHplc/V5Zx7/zAST+O9OH39zb5EELrrbBLB+hmilkB8FOCWP1BSj5i0ifo47JqLyqZHyQWNsfCg1YS2Bg4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OkMk3R2T1ciZYzP7MRyZrra1fwbNAxZOS/TsABQyxgApC0F8v7MvQ2YC9BmvEPerRDuahe6h/hLJtnxv3I/eykC6OPDFEORQcOrrIi5MfEtI2Ujt5ESA2Mswuhw0oUmhE+SHtJARiBFg6L0dv1tV9iw1672uldjcgMJwEfMLPoD1TPenWQFZCNdavcV/xyZx1qINjrwKrOpeIg+4V98fjbLqnelgtm0Rctk14d+9oHe9w+n27mIUUpThm2ZF7uyVD5K5KnnrQOFGcZFC7Wb80F4WikkTE/Fv52SC0lDRk0wmobbWl8tgprsRu2qzo85EwkJgdwKcujUyvlax2BIfAQdEQf1V7eCyNV8OQHf2Y5//Fc+0OPLH+PRZ4T/i95E4Lh7ZMHQDq2ekirYl6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TJjwgXcNx8zhTO0fFa3WgreqQ/siIBPO1EQXtgsI2Ljib3ZsgotPuwx4Wiqyag0LG2cOLZbLLgFxs1Z/KKBTslsErcKiD7JOHOOf3iK4JVWIJIdDn43/naNVuhzqgDbis9tsvQfwX168ua9g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ogS0zrO7RWzStu6SGHNdXfKIXJto3uPVBzujEK7pPuKCMR6K9qL1nmzSGlARWGy4xAVYELnQ+5inZ59aHP2fRmhl4my2xFVE8r63ZoZfv1ythU9+CJxEL0+qEkgya4MHQyYb5sI4oIyMaA+yjWwYGw6lQmiUbbCCULn7L5hxNoxakd/fn+cQQPRhynSuYVfynQtglWH0YDjN/ppALJECs4D+zoyg1cU69TdNuv03aYEix+XQZtqPIXawxUp+hJXlhMNPqpG3BGYHRUguA9gZNqh3PT+WF8lxlrcKyDIRwk+ak1MGVnciKyYCOeDds2qJz457w7RlvciTU3Qu1OgKpN6alDyH3KccusnRst+skpswRZsNA+Ns5aZpyHXBepUQ01hJBIqr5D/fVZUTgoi5/0cenwW+ozZ5gRwJ7eo8DzdlrP2xMekMqtazDAtSGUrciOhBD1npcOM6KvqIZfMEkKp5UZ0/ZN6pd6YC766WnhHv2lFVPa1gjSNEZUlXSnI3DpA2IRxCIeIaGnEFALta4Kd2s7MrKRXpqqix1f9LqSITtB3hS4del9jaJwHhMu3oqo9IdDxw2z1L8lS0O+uf6hrFjlEIB4yZlq/U3hMYZ0Q= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 779c2df2-6419-4dde-1372-08dd057237aa X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 12:37:07.7142 (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: bA3sNcqbSpzyFa67M1I6eC/KDnN72Ds6ansCWnXMejIEbj7Xatk6Cof7ey1UxHNwX6wTFu6ROatf714V4242tOF1FbS/dvWcHGYSfY+eLbw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA6PR10MB8136 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-14_05,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411150108 X-Proofpoint-ORIG-GUID: 8N0rPsEK10oZH9mlXBsUAiJLJpU5ohVg X-Proofpoint-GUID: 8N0rPsEK10oZH9mlXBsUAiJLJpU5ohVg X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BF629C000A X-Stat-Signature: 4rh3tdx4hx16j6my6za1sq118g3zmf68 X-Rspam-User: X-HE-Tag: 1731674202-398931 X-HE-Meta: U2FsdGVkX1+MCU+0y3nVilAnVNK3Bm69ARboya3mrFMjUxKmddPoPJhO05gq5edP22+r3G7TxOnNH4y51tQYq09hL/0owP0ctmid/YoESCX9HA9L5jCrGtibxk95xRTZDNNRJa+VjJpw0NKCRiyqON71a87dPhmxAJfQVhiokTZzPRoILIEC4AoCyEZQlsSaqrTSGBlno3mpKIpNogfSgs0unsnLogBQZbr4Xm4owZ0Ytn7zMc8HKyg5j7TRoREdbcYtN2lKIteP574hbJ5bqheqW+5X/3OjtA7nQaslAnmRcOqfaC9rwop3v45wpbucL6RemnBMJQCuQjoqUhypx/3riiGjqbzy0sLMOG/5qxZ9JiEYs4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xfEnrSTNEaTpVoPOUYMtdwPVsWDrjo/3MalksD2Y68rzbZBlPwO1f42Ssi7Xh9qMEYK0KFgkckFvNwMelBM9KFphhqH6E16DeafnBlpc4S5ZqzPgY76YvY2BVQn+qlx8G76wP5UZn0Bj15DadZ1MJ1x0VjX5lepfJIJdJYAxA9dbkXN31qN8rVBuj8JvxhrSXydTnLyWY7hVcY12NynMQalP2kqMSrhUqDCGUUUlPaoCAlADmZ4XTz0kRp2nEaggE2vao8wN4OHObRspdT9mmwHlQJH2YCdNiNCsqZu536pzQmFAoUFdwV56hDFYMBhLY8bjDcDpcdvF9+sl7E+7bxElO582B0+iOmuLoW30mOJQONDjqeK36y5XY5hEJSFFu4HX5BS9riPRV3+s3xUOFaEjV92szKLoryO2gCfEP63P2RjRfxBrCwJLh2ffCNBfiKbLAtUr/XPYDOUqjl7dY4AEas4qoisP+4YZfKyV/wv+uV1rEJpugx/mbkOVFuqdRK37cjqnCks+ 30YnnuL/ 92T85XeKRKQ/YVr+0R/YABa+fVOQ6mWljK/tubx+/gQ= 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: [ Upstream commit 4080ef1579b2413435413988d14ac8c68e4d42c8 ] Incorrect invocation of VMA callbacks when the VMA is no longer in a consistent state is bug prone and risky to perform. With regards to the important vm_ops->close() callback We have gone to great lengths to try to track whether or not we ought to close VMAs. Rather than doing so and risking making a mistake somewhere, instead unconditionally close and reset vma->vm_ops to an empty dummy operations set with a NULL .close operator. We introduce a new function to do so - vma_close() - and simplify existing vms logic which tracked whether we needed to close or not. This simplifies the logic, avoids incorrect double-calling of the .close() callback and allows us to update error paths to simply call vma_close() unconditionally - making VMA closure idempotent. Link: https://lkml.kernel.org/r/28e89dda96f68c505cb6f8e9fc9b57c3e9f74b42.1730224667.git.lorenzo.stoakes@oracle.com Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails") Signed-off-by: Lorenzo Stoakes Reported-by: Jann Horn Reviewed-by: Vlastimil Babka Reviewed-by: Liam R. Howlett Reviewed-by: Jann Horn Cc: Andreas Larsson Cc: Catalin Marinas Cc: David S. Miller Cc: Helge Deller Cc: James E.J. Bottomley Cc: Linus Torvalds Cc: Mark Brown Cc: Peter Xu Cc: Will Deacon Cc: Signed-off-by: Andrew Morton Signed-off-by: Lorenzo Stoakes --- mm/internal.h | 7 +++++++ mm/mmap.c | 9 +++------ mm/nommu.c | 3 +-- mm/util.c | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index e47f112a63d3..df2b1156ef65 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -46,6 +46,13 @@ void page_writeback_init(void); */ int mmap_file(struct file *file, struct vm_area_struct *vma); +/* + * If the VMA has a close hook then close it, and since closing it might leave + * it in an inconsistent state which makes the use of any hooks suspect, clear + * them down by installing dummy empty hooks. + */ +void vma_close(struct vm_area_struct *vma); + vm_fault_t do_swap_page(struct vm_fault *vmf); void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma, diff --git a/mm/mmap.c b/mm/mmap.c index f4eac5a95d64..ac1517a96066 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -176,8 +176,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) struct vm_area_struct *next = vma->vm_next; might_sleep(); - if (vma->vm_ops && vma->vm_ops->close) - vma->vm_ops->close(vma); + vma_close(vma); if (vma->vm_file) fput(vma->vm_file); mpol_put(vma_policy(vma)); @@ -1901,8 +1900,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return addr; close_and_free_vma: - if (vma->vm_ops && vma->vm_ops->close) - vma->vm_ops->close(vma); + vma_close(vma); unmap_and_free_vma: vma->vm_file = NULL; fput(file); @@ -2788,8 +2786,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, return 0; /* Clean everything up if vma_adjust failed. */ - if (new->vm_ops && new->vm_ops->close) - new->vm_ops->close(new); + vma_close(new); if (new->vm_file) fput(new->vm_file); unlink_anon_vmas(new); diff --git a/mm/nommu.c b/mm/nommu.c index fdacc3d119c3..f46a883e93e4 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -662,8 +662,7 @@ static void delete_vma_from_mm(struct vm_area_struct *vma) */ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) { - if (vma->vm_ops && vma->vm_ops->close) - vma->vm_ops->close(vma); + vma_close(vma); if (vma->vm_file) fput(vma->vm_file); put_nommu_region(vma->vm_region); diff --git a/mm/util.c b/mm/util.c index 8e5bd2c9f4b4..9e0c86555adf 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1091,3 +1091,18 @@ int mmap_file(struct file *file, struct vm_area_struct *vma) return err; } + +void vma_close(struct vm_area_struct *vma) +{ + static const struct vm_operations_struct dummy_vm_ops = {}; + + if (vma->vm_ops && vma->vm_ops->close) { + vma->vm_ops->close(vma); + + /* + * The mapping is in an inconsistent state, and no further hooks + * may be invoked upon it. + */ + vma->vm_ops = &dummy_vm_ops; + } +}