From patchwork Mon Nov 18 16:17:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13878823 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 9FE84D49207 for ; Mon, 18 Nov 2024 16:18:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 255D56B0083; Mon, 18 Nov 2024 11:18:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B75C6B0088; Mon, 18 Nov 2024 11:18:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E11B36B0089; Mon, 18 Nov 2024 11:18:53 -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 BD6256B0083 for ; Mon, 18 Nov 2024 11:18:53 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3D40E1602FA for ; Mon, 18 Nov 2024 16:18:52 +0000 (UTC) X-FDA: 82799721060.20.E838CD5 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 8629D140023 for ; Mon, 18 Nov 2024 16:18:11 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RxOKnzO4; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=o7NMkAh3; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf26.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1731946663; a=rsa-sha256; cv=pass; b=YogNQlIgNrOfYSwZ/KryZyKP9JIglEDsAfOhHCQ6k3QUdkXJ/A1FkbjpRiXIMcyt42RR3G KsefSOwlI00XZP2LhCVRa+f1UMZruu9jKw9lGn+l6INLVvjumy2mYA/ndXCjB0WflNxsdr sA4thJsT1rinIPBSauJmGY0twfrxYXg= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RxOKnzO4; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=o7NMkAh3; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf26.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731946663; 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=OxWMYoiN4etCWEyz5nY0Duc+cphdupWfvPon5pvG3ks=; b=XwHV9vmB3lr930bFi9l9K9jGoAoamvvcB5v20NnR55DdHjmU2DN+Kr2pMdiSjbbAg3M0J6 8p7UpJ3huiZZ1Y6/RM1Mvl2rxX4rDfPteKW/zvwscW02kGL0fsNvGGDcAYX5qMeTmCwvyl yu1PpRZGD856b6Ox+/PR+yAEdjel/TM= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8QXZX032645; Mon, 18 Nov 2024 16:18:34 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=OxWMYoiN4etCWEyz5nY0Duc+cphdupWfvPon5pvG3ks=; b= RxOKnzO4cNgq8fEj4WhXU2d6X9MJmgpQKqQePnp0jyZ+AEXrVgV9fRStYO8eDjOx BOWXaS/C0qCMTlxZO+P4DGqW7/GWlxjvVaurvNvo7lB4ka5Ag9jIswYssMBkb94k UhL/oYW0SMm3OkxBkzUZy0/YAbQpoOSU012ai4hoN2ddunFc1Jsvbgy8gUiHzTww EJCS1UUKdbCPEcEbWaqHN/2ezOarwigumoPCl0UwgQv3lca6WgANsH5qOgE2f7+K zIdLW1IAw4dVniMSqAzbwhZBnHTuRQAhWaqBeiZUjtak6bMIbtn+R6pbqpqKWiok n+7djNborFkpNmsr31zNsQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42xk0sk2md-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 16:18:34 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIFPi6S039269; Mon, 18 Nov 2024 16:18:33 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42xhu78bdx-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 16:18:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r/eYt9oA4A979OouXyh6k1OmeaOJC8fEUEess0uo6CrOAot2aDgORyokE0AR7hnXumR6zkAdFLE/8M0fJxkYCsLZwiLo5hHRtikqgKhIVMsA/F18TPXPUkyrfVJze+V6dpk75qQcymGdxiFTntNuGpvTqbcDH0PtJaHckntJBDEwpprVPBF+ivKci3Ugge28IJi7olMLtKc60oPYQbt41I3zkS8LabDKhPzBoK+Lbp9Ui6cMZY38+lQgij1wev1mQnvM4UK9IqkGbHiei6Yv4+AzIWg4tBfl36nwUoaLIu/6jzsSS+qBQDts8lHkDYwhKfR3b0nO7q5emiG2p3CqEA== 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=OxWMYoiN4etCWEyz5nY0Duc+cphdupWfvPon5pvG3ks=; b=CKTEl0NQ6jLfPYFQmlqWeT9SsCl/nZ3kZGWCGRXhiNl9ZFTson93TxeN6KHWVq30y7ckx5wOOLLDMelyHo+2Ho4RNdu5UEeS4Mr0OuwXaRUcc0yfoMHUQzAVNMo3+dxYKLu8oyZGlW3GIuPY3JoEfUcE4Uosg/Q+uAo3H6vYlYJ4Sd2HabSkPIcKoU3wUuay9qknRbUUhRCuSpYm0TLwt5cpSv73Y+RrxwmhARDyrDTtHxkrSBr2NjhW30OZ8rAvNKPbDkdKbJcUwPYQwDhmnNoehLFxXPhozjCgW3mwI/1qDr1xIk8A0s2vubvYYs4uPLUAnNJDfJg8E/abxQlBTQ== 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=OxWMYoiN4etCWEyz5nY0Duc+cphdupWfvPon5pvG3ks=; b=o7NMkAh3wb8L3t8FT/HsQr8poWe9WdIoX7dzNkq+W7H46U77aSsE/Oyy0KBIvyAl0LTmuv4SzXge74USpbH93qoK0W9hWfl9a5Ne5f0yXWWXQ8Ex6iLktvvcZ9U7aoM7Vfjg1RZ7xnKeBmZgLMwjOYn9DoVg8OrblrO7CEgVKrw= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SJ2PR10MB7619.namprd10.prod.outlook.com (2603:10b6:a03:549::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Mon, 18 Nov 2024 16:18:18 +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.8158.021; Mon, 18 Nov 2024 16:18:18 +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 6.1.y v2 2/4] mm: unconditionally close VMAs on error Date: Mon, 18 Nov 2024 16:17:26 +0000 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO0P265CA0011.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:355::19) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SJ2PR10MB7619:EE_ X-MS-Office365-Filtering-Correlation-Id: c4b2c6d4-44b8-4cfc-ffd7-08dd07ec9ceb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: 7zWCD6+UaHc1dDXaCjxH/JDwvw1Xbrd/hVZVV96BmdyEQCIBLlGRhy6IiWpoDsavrNXNMNGI14Y1W7w7A7gWLuROg1BoC+9jXgEh2p/gtYy0gg5AoUnbcsY71M8jKeO/MlLlZfc269deHgzOjw5WOl2QY9HehkUfh8YxQzBe9wVvgea26okiDCztX7C4Co7zEwlBmzVoANCmeTR5oyaCaY/Q02BgICOOWAWJkWevk8GVzgQ3xu8rGko0Wb4ri1HcuT+tCrk+FajpU9MFDy+FQNvNF8Jb4A5/b425G+0oOdcrRY5ws7ZOuhWREbS/csadlgdzun7HQwQqyDUVXQaH+ExoEuffoS7/vC0DzLacUx33nAmjyyktEAxG/K0CEYHkh5LIfflsUuAeOhdE7633/ZZkrXAzHh66aU2HCBehUJUQEzoBCDwE8GFWZN/NrnqhW4QO/oInt+Bvte3ffk5vOnolm2ucwDX0IhkLWvmGF3qxujnokPVf8Olzi0k558tudnqbHAIAHpF/C/gCRQWBPwnMAvGAw19ztBwQPIan3vR6BQFf0qVRv4Z9fEg3jhoHRO7YHbDS5WQWLehIV0aawEskAC8iWi3RRZpXkwrypaHRwlIEsVsuvvwKgUDmF5DqdvHEKndknxM0letcJM3/Sh0BM1DT6FRepsnFQu9YFbGFV6L39cD1jc09BLvvzVjyJd/9HrBpZIw4pE2X+YNzf36yfpM/Fo7qvltDluAvdf+hiQ3u37gqrj4QHYK8xLu28t+Iqlu4GhsgpK3bxDWRRXrYKBpV0V6iFAF4RboE3g2/BV3kvlFmSe79KfBFmFzjM7v+yhuRcnX9NXZ0GLInJMynxBPMslIWbsksS9ohOK+qpIz2wb93oeveFms0ufyCcKQemX97PjpXIdJsjMgMCkcDLQfjaNzszwkB3EJcnmKRJw79DFoPL47XY17jE0QnUfCXe2CWwzK9iRREV4NlcoK0NGMULU3MPYcdtoNZLMlbDUxHK+PIYu4n18mSwuYl/D9ZPM0jh9R814lBp7P0lCsfMN1fp3ZN7Onhi00clUwQhy/nty1yOIvPmWM7gBzssgHkHr8cJobOXlREgk5jMKZpdLheqQhDM74NLOMjjhfeMh8xXEKDXbkHapxRYIVtNpoMCjwOBRbc1ET8E9s+ZqZMGhASAORVm35+kgqMmpmsfuSk8vvFje19i6q+ysYpW0xuM/ibt2g1Q5JOPE/8PeMfui0aOvz/oGE/wBjk6KuOnCnaLgMR8cq1jrQfrIAE+oCrY1/TIVdGOZWC7Mzalxwf/jk1ZkBnMQmWXP873N8cs4Kj8eKb0cF9th+iRvFS 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HPNvWGweDdconWe/cD2Am8iUoEb090Hm2VJh382ixZhqTQCe/q08Mwi/O5U8ex/JSqsepG3T2z7lbI2/6xJz7SPn088Mi7VPdYzHv3GkfHYurakBQV3lR9SsUHClv/dpwZMeswacIwSAfPtwkvfUn7InvMfBM1/z1YWmNxExy3OjUiX318Wk4dvrOpLFCiXEKUuAR5vEhXsHtYmgzKexRnjYiWzgMVbHHA6vc6KLEuY7cRwANp53Yb2CD4Q/Y9fuzlsuhdxgcSYatV9H0o8eiICy3zNHvMJa+pTenZP2YoLpFuHSSOQLzzFhghtJtpOuQYD+VsysXXfqE9OJpP0sT+wVvJq+8+kvWROQmpqOQviXh1gf3PviJhbbF2YL2PIwiyd/1eK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CfLqAgjNONBbD2ggLM3Sn0kmeyS9n0Y/pQLzy8B20YIT4hjhpeipBpTbZ6bvoG2/bgqtSuP8p/+FPvap0HFpum+OzT9KodEnOy9VL7hGJkMe4Lmz96QAn4k7Z2pX52gBYzvHswL64+O2s6nybMQBfaB3Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 3gLIGuE9OvP9/BruG+eWWYIwTkt0QIoOPzX88B7BNAJU2/xZLLyVGAx1nkBbAW8Kgmsr9AtO6AJOIBqaEdtRutkPpUh47yzZZwQMkHWT/+ZjEvM36ON3T/ja7yqD5oirTWBUp5EPbRMb8FCSu5i0Y5nKXuhN0XyLU7s6n+FhLJXBiArgS1Wo4SqUS2t/POM65TkhL/Eel+noUSNn0PPHCNKGh+i22sAPSscXthcBZd1hG+AIEdwB4TKxKHkq7Lb+Qf2GqpqtaEfKdZ019wz/OwuRB2xsKxdLtl0yU9fSazLTwyaYC0j7duFEAQvco5h/4qP6Wf/lmOgfp+UoHGOYWxGYu57wWqYtNE15E3Zru9i5o7k2L6RGidyZrniynou5AfLyfzCYpAMhqDQVcrcadvlDlJp/N0w8JPg4Hd1Oe+dOAxFLO4s+nbN8BflST3oL1/nGriK7QX/iV2AWQFXGjcdJX/DDbpm45dqdUKH0XOyyyvRi/SBjHkwsxrHZG05Fma6QRre614QdwxasPpWDXLtx2Y7kxrv/AqRvq3MTpOCVSBYiYvUgrh+HKLowNBlWSg6gzu6nUZ7dpNSDZ51vM+Ll2A7Xg1KZL4bV3XHZpRM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4b2c6d4-44b8-4cfc-ffd7-08dd07ec9ceb X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:18:18.3789 (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: sdDMH4QSpRrevIbgFXNn0/34dl3kTuMyl2W1qGSK+MGXCbfB2HjrbqFoHufA4aj5Tp7+pibeHAIRmz7pT03BuN0zqFbhPOvfETxP5aNJe28= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7619 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-18_12,2024-11-18_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411180135 X-Proofpoint-ORIG-GUID: uJBBSe8JciJ7_GG4USGnHHdOOdYjG_tM X-Proofpoint-GUID: uJBBSe8JciJ7_GG4USGnHHdOOdYjG_tM X-Rspam-User: X-Rspamd-Queue-Id: 8629D140023 X-Rspamd-Server: rspam01 X-Stat-Signature: tqe1czq9wa7uirkdgtmiz6ai9pm7u5h8 X-HE-Tag: 1731946691-616269 X-HE-Meta: U2FsdGVkX19Aid0F2ACGLSw/cKE0aJUAk7IsSmnAmtlsdTyQ2be9fBOtgzCqaIjSH5rs565/JGWkhuTRrF5Nqs8+cKIm3RpGLv3ixuspOYD7k6IEoGWclT6C3//xjgi9SvCjYWMCNLIgVA4kWqPSss8AezyYWb914HVSGxLPirOA4ypysR8fQS+eWWpdMv6vGSZ5FaZ6vRl1mInGAEqtz5HhBw0kfueg4WCscjSAc/pvlAfHQBZJ7zY2cBn1khFlUsFBEwQc9nN6CB7w/H1GkReoUohaz/gSeL8mj/eE4eIpk2Qu/sXoff1W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J5nRy5+jl4HIfUx01+src6FId4siBZdxrOF0KQS/OHKSiJkaR8elgd8rKc8ioBOejjLLjnksB0Y60sxcIWRzAqrws8G+juxk1lN+N3O+SyI723toqXRFwgSuVyJsRj3uQuzKEWwlm7kteRElQFyAgspeD4CBcOxbMUfv4KfYY1oDU1bB2TxzSZTPLPte1rX8pnMjp5IEfikcBY3UUEwGKM+KO7R56KUixlk4Jk6Bu4bGJaTooQkCe19ChDTeijKgc9LDseAOEYTC4jQPm1cqRcGaMIFglkEyvEyYwiendNbw8pD+8DNlB0zaoQPPwTy8zuOzSq6X+bAt+G9KGKldhvP7mGk6Z0JPP9VyeTHfYw0o6ZvCl02RfHeEU3I+IsuX14746EjXaOYH+oxPTGk4juKRvHTVHHj0TW3ESBwEov+IEFoo8OEF5fQwhF+TQbihUsTeiyPSHBxFUw7iV7rdvi95l1XRFVeIxaORIxTU8Hd0fWE9g02UhgrXt+BaQXXfXoq0SLIXnxyX3MirioAuIA= 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 | 12 ++++-------- mm/nommu.c | 3 +-- mm/util.c | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 85ac9c6a1393..16a4a9aece30 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -64,6 +64,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); + static inline void *folio_raw_mapping(struct folio *folio) { unsigned long mapping = (unsigned long)folio->mapping; diff --git a/mm/mmap.c b/mm/mmap.c index bf2f1ca87bef..4bfec4df51c2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -136,8 +136,7 @@ void unlink_file_vma(struct vm_area_struct *vma) static void remove_vma(struct vm_area_struct *vma) { 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)); @@ -2388,8 +2387,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, new->vm_start = new->vm_end; new->vm_pgoff = 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); @@ -2885,8 +2883,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; @@ -3376,8 +3373,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, return new_vma; out_vma_link: - if (new_vma->vm_ops && new_vma->vm_ops->close) - new_vma->vm_ops->close(new_vma); + vma_close(new_vma); if (new_vma->vm_file) fput(new_vma->vm_file); diff --git a/mm/nommu.c b/mm/nommu.c index f09e798a4416..e0428fa57526 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -650,8 +650,7 @@ static int 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 15f1970da665..d3a2877c176f 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1121,6 +1121,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