From patchwork Fri Nov 15 12:38:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13876175 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 1059FD6DDF3 for ; Fri, 15 Nov 2024 12:39:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FFFD6B009D; Fri, 15 Nov 2024 07:39:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AE616B009E; Fri, 15 Nov 2024 07:39:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B3276B009F; Fri, 15 Nov 2024 07:39:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 46EF16B009D for ; Fri, 15 Nov 2024 07:39:01 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 115ABA143E for ; Fri, 15 Nov 2024 12:39:01 +0000 (UTC) X-FDA: 82788282318.25.9D59553 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf16.hostedemail.com (Postfix) with ESMTP id 7F4CF180015 for ; Fri, 15 Nov 2024 12:38:12 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="X/DDeoNm"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=A6MdOwnY; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; 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=1731674280; 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=2hzJyGd7ND7ALeuDMST/ER3oYgX4pWOPUyctcPhuIyI=; b=zxv4SrHsMP6rEEN/0nUSLqx2mvMS0kr/vpqxzeJU6MgD5I3bFNWarSAPXgxS3wI1X+4sJz AhW+cP+aMUIMD/2KOOQ5yIWvniEf6+h0zs8Ld1y3i7nKQUduA+roM7Rq5mstazaxbA6jNi LMZbQk54jDRArQ27oQiL30aZOeabi/0= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1731674280; a=rsa-sha256; cv=pass; b=34S4tpgeaOqh4Tt3h+Hj0TPcWSiIlF9eANmyqzCI6MDGQ8Lb1Lw5Zs10T+PXzxWc4Jfy0Z p2l7D9BUx0QDeteYYupWjN0pK8wtwMIL59mxS8Hfo5Rb0rrvnOcNYANnw/bfIqZfu9FHcX zwr7Kmq1xPZTjQvZW1fIonVvOG/q3XA= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="X/DDeoNm"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=A6MdOwnY; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFAHJXb000670; Fri, 15 Nov 2024 12:38:44 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=2hzJyGd7ND7ALeuDMST/ER3oYgX4pWOPUyctcPhuIyI=; b= X/DDeoNmCV/yVvjp+KNdjE4YqXBAdXO/F4h3u9GT7jNtMDnVFFAzF+en9m7zT7KS RYLXKd3EQjxsafCTFY4DO5Yu7jGn45UunTbGnGsEHP6rVdlbrSpTrFblWIQjmMNM giTceEUgK95vTYePN9hpAgpP1TMtvWGDV6Lt61yDdtfPwqF/IGWt1tBbOHnrwmLm VNQgo6n2/cM4nDIqAmIEDXClG/VhJJHgnO/gg3ozdPS0/jWWoCg3d0SdxfMrv3no Ec74smptQ7DXc0+wK3sDh21ZsDURQlNm1F3ZnB0Scd0/se0Mr2FMtP48uCgpFbRI 3gncWvrWmbZOdjZrESkmIA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0mbkd8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:38:43 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFCSLMg005652; Fri, 15 Nov 2024 12:38:42 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6ckrk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:38:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i7jJplQw2gPo/LTrXjn/aTsnSlZ77TjLpaDn5g1Suoebb+idack3BygnEbtc8Jq0PDoK/lY19YYtIHUubwHyqxTJk5fRR+9+M6YpEgS5wkZkMZ/1eCUQQ69+0B4iU3L6kzEEZp13b1IhqaYyKV3f89xRXBGioMd4Jyi/cYHspK0kKEtG3gu84DZqc/9u4SJqqmJxsP24IdIaz+HU0D6IJnUk+wvWW1SU1U4fZDzUZmjD1/zuopMWQzg1bEZ/Wlcz/XPcULNtjwdDItilgl9iHemrkMUff+VNV5cpQB6ycq7zPcFAyGRMrGsVr0igGyYlK9wzkPi5X4rFkZn+0aZz8w== 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=2hzJyGd7ND7ALeuDMST/ER3oYgX4pWOPUyctcPhuIyI=; b=cgQgaU55ZrRKhinXW7HhxrtLUu1ENynQyVjzxcJr+W2hpIAS0ajHGv+LN/UuN6Ojp5ELZ0gwwi/wc6L1fpmiTmlgGCzfP+/1lvLoCizGcNUj9prMjaxrfWHKqEX6tikokPslEWFUUufYYBRdvlELE5T9dh4Iycad0lje9eL1dwgqJPyi5/WMGH7PcNmR3HYXJ3NewyEaOoBN4qnUd/wNgLrSElW5M6KRBeGttvI4OdyhSYt1Bi4XDMWvnCaR3FEo6y9Tx+UWohDUKJgX034KNOrrMs6PZ7FTifcJSSWAum0CAm2IEN3gneScUXVn3QInDPOIs+r9kBxetuE1UkQZ3g== 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=2hzJyGd7ND7ALeuDMST/ER3oYgX4pWOPUyctcPhuIyI=; b=A6MdOwnYAuiThhEskYA5OwVyfz+FCAhviu9pQwyPuLMbVxF2/YQf1C3G7dy8lIz1hNIsJmJq6BbrgPH7IHGa6w4A4kMPVS9ekVz8hJsS1IGXfD/Hz5AyVhl5/uhASbSFfVUkgU9AUH3OnGzRWuflPUj7JG5CbhUzqLbtIpXbK1A= 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:38:40 +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:38:39 +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.15.y 2/4] mm: unconditionally close VMAs on error Date: Fri, 15 Nov 2024 12:38:14 +0000 Message-ID: <9ccad1c5a53af878459f32ae3efaa3d12d33e4e2.1731667436.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0178.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:311::9) 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: d2a9324d-82a8-4efe-9053-08dd05726e97 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: 4n8N14UzQVWNUv+8o3on9hFj5b1tH/5rVdModFiOHYUYtSlUptbWla9ewpXHoMnzlxfdW9LYmrVlg+DVO3nwvBwTzk6CfipNhtIBleFAcoNZA1VhA7p1B4lXFZJuXgwg6yY7MOAQA0myYdizowlIYPaZlGGNY9KYLfgfWVx307PSo7E2N9DQs0GUk095Cgr9lkIJcOmyOGE9FmoQLVZ/A3brtDouHBjCl7JNEoVnzX3KQhUIDtEbG2oFmZrrZkSeN43L5s3XR5N2bs31NsaJdFBym7p4nz4Pkx01ZZkU8dCk4upoWrNFcFhLzQObwtsOwzrGdSH+9H7GHmow7JJvKtD5B/UAoxWQIgX81R8Rbj6ByUYEdz/sw6wimuO+UE3Q+9+VPuthdnZWa7040xmscrIe31P7b+CehFuTEcf78hKrVEaOV7Cb1Jo/b14igcG3TTjujAQBiocMexFqye7lhNtpY93x5ORDDRwMAL0WllZAQywr2OvOyJGJcCTkabDfP17628DgA9WAJa/zFrTVNioVaKgzc7oYlhCRRKOUdFb/ztTrgrkG8IFMPn1D4Ky2PSQdkhGQKEsDu6eXkcJMKjLLOZJ2LxfAtfdB85Pb2kzr0vP5UEhAKBJrvKESPnoumT5MBEZPQz56Lc1/0RPEK8NUXIJz8aFs25xoCgoD9ntcTUpeM806F/OdHRGs6N6FHms2F/VwqGD2YpXSikBnKLKBJTJSPPyIEzyk5fMKzXQJUZhvq7CT/raunVp3hceNCrmWLXK+29DKTD9hZPHNS+uE1Vg1knSejI6FKZcfqI1Fm7q7o3GqyY7xm64Uj7O5gg79XMNyDRpyh7tXqsMepIyx6YuIwkaZQDeKIgWl32fm4UhyJHpbNU2zgD2zIdGs4mSdeYpQoghexRuOeaIdE7XYxasLXI6+RstLLNLy0G/zjEQKvGypyiU3R7PDF0eDkp8w5ZAIhRchB3Ee3JMJR/gMrnq9HcI3IAoujLI7OKFGN0gimFKPLRdbl0DFt/sNPdkr1x1IHdz9RpFJwywHyE/k3ZKXyYm6g2jyI9k4zOuQ/LPRkPj99qARHDTOwSIT8tAIgBQumKTexIhdAx+SMYqzKdk2JRKsuSifUroxnH1eAP4mbSfIiD4+Jcq/r5FxSEORVXtFBfEF5fgMAE1fYMSjzEZllTfDPvrHhB7xXk4bIp3HdeQ5fUaJIr5/QZue8fv0X+8P0qGGvgx1zao8SVGvbkupNUEW673vBmivbymbEAiFp5UWw1IX/k/MGAzAguLh/VHskpjBLXNNcnW17vg71JPuC9+Ba5SPYbjDmj4BfmqgaZHsJShBZse9+aQi 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: sYXyxdEAs2iN+EmJxpjuA95uTTsVIbNrXUHbSsX9ENtGfP8YUwTTjIPgKKONFo4ltDa3rrvPQ0GxyRy9RBAXSY6Y/3mjAahYMvZjbgZ2j9TVW1nTMcs+Bfdyh8spKKJ3Oo9O9tq61+zF3EpZBxLuwX1q/7YNQAVocrov1cZlGR3mpOzSdmYxObD8g5tyBd4wPhA0W5Gbtf1yVl5eE66WOAiWOC3YWVSFzGXaC2G0x9GifBI/A/RL3ARIu0JSzfOoLoz96XoOZwvKLkS3QDzTTP1wfuSPkfvuJYipAQe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KxTmMxYrWOCpkwM/7weU5RE3tEj5CoF+wvWLMIUuI4yIj+fGsohBVlDGjgfqXy9uT12oDlA1riJlXIBUfsrZONosxfbd7xn3/T50sK4IPMMQLDTmdyz1t2xhievrr9h7Q05jniY9rWPCdGzcGJgD6z7erDAsVjVY9DN0ydGFnHKaM3OfMOfwu2Wvm/v2nL0R2eNb7Da0xulbb2KQghb3MHhcPCIbu7B9i7XYrRCQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Mt0exN33bw7ylLY582OgbW0wBTh+AIleWkjgU4YJymM+v3oFg/7rXp+T+wtymA6b3kYBkJZH2uW6AEJhBRhncOBxAPJNVgaP75F6ZpKDpluozIJItyIU0Zq4C/i3/P6ug8viLdaQvig5GSIcZObusHVlIY45Vmdkmwxs7e0cCzx3Fz1/YinaZNvhvpMRRRqW7cRE1Uumy4tZwX8zy4VUoQ2La2jV1t5oHaQrAyrwl7St06wAT3F3cP1dNeT5NvdU8F57KSxQgb3cL4GISpOhaVs9h2SE2fbw45OKZFqPJ19aqfbHGoOkaQhpyPzaVVjYWREVRuBwopyQCr9G/bCVTx1NK7f/NYTtJwrb4rqHlrF2cUihGYB7L/53oUH2tjdFbMZoH5v7pkv3rwSOyL9yAk59hO+jlmiWViY7hd/be87xUpljBEDp7Hc/jmq0c6H2sPla8V6mFR9oXgcNotvQ34mTZBXEZO+VAc64ddL0Pxo24O6FIWl4uxD7MJit9hHH7mxAvzkoRAeMqp8PL7Jg56GVEG10qexvwO05N3kMr17EQZTSLjXdVBm+3LRztOg8cKOHZZ/EOdwlyplgQtBc9JRlTrumnI9AcQWZAHCDWLM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2a9324d-82a8-4efe-9053-08dd05726e97 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:38:39.8749 (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: NLbdxDrRFMM9Mw5kbFee0vE79mQlHWQJ0sBAWoeFouRxffKPSwtVEBZmgEirIlW6rd8jZ25LAR8UBfGMfkqJv2iY6XY/JBvlUrixPUusMe4= 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 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411150108 X-Proofpoint-GUID: wh8wQ_Hw_9pJaiqJIOVj1fBgzh5hjuFV X-Proofpoint-ORIG-GUID: wh8wQ_Hw_9pJaiqJIOVj1fBgzh5hjuFV X-Stat-Signature: 4s7pwrk539h73yga5ihbqhmjokbxdtxu X-Rspam-User: X-Rspamd-Queue-Id: 7F4CF180015 X-Rspamd-Server: rspam02 X-HE-Tag: 1731674292-288156 X-HE-Meta: U2FsdGVkX19YgmrJ6WDXD5FET1i/p1/CUpK/MNrXv/QM8LEPNKtmG2Z+kebLkWYnxyC2ibgaQYm9DzGmNZoDsmk65Qi0oftUaof8nO3ohcBeBSzWJr4Wobz+o6BSAopG72siNOMxfbNYP0KHiYtqNrzyUF7E2GFzd47jUQzOK01MygJpmxvMGckmRxFIYM5F+Vlfn4twnTClODOmJc2nzzIB17aWUyVgPNxMUGVLgmQmq+kIBrYqIITxgHcWZ0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tGO8vVdhQpFCIuRZRvzUm2PThWVHmM7u6+CHs9yK0JYQBAkmK+8rQOKvrzBpcKy+49tm38lNVvmy6IxO5IZ6ExHCeFRg2jh+l13lFJCn1co4pFWYrTbMbUlX3rvNt12yzBJzNCWM4dXbyd4zbw4Z6AS61Qo+mDPq+TKyD37y4BXOaVZg9pRgemFLhV8UZcUK7rJU5G9Gm1Be/D+DrJwnVkGS5yCCvlasRy6NHKbmtR1rtqrTbp53TQbAIefW33402zY25tmKQAZBKIFmth0TWTdWLHAYA2GVm69MC9v7wqs0gKdQ5vIOuFkfbPl7EK7HBt7/rnOrsGepbuWIj05ZNxOBajJlzGt6e1XA2wtRgnbJLVxLPedvWttggJxDcJ7VQqcb66D/R/StUpEu5H+1EoqE8fYp45kEPv0yPhjukhA+IL+hf3GdRHWxIjwD6ZbrIjGqDYiv7i9ZghJfbQovLxCwsDQ04VSz/n7yd0rd7KxD5ZfN0Jq5dEUUmM1YfWow2ZQyu6GpXDt35RnZMZ3mngE+HFRQrxhz/RLDw/vHitWmV145OIzCLWTL32GaQhTsJCdjfMPpGCnl55MhqM37IuBzDPW5+LsRiaZMa0t1zw== 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 4670e97eb694..34b3a16aa01f 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 11d023eab949..d19fdcf2aa26 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -180,8 +180,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)); @@ -1877,8 +1876,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: fput(vma->vm_file); vma->vm_file = NULL; @@ -2762,8 +2760,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 2515c98d4be1..084dd593913e 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -652,8 +652,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 f55d7be982de..af6c9bce8314 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1104,6 +1104,21 @@ 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; + } +} + #ifdef CONFIG_PRINTK /** * mem_dump_obj - Print available provenance information