From patchwork Fri Nov 15 12:40:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13876180 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 693BCD6DDF3 for ; Fri, 15 Nov 2024 12:40:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EC416B00A6; Fri, 15 Nov 2024 07:40:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 973A86B00A8; Fri, 15 Nov 2024 07:40:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 705156B00A9; Fri, 15 Nov 2024 07:40:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 495436B00A6 for ; Fri, 15 Nov 2024 07:40:39 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 05C77AD760 for ; Fri, 15 Nov 2024 12:40:39 +0000 (UTC) X-FDA: 82788287316.04.691747B Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf07.hostedemail.com (Postfix) with ESMTP id A50494001F for ; Fri, 15 Nov 2024 12:39:31 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=MmTBmgjM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="NbhYj/7f"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf07.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.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=1731674290; 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=0a8VQFed1vvikZaXHHCrnd3K+y0N8GdxnuwVWsxCp7XxFOCEleey1XS7JydpcjUM1Z8mSv TbgXspoBCOfwTTHQ+CKJAxnuWVtqiZwgeNTS6xBnLlYWgj8onLByl7AY7HRy76+SJ0A8PQ BwYnJua7I/yVpWiKKABDypFracha7pI= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1731674290; a=rsa-sha256; cv=pass; b=WlvY8JwqPeW84vNlz4EqYln5HBVl2Mx6RxWAoXlBw74GFzWauoL+ZVlhvMylayrbP5DD2v kWEyU4qgTMzvPsnobuAHWCWYaK/vU6m12oFQPbh5VMvTW5DtW83dn5mQglInxUFf2CS6un fwgaxI3Pqbt6fN0vrOXVlpRLNXP0/XU= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=MmTBmgjM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="NbhYj/7f"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf07.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFAHJ0M014501; Fri, 15 Nov 2024 12:40:25 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= MmTBmgjMus1Y1OHoAThRhY82a4gjQY/Vt9sU7e/6vMChl+Ep9Kv2JtQkwAhLbvRy MC3AoL7g0Aur42VakX4l9NWLeYE2FmEIhARTEOPkGJbaCv1ecjoHsZEpOv2/FRmF sxuI/IYqQPCwbiC/wejt8tpm1ZHnCkiIzjpFcMlxajIK30A2RSisbsNGEhnIYXMS Qc3GnAt0QaRj2AUSXr1M492kEAqnSHrig4ROY84RHjG10t8YimyIR19h08hQAxok 0D1bYbJqrsS+mmVMUqZVFUPnfOyEdTZG9uo7BST0T5+5/jHpffEoK4shsKrbLsFE ZitQy523nnoeip3kowCkAQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0k2b9j2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:40:24 +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 4AFBtqdf022740; Fri, 15 Nov 2024 12:40:23 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2048.outbound.protection.outlook.com [104.47.55.48]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42vuw2mrnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:40:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BAbeRHfCFCgfWA317yQlByuFeGllSYItxYNgWK4LtAqJFMevP0or43rGFuQs/mlGibIwvlSwnkfqmHdWU1NwgqSkKHDZ2YB45mUzc7zPCCJdoIIipVx2OOCdsATilH3M6SXvfVzM7KY3PdmOgCrMuMOGzXfjH7+tdTw8Uk/kqNIFIqjfv7GGLj84XrA7PWNBPSvszyMiUdtsR6ZKTUBf9eMJ5Z/JE1km7aNgLdPPUiWo37pOnfWu3MWzIS1PbQv6EbIaqk+BIVKrlOBwlgS4j+WSjij2lmV7n8loqwkACIadXvhDmkEFki5oJAbqKISfrQQeAHOmudA2njG5hVSPjw== 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=kPWr6E1P0WZkI35BzaR5dioXyk3vJYKALh16wz42bT7e4IVbaPzx+1XKHoW/msF3Zks0YQqtqqgfMxp2ZsuioKfK64mfRPGB2Zvy3ctB1lfgRw564Xz5twHNmvbNhBnqZLen6OFBPl9CdNWPciR3+R2513epPAUh4YIhz7lA58NNctzT8nM2S1lVVpEVUvxbBJeyw0cOkn1palOtw6FpgiAFVvpIpNEFgULrw/QtQqeGkmoBOx4Zbl/meHx4ENKRFoxv2ZgtnsgCILk5Au24ClQuEw3NRFpYrkyAoLb4K5jj11zn9ty7rfhvvrUGGJgds9utMd8nxBu4IGR7+Mz0wg== 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=NbhYj/7fmWqhhhmDNCMxLSV9d9U9sDwC441VI6Zv05Bb6SdSluP3bNGH/S3mD8HHAT1rkAL9zsYfffIiZZXieQOFJnZEGdYqlqqqkJkLqA6iSinJsPsgLhcY0RuGTHWWDDFZ6DcGfRuV9whum5fklHFU4awZogWArdGlKo6Z64I= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by DM6PR10MB4201.namprd10.prod.outlook.com (2603:10b6:5:216::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Fri, 15 Nov 2024 12:40:21 +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:40:21 +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 2/4] mm: unconditionally close VMAs on error Date: Fri, 15 Nov 2024 12:40:08 +0000 Message-ID: <58ab2716422d1ada28981b8e3b91e19ab1f5778b.1731671441.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P302CA0024.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:2c1::10) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|DM6PR10MB4201:EE_ X-MS-Office365-Filtering-Correlation-Id: ab7909ab-9380-449d-e51a-08dd0572aaef 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: 6SN0Ini/hraWUDeQQad26sRSsRzUb32lzRlZ2v2k/rFaJDxTgdAJPwxavsGKNDrwsExTx+5//ON50tqi7VCwAbYJTWrHMWBYu5npzfTbEVaGOiCUFZCVhRUmTIKy/3vuMVo9eB6x7wWqpoCOj94tWYwTDZoJVJy34UYM+O5woEO0Z9Foek8ZuNyo7tKrGPL9FmMFdinClIEPgdeAyudHY7WlLIvMxdYgpVfJ1gi7+xCDT6KinBp0D0p4enYVY5OH85HJxaGvXuwcBpZWQ/gIekmEBce+PZjIqH6dZmag1kWC4x/HP9MWi8rHq+IQ/qUSoheNtN8EHGlwGgQ8/pToJmBOeoIfiHyh721XxuafzeRP3pAolP6gZkwKgwJd5Zh9pfSDsi6HEz4Nk9BjkVHWPTuvgJo24xs7lrqwauQNzbmPHx3y9c0Dtc/kUhMLytqd/hPMYWit4KalGfZ5K4nwC1N4Ci2sbt0wb58Rjrz+XScS0aEwNisANg/5VYlyU/Ubdu9cM4qxcWFQv8rFgkWCtofpNTQuYT/7Z0pnq57l4GFsN39DtHxm5fkYsJTdzgcACSGabmyNcyVQJ4iMplrqSM0B3xJyiZtmT9NKAPDYd/5ennywK8vOurcujOjpvh+9Mwv+xZZtweUvBg5Tg6goVPeCAZJBjPu1shNiwHG8T68LVojakyfuKDibGg9e3uu7Pt7WtEQWMyd7WT/07pyatHIAmgr85GF/llH5oV66jwOY9KU/qrX9o4FgKvRHzDv3vAplHHHgqjbI/9Mb2qGnml691OEf1QPFkUNiXUJLSZJD4jIVKR6SUKMnjhLH51KpNHg//MqNgpzjSLGchliUEhlqVjYzeBBVLqKryVzxZz9MavAFofGVoUgnC0S6WF1PQFfTbnysKXrH9gIYhE+I4DLihVEIC48ttLuvML3J9+dhUTsKIaQIhzlGNXwn04F5KTJulpN8+fvtkc5hpibfLtxxKlaX40DuA/aCSs5S1cWaDWDkLDnEDxIno0nYCBHN545StIKEsRjwFNzN0LdOO0KrjFRMaG1RzS/cLLmSmErwDhyChd98qTVo3TAwKV5R9SiMXhzLlzqHHchRrIXfFjxiXquDQjFNxAAIhT1wCy79zG6aCG0lkLdqHqH56E4KSs/oMXDaElSGABoaeiZikf1kZEqNYKdltfw/elk9K67sVwWrnu5mYgrCZsW5v8S/oYdjeb+4PHDYsVhzkqQyEk+tUbn2IkuoImEojLE0qgm9zw7l4CkwykgAEB/feyOg0ju5XfDaEzBJowS+jI3AswGlqajEtA+luv5BphayYs+3BsDNOgwDA5rOHHtNzjUr 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: H6TisW6MSazPmphUyjUJshC5R3m3atjflLCi6CYRNjGhRPWFl+0pEBSE/c7nCoRGF8OWyiYf8dC8oukxWqQWAKoCJGuLQ+0s0+8QgJUoSY9jPZ6WiaUZqoTFk0nl/ouxpOl/p9VTq7UkG3nx2cpTvOiyvHzybxSlCCajRlGRK0oV3fCQoR99mXthqZkz3TnGYmWCtbtdcvnQ01KnWZouM2eLKzM9xsWpRi/EI5a0bxUtXwaW8cljhnZRvhJtjopVdxZO3VPTli4bR6OyQ/0A1TSh+6IWlWTVtxajyDly6ghKQ2kHNoIh01SD1BfBcaoyUbe8Z9wFLrEle7LMcZZQ87KEfcG92U8HzO/rmf6/BkUCquo8T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XXftPGQJF3qEZrfp+6pxA4f2TUVXu66qI1zdf/gskwJgHwbHdByKkdRDYjjaGgayaHFbk7uByQoShuA/gXwBGnF4I5YcqRLRBuxdR44ptl+M+PKmKbmqZznnXJjmXL0VZR3sJiVnvidNdyWj1iaNOH2aG8zRwxcmFMhS155Bg4Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zWjijpyQesvhmHPTBOXKotncBoJ3m2+Qw2lFEhXd1BFUL79E42oi/uA2dfZr+wrinmo9tVaacej3pPb0Bz7hiAjB2hm0i81UfTBn9HbnNf2GoRJKmzHsEKIEz3uppFkI3JKHHqd1bFEYylbZrTm3QgmiUQzokziW2atc1D2MS7NpvoWC87phttm9u+IhlC4GLxWL1M9j4dP8Nlmf0qo9uv7dZcsw1UpWZic+AAf8BJ9dnBEFvVRQY3/ujYUoiDU1TWmwYUH2ddH0qrHGdhQE093lj/GO52Fi1FS7fBitFR9hfzdzxrbYblmrCGqrJpEEWPQiIpZzcdqnZxSxe75k2MdPwiJHz2adsOrbY2Wl1hjYGm98ExlxNxF0NJPGVpQN/H8CTIcKQVJK4yJw33h5ZF4hoAuFweyOB3vfFmlpcn3qiLvem+1xCwX8y+2nHe9V7/nXFc2I7HE1poTqRJ3eK6Bhj+MiXQZ0M3VeZ8lwhgtoSVjPerEzwOtWGna2vWgnzuk02UWow3rpli+iNGONlbFONqcLk0tjpe6Z+sgQT7S1V5mIxbf7pRco2wsA17XRLEb6z3kPCXi9Zp00XKDKyarjz6HqEYYBMQn3wwXd2/s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab7909ab-9380-449d-e51a-08dd0572aaef 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:40:20.9932 (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: 9kxcup4xNp8HprQBVUwJSmOYld9fmG+CMhbXfAa79IRkxgxMKZBZs8yWUOmBfGLRD8r9JqNhA9LDfEttIFn0pMNO0eySlAxHbi1aUm/AOlw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4201 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 spamscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411150108 X-Proofpoint-ORIG-GUID: H51HuOrTnqGSwv3BqamfB5cbYeVOQ3Nb X-Proofpoint-GUID: H51HuOrTnqGSwv3BqamfB5cbYeVOQ3Nb X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A50494001F X-Stat-Signature: g6juctiu6h53j91wzu4z1z5siuayrkge X-HE-Tag: 1731674371-945030 X-HE-Meta: U2FsdGVkX1/oPCevRf39cQ6ku5DbRN42BAxwwpOpANV1tzaT0J/RiVtNE8A+gYf5tiNsbYam1i7KfB+eaDEa3Y3PmBhgXkgXpa8JGdBG3wIxZt6DYScPZh6ekFaxo0YZc9n3oRORYD1X84mBZ5jCFxwJFXv+EhmEAmjtwWU2RGTBzE/RC2vfH9BlFx+Q68UakAn0RhoKolbF9d044leoqo4N57lI1Ex7E1eFOmyTrNYWae9cP/byVpJxpo/ygqWSvIxfUfY+O6dOvra4L7lZyrxAYKm6Jkdp/6tXwcFAFUnA6vDHTyCGzf3FuZy5CTJ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wYfGxVSaFfPhwOm3f5A4XhdBTQgwfExPGSRWCkGGi7AIn6/sdYXWx5DIXvQ8O288zygJ2k1lOrujRYGkcK6mKdUD5dqbkQ59HaGR3VuKv9JfQN79GKDl63N3qxMasn/6WeWR/52yyDuGomu31bLafi4V6gG16mb8ZVltVBKmfifMY5PuM02wYtm3IHIuZ0JBM3CL9k3PYt3zwbpxMYCsbPNgyvJ5hvk8A4CQ01+pJAFL41IrUUQQCiHuICxxNIYJZMo828VBuRoZbhbbI5EV4U8tiTmeEWhCQWdMnpkMh3lVcN3JHLZHwqa8DJFRwMQD8en/U+//d/TRL4Wb/8+75o00iiF+WZgwCl0RGVvv/5l4NoJZ0Z6B5ojw+9Gvlra7pNrXWPLuca3YNN+ezJaIzlp5JDwyTw5U7SGBgeBl6ctXYCQrH7zXjW2yV37Dtmtxps6T3O5kmLCf6XRseYf3EABX61jmLkrPfhRvgKYWHJkWSYOGj9bp2lAcjXGNmhuZGWpOruhQttzBDzN05MKavLM= 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