From patchwork Wed Oct 23 20:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13847892 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 88CA2CFA469 for ; Wed, 23 Oct 2024 20:38:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BEE36B00A0; Wed, 23 Oct 2024 16:38:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16F6D6B00A2; Wed, 23 Oct 2024 16:38:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDCE66B00A6; Wed, 23 Oct 2024 16:38:57 -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 CD18D6B00A0 for ; Wed, 23 Oct 2024 16:38:57 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 74925C0E8C for ; Wed, 23 Oct 2024 20:38:38 +0000 (UTC) X-FDA: 82706030400.27.36CE66B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf07.hostedemail.com (Postfix) with ESMTP id CCCAE40018 for ; Wed, 23 Oct 2024 20:38:29 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Ud158EJE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nXApxsgq; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf07.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=1729715781; 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: references:dkim-signature; bh=jJ0VN9cEY47aVst/SDONE4skPXoC1YBHTQJV6Q3MXyQ=; b=iUmleQRirFHjCoHgkAHhRNpO+OzaPFqxdv6vOvTGSSIzj8YPYvd3xeUHSFhacuSczoi3vw tFrtk6lXZGlHHkS64SUflo39qbu3C0v5uoqAkyZDeuYgqF6193rfr20WpvQFaqk3QD7k6D CGVkOUFWwDeeCrhTveDfgrGcKsqzyr4= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1729715781; a=rsa-sha256; cv=pass; b=VmFAdfJrNBJ1Yp9DHS5G6YKQhN7DQr/VT84FkufDrIHfvdZbBzAmpIzMrbd4u7Rrh+cYqu kKZ91n3wEWp002xBl8uuIeIjkk5BK0N9Grk7WGD/XJl+9Nrh96fAgRQBE35EwpGFPgX3Ek bIS8wuhsr/dyZZpu7x+H9TJ0lMCNp3g= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Ud158EJE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nXApxsgq; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf07.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 (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49NKcni3005471; Wed, 23 Oct 2024 20:38:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=corp-2023-11-20; bh=jJ0VN9cEY47aVst/ SDONE4skPXoC1YBHTQJV6Q3MXyQ=; b=Ud158EJEFeSJXpIuEQ0ihEoi1bc3d7CK 4eCnCiv1MqFUdqFqbFhx+6uTqIQInwyMfsDA9OCHyobWTQrJDI6PxTFP7reY7wVg 8YzuVySoyFBkRSvIo7L8QfdQEF7SSNVwMongD0FZcM+sHmEWekiCl/p5K2uhNK8V GlLwTiL1gnt3QkOl2Yu2FTbosSxParaLa9Ma3xDJEMX1zpFHN3NX7wnnDPrzto3V Oj6Z/6x0XYFpI32zXkwJxdF36BYWxO8TS4mooZOAa4T0svvqsMoSpdKaejK1OKRX etYcTgyZgpCa/BDPgokmbqxUyFV5w5oeSyLtmbOwO1LlZgKgQnAycw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c55eh1gn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2024 20:38:51 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49NK99Lk030906; Wed, 23 Oct 2024 20:38:50 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2040.outbound.protection.outlook.com [104.47.70.40]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42emh2191d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2024 20:38:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OQ7wSeonZIYWeKlDKDpXeHQ8OQrqrjZtGxpuYQ0ppJvS4sibk89bBGtXlfDlgfYByUH6tON2xTJwc9q6H04RvXd6dZXs80Q4taJb1bbH+c2Wx2GVPNl9e3EAxtmRfEnqK94frgJhVvgIv/ead4xvmGkXxCSef2ZeZeAE95KhJ4F6mZsGCtUBemRVpVrrJKSCjm6qc0Kvl1BQM2nArL0hNcceKRGOP6/JF2RB6wjVZcun9qHKXaaKrhAhCqnV99AIRcpBeCbqrRj2q15LZtfJOUvbqWMrfXFpCCV/OfZxuGXV0iD4UQ9IkD1JqPELEpEELteT1SG2+TObp1U7A4/KRQ== 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=jJ0VN9cEY47aVst/SDONE4skPXoC1YBHTQJV6Q3MXyQ=; b=Lne660fI2sKvgjmbXCQ3XavfpLGqI/1/nQWPhq1dersJVe5o9eMOhCZ7W5yOQCSFGpP6nTQ1Oab/v4m7axnkLIYQ+6jnvmhf4wnxyEeAI9pPQh81wozS1TwqUkLRQVLGtAvI0e9AC62DLYDEnC1uvMaiE5ExcFrI4BZsDL5Hr30Fy/XCT4kJVVQP2fVjv+lx9AEe9KGQLvbZKtemLfUOnrGZwBU1ZVwrQW5Gz90ejBucxY/HV9QV+Zjieac95pEC0v0BDh8ESJw3Z92YNAasAL61PxOmtArZ4a5dsl711UM3rTZx/nrNrnO+rw/RrNhgFxmfNh4O+OvcoHjc7NxFZQ== 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=jJ0VN9cEY47aVst/SDONE4skPXoC1YBHTQJV6Q3MXyQ=; b=nXApxsgqJYVqesMJV+e0wqhsgjqpr0dpulSYxYPEhz1rsumiBi5LwbPGNwfvLjsXl7RBMQ9zdCdhSDJeb14b0XmqJeMxtwTTx1B/fCoNs/rUtObaB6GMVK+xBNMkjokJJHOQL5HCLjN4/uPQEj+aMu5izjiasVhEb+T15f7lUnQ= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SJ0PR10MB5833.namprd10.prod.outlook.com (2603:10b6:a03:3ed::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Wed, 23 Oct 2024 20:38:47 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8069.024; Wed, 23 Oct 2024 20:38:47 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu Subject: [PATCH v2 0/8] fix error handling in mmap_region() and refactor Date: Wed, 23 Oct 2024 21:38:25 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 X-ClientProxiedBy: LO3P123CA0017.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:ba::22) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SJ0PR10MB5833:EE_ X-MS-Office365-Filtering-Correlation-Id: 3472c355-4a57-47b1-8f4c-08dcf3a2b199 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|10070799003; X-Microsoft-Antispam-Message-Info: 55Q3rbVPYVMsHOjmoqGf1kDNwin6eh2jpuJewkekr+NhDAwNV6sNbdrGrJoQGpP80/8K9C5gq4oK0FF47i/yL3xkDgJVl6VHquus6ZtTlaYecfpZvcIh9aJ3eS0Fq9qYhkkobXfr1c6LhkNo/jOEDkEwFJ7qeS2EdW+2yKOmsFft0YpIaUCir5Tej+Ub20AJok1Th8093N490z6S/pDWIWPq/UZi3bKJ0PC+L7AdDhaazr3nlaag5go2YsdppgnpjcGrOAohyVUdoJc+cKdZuqpMITdSlf1Iu8rk9sF+HXA6FMMBDr3/RfV8d7Lcve9DnUKZNzqfCa6lP+KCmdD1dEH3LbBzI6xSz3ZiTVwj0Wi8hgEpdJQk4TL4lmmBuN8QxusCG6T44GJbGU1yXdCXddeJF9oNqHAIprmNznOurkU63oDPaLHEPQ3RroEmCQJc5LAvYzjNJ2n8fZMRiyn6Mda4PVpF2ObdQa3cmEiMl0DpcaxSmO97aaRUrbkjNbN4ijCw6x5ceKfwb3Zqe2fqduwWLNIeZNHYsVECcK0pqjCEmn3WPJbt9f3pyKKGW/xLHmzTlmUIN6v9wf+CVgNTNFiBDoIV5xm/E3SQI3llMniOw3VIT6FGcX3gv2x60R8bvdZVkKyVorgTCoJ4FJjnB3HyjKnufVUKxtezhOM9c3YF9d4YwFn6UI46hu5MlRssphyr1sIOJq+eiY+rgInDdhqAmtzjyaBFcePHSHYPMiTtgR2aAOEeyElVoi5cE3mpIzmj/oPjgGkn8Zum9XxJrbcJIsAs/tJBI2HDM+94tKo+AW2j8HAb+7L+wmHnwaOylm3HGTCBff7BdwXA6rg+S3xQXITM2u8bJ+ajaXHbMdrrP81NBkXU1YYRwUQWd7vyVu/fysau+QgD1PBFhaZhghGOMrTyUsOvtSrK1vhxdQaVlVpH9ZxxXQ4VR6BjUP+3YJnvFRt98nLWzNzKhEc3n7S9rwjM1a0QlhpQHm69QJ3NhlVg05QLPHIP+bXBO4Fy897boZwDsuRrgWkEpS/2deBDNE02p9JdPA/2LmalklJDQausWNXDsGsWFjcoeMII0r1xAojdYbCujoFurYz11ikPAom9lUA0sG5kZhmJFkXDqKlx+mPHB+BfaSQgojXKSh6gQM/g6C7mtKnHiiLaFpbYN5yVbojkOQq07DI7wjHJrPm8oxmE49Je9Em0SmQIcCj4Ilb5hxGzncA2sM1xevIujZgUContktng9btWb+clTGpVG+ZTV77bX/SSqJtf69Oeg6T4xrv/rijs+6ompHU5Y6fVqoYMzAKSf6QF+2MhOPInkPvButpg/DwVQWA8 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)(376014)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZMclwrSE2bFZ4AfXGrCAfwsgwYn/ohNwubQZIEqDMh3+5pbrDseGV2Q4cFQcJM/Ne5okG94h7tFB8hcI60Uw+IprMdSzIfWLSCOVTZb0OtYsNjHuOwA2aR/KobISIe42FjiX4H+rmo9dV/dpUPP+tVTc6UK4Jk+dXVaTDs5QOoSCNgJ+QMDil/1iaj+Nm06QbRSKTXtIcdOGpGVP6uYCmrwpUFiaj/YUFEeV0yS+2DDBzuIOcvReN6qev13yOflGPixHasZp7AvTmkBWovtc7SxUp+ife7IhQFAiEd/7sDnsNuu1KQeubmrxec+yt/XmTrwETsp8NTSv2lGVujgUsjmzxK++9qLuu8ke3nOTXgHu4U6C9PzXbmNtz9u/yCcOAOMnOsfMTeC56c+yqx+lY4CKWuzqFBbdIaPJcClUrep7VaYlW7njkZhwHuvYS8szKoYXsLp1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olSS7YxUn+91Okx9rtAjWMA24oRZy0v4v35rLZH2TFh/ijmwflSKBNGP7HUoUTRRnk5Zzh8HgcxBYRy6z+Dhn7ZeuWF92InvmHGRAdfCuXsbkWhJMqDCcCBAJVg9ld9htFsFCu6itWw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XMcGcEzevXHGW0u+Q18lVlTnkO/1te7yY7Ki81v7S7z2ljSW5MN6ViGfrmWj3eG9udOqe2SFaFbTq+AQ8afQ1B212DRzlP72WxDei6AWTewcFu17KnNkt5ILMseqlL/l6HPnzI91GET4LfRaTfhG6NWeX6kEjBt+wKfbFw4dvGht/fVItrNh6wFqhl+IfDtCCc1i4nbTePljjCSMFymg8njoIMwqlEtCr6kaXrMsVZXicCELgZSeoPeMfO5gsU+0UEoz0VcLymz9HCKdHJSduHgM1zd40vLEd1utj0KmxQbwCWMWnrSK1k0QtHe3gw/8QVIsnFYvGVfxzXTrFo1aZq5n7jSFDzPVUR7mx7ItcZCxNEf84dGG9UgnRIsWkK8ZcJ+bmo3Dx3wmG3AyHhh43GjZmj4WHBHgIdFJmAYgaEdJ7hEwlf4B56l8P3Cwc6NG4IJYytBsdcmnRMkNb2MQnUvstkKZASaHm7+12bAHEmi/gJE5EUTdANYvZM+1AaTu8hkWL4Si8q7dqP+0dewKxXg6UN4PhJBuzh3ukO9kfHas4cnXlsodeK8x0DCUBVo/6hwrB+Cv4Zy2LuIw0ckCN7iPy5EqGHDwr2zCwf8CB+U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3472c355-4a57-47b1-8f4c-08dcf3a2b199 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 20:38:47.3232 (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: vgHLkFlRnjQEd3JjnGOExvyxFCVlpE701xpil3ewu0Co951LYDNOj9pxtcZfeiMyj+eosufN+G86c8fEtMJV0dLgVsi41E0XXKDrqVPcqaU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5833 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-23_16,2024-10-23_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410230132 X-Proofpoint-ORIG-GUID: 08C2_PfjRO6HiQmQsmwc_xlZA8d2jup5 X-Proofpoint-GUID: 08C2_PfjRO6HiQmQsmwc_xlZA8d2jup5 X-Stat-Signature: 51hjggc3e5iij5g5n3o1k1n4pg5fmece X-Rspamd-Queue-Id: CCCAE40018 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729715909-123552 X-HE-Meta: U2FsdGVkX1+Zs7FL4cTNzfxfrMM+2NHYFfoYUXeiCr3jBhXB9hc/zSrkTvaOxYadzJbtYWH/AyRicYv7ZR4bRQ7amqMhkWNKpFdXdKEw39Xo9/gc6o2hIx/rV0sn/iFCX7xDuT+mwgZfY/MubVEr9telemhrXBdXd96rLPXvAMvGfxuFM5VVKZP/MtpqjLSRhYh2CRjYx0zAnupyq3cUwBh8VWUxSegOrPDWWQ9wAB22NJS4ycgpBQG+oTdkHYPDqVYkxrxRQwTKi+Bb/MHMOyYAbst4GCXdO3g1/hK8pM8tECCsYyjadJ7tFbJ7qrN/vB7DrkgJBnmfIQw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Oj3CB2152A7g1s8WRk8/anr3NdV8PCOpGearz2g1grZ9MxiYHJMCqKhCp2D54Jn+BbfRMSpc+e93SHhKdsy0l7x4jqIWSW4VEjinQp6yxXaCKXRawhsG9KUutuJvJGJdAFit6DgyRKtvTa/8i2KbnbwKWh3A1zvaXE2/KssxMPocMbqkDPIxPwRt9AAgQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The mmap_region() function is somewhat terrifying, with spaghetti-like control flow and numerous means by which issues can arise and incomplete state, memory leaks and other unpleasantness can occur. A large amount of the complexity arises from trying to handle errors late in the process of mapping a VMA, which forms the basis of recently observed issues with resource leaks and observable inconsistent state. This series goes to great lengths to simplify how mmap_region() works and to avoid unwinding errors late on in the process of setting up the VMA for the new mapping, and equally avoids such operations occurring while the VMA is in an inconsistent state. The first four patches are intended for backporting to correct the possibility of people encountering corrupted state while invoking mmap() which is otherwise at risk of happening. After this we go further, refactoring the code, placing it in mm/vma.c in order to make it eventually userland testable, and significantly simplifying the logic to avoid this issue arising in future. v2: * Marked first 4 patches as hotfixes, the rest as not. * Improved comment in vma_close() as per Vlastiml. * Updated hole byte count as per Jann. * Updated comment in map_deny_write_exec() as per Jann. * Dropped unnecessary vma_iter_free() as per Vlastmil, Liam. * Corrected vms_abort_munmap_vmas() mistaken assumption about nr_pages as per Vlasitmil. * Changed order of initial checks in mmap_region() to avoid user-visible side effects as per Vmastlil, Liam. * Corrected silly incorrect use of vma field. * Various style corrects as per Liam. * Fix horrid mistake with merge VMA, reworked the logic to avoid that nonsense altogether. * Add fields to map state rather than using vmg fields to avoid confusion/risk of vmg state changing breaking things. * Replaced last commit removing merge retry with one that retries the merge, only sanely. v1: https://lore.kernel.org/all/cover.1729628198.git.lorenzo.stoakes@oracle.com/ Lorenzo Stoakes (8): mm: avoid unsafe VMA hook invocation when error arises on mmap hook mm: unconditionally close VMAs on error mm: refactor map_deny_write_exec() mm: resolve faulty mmap_region() error path behaviour tools: testing: add additional vma_internal.h stubs mm: isolate mmap internal logic to mm/vma.c mm: refactor __mmap_region() mm: defer second attempt at merge on mmap() include/linux/mman.h | 21 +- mm/internal.h | 45 ++++ mm/mmap.c | 262 ++----------------- mm/mprotect.c | 2 +- mm/nommu.c | 7 +- mm/vma.c | 435 ++++++++++++++++++++++++++++++- mm/vma.h | 103 +------- mm/vma_internal.h | 5 + tools/testing/vma/vma_internal.h | 115 +++++++- 9 files changed, 634 insertions(+), 361 deletions(-) --- 2.47.0