From patchwork Wed Sep 27 16:07:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13401333 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 DBD73E82CB0 for ; Wed, 27 Sep 2023 16:09:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F0F08D0030; Wed, 27 Sep 2023 12:09:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24C788D0095; Wed, 27 Sep 2023 12:09:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E59DD8D0030; Wed, 27 Sep 2023 12:09:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CA79C8D0093 for ; Wed, 27 Sep 2023 12:09:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 99F3B80204 for ; Wed, 27 Sep 2023 16:09:26 +0000 (UTC) X-FDA: 81282862332.09.4246AB6 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 5355CC000C for ; Wed, 27 Sep 2023 16:09:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=yKldy1uZ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gYm3V6Vs; spf=pass (imf28.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695830963; 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=KtDGpCO23d7lFr+HvsCNeiHEhbnZIYWxCsEz55HGVpk=; b=XM1wdW4YqPzOdKVrJMWr+NCvV5ucLyOcsxaeJY+I53DfZftlo5l31AL/x7bKZ2gArh6guE kLEPysgQe3OZQv0aFg2g27jVHeRTENwr2QF+Oe7FwTojydX2hXbKwVPb64JslEjFPhte1M WHZuwyh/QpLFVme1HzHMRiPNMoCCwkA= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=yKldy1uZ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gYm3V6Vs; spf=pass (imf28.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695830963; a=rsa-sha256; cv=pass; b=DT95fP/Eol/rajhRohgHFecDIQjxjOPGoy8ooUbgdILp1+qoQnKldZCspNrua2ZzhpVpFB BP5YLFOfiK6fZOGux/ddXM+ZOoJEr7PMN2J6j/tmub8VDNag++GAxwVePpIUMAODoB2vwh 6KaDg+KR9sbkZhiYtu1dXMdCITgJ27g= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38RFsmvx006126; Wed, 27 Sep 2023 16:09:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=KtDGpCO23d7lFr+HvsCNeiHEhbnZIYWxCsEz55HGVpk=; b=yKldy1uZWF8RIyH3DtlG298o/UfCCCYrsKA9h6wogUGTYbmtDJUEzT7F1noT9V7O4/de wGBzsnTpY+U7/O7AVX6J3Wbh/xtUDTM7PcVTHpf0EV0hEKS+krTwsRoprJD+yjQ9s74i /2MGXzT6Z3tJpLaX9GAMX7f80+q3soOhK8csw/H79K+ywc6gcf+jO19wy66c+i3JW5Sy rFiuEHZaLHFxzkL1t441bhwNTq4gDLoxvXhWLp4sqimv1D6UOAEBppgHTRNATnb8Yn17 499d5Q6o4oU40+SaKHhHkZ6MnXmQG2F7gILRhXDf74AgEoU8zFgDka+gUuoVLu+v8E1k Hg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9pt3t014-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 16:09:18 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38REvtav034938; Wed, 27 Sep 2023 16:09:08 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pf8egah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 16:09:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c11ENeWKMNgiXlwSnOFnSfpMnHFd7IcWo8DMi+QzYL/gHN5V2JsWOvKDFPo1vXx7BazqzIuOIToR67H6KS46oGJ0kcelBs3ziLXq9CH5R9cRkjuk0jQ3uWCaj2I/JozQd/n9742IcNo2nJ6n47SBLnSUTU+6ZIWUVXSlVRRbX4XufUrasdRANYNHKAYatXlOptFL2oum4LAkdG9vuKqrkswPdPZG9Xc+X861ZCZ5riG4Jx6BDrr+4b62Vrb7tTvY+HgoUo/u3tARbSiSekz29o3QkDblBJskJB7g0ddxoGOGTW9IZa+4qB3IGNsymVFqABUVLwlMvrJLza528JV5Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=KtDGpCO23d7lFr+HvsCNeiHEhbnZIYWxCsEz55HGVpk=; b=JLVYC66YNMPWxZ2NsZQY+EoA63PHZRsFdbnwprtESckWbVJ9sqtMya4myfHRsC+iacXoctrR2BG7NmaX0gLqR+tS0LxvcKE2fAYBXA9BeMcGaDTYz5OR5JsiJoMp5uS/6rLQU1xpsUOVIz+fkAuCXfxkzYHENliOp2YflwUQUaRzYa3N9gT0DDLLRK7RVrjfPBoPjsPMrtVLAZ8BGNzcGGUsqx1t9+rBQlPwl6BfzSf8QGlDT2TvgYzHo81M2ygXPjQt7McNo2w7kTdfuxQP0wkQagLEHMENAURWo7Z4pasMUCR53yhn6XTt5N9TGa08eSWWtO84xmQEyboZQENpSQ== 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=KtDGpCO23d7lFr+HvsCNeiHEhbnZIYWxCsEz55HGVpk=; b=gYm3V6Vsw8YY2zX+UdwCZwBQSmQCCEEowkrgaO7XfSkRREVtjCCsYN+wqjzzL91obKq0/1VY6jlV1ztvoW7G8wR0UZH1BxsvoFX6cN/6pJuDqXb8CWnsB3g4H+gcWWmRVPLRQ45ffqR2neEcAMWNdE9XtBoGaZlqDoXR+VXOhEs= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CY8PR10MB6732.namprd10.prod.outlook.com (2603:10b6:930:97::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 27 Sep 2023 16:09:06 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa%4]) with mapi id 15.20.6813.027; Wed, 27 Sep 2023 16:09:06 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jann Horn , Lorenzo Stoakes , Vlastimil Babka , Suren Baghdasaryan , Matthew Wilcox , "Liam R. Howlett" , stable@vger.kernel.org Subject: [PATCH 1/3] mmap: Fix vma_iterator in error path of vma_merge() Date: Wed, 27 Sep 2023 12:07:44 -0400 Message-Id: <20230927160746.1928098-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230927160746.1928098-1-Liam.Howlett@oracle.com> References: <20230927160746.1928098-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0479.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::19) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CY8PR10MB6732:EE_ X-MS-Office365-Filtering-Correlation-Id: bc9cd043-41e3-46b4-59f6-08dbbf741356 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QCaZOQtRrody5Ui+mw+F8dC6UQuYpu3KSz/SmY5Jknl7zXvoI+gi0L9VCi4n01EeAZwnxfnTS28FXLe+LMoSERjSGlikaPo+5nou24mMuJGwJbyK2ih33ddd38mAlHb5eOU4AtuRwPqOWOAMZHddDCATDDuf1qaIDSbztcQaMQeSuqV7IdrVqQahmff5NS3Ew7zajnF9F6yEdQqZkYbpc3yOhmU4HAHcQB7b9aBW/GtyiAExONMTmdEHO4xeqYzFBwtx+xNA+I8Wu16K2WlyVx1SKlarKOoc0toWRE1+OlMXfs6E82BkmplQ1Ia+PWha78QjSLtzNGad9I+DfkJfFlti+gr8mVTPa+A1/bjTLWes1fZ7p4txLQhyFZpftwHzf1syycPg1fxl/e1JM6TYdZlaO+7C/f4wUE9DSyd1B8pH3s+OWNPX1+rZGT8FSUImpMqBNnDRXA7Zsu5bg75mz14IMoFEYCLWouaRVDlGqxO6HuS7LMB/g+kJYs2c5+DFEMWmBTGI5ODmunhJDS4+REluJwsvCagzlyUh5J2RDhc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(136003)(346002)(366004)(396003)(230922051799003)(451199024)(186009)(1800799009)(6506007)(6486002)(6666004)(8676002)(478600001)(26005)(8936002)(54906003)(66946007)(7416002)(2906002)(316002)(66476007)(966005)(5660300002)(38100700002)(4326008)(66556008)(41300700001)(36756003)(6512007)(1076003)(6916009)(2616005)(86362001)(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GcIwnYlrWqP9ngiEFlyV+tXHwMeaaHGsEUyuux9mADa+Zt7o+RopcsKAcPb12SnxlqMEAW+scDh9ECriyoABYVKDyZSwUqezwbevm8fhGVV56B0ZDrZAWvQrgkqxPXetzK/NmP8FVGyKCmm8mlnBb76MnlVixlSVvjcupD88JxWK0KGbcCKjx+0uOEtv2Yo+AB+Rnw2nsODL8Z1DKS2n9iOpJsfkBnElV/EtymvPNJwc83Rkb6neTgRFp29E7FBgrdqzFL7sRe66lfjreONw28/x+hFUZDTLriq5b5w1JlBujS2aVPp7N3q2Byv8AjvGWD3rPZeiQBeE7pi98UWvgIPC1lGiwT91K+jFXQr+9y3SJCbaGGJIBbq09YWAV2bj/uYMkcyzJDd693WUn2A8qGZ6ehYW3+LHbX2K60lHA5D/LOD39qtUaniK/BjTG87rPvosShlwW6p42BtDpnO12xB6mw3SSLUBuG1Oxnf9FCSUyimvmmbFGU9i1SlzF4WsW0JGck+qEDc+2AovxQKxBr1XZnzhQ8DdZhMQHOtpc2FoGlcEdgtm15lEsPWpv5+nh9CWx2D0pP4r/KOFgHgQ28orFAiMkN67VbPllTG/F26cRzPcKs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc9cd043-41e3-46b4-59f6-08dbbf741356 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 16:09:06.5329 (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: gPL8glYBtrnKXB4dAS+4yYrwoTrvjFX7hjXCw0P5hzfsnx2Pxn2NIV2uQI5dU2Wg/VMnvH0pPco8bG3+dzTQXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6732 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-27_10,2023-09-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=963 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309270137 X-Proofpoint-ORIG-GUID: zHjT5izFqsTTEteOhQv2a817RUo0Trcg X-Proofpoint-GUID: zHjT5izFqsTTEteOhQv2a817RUo0Trcg X-Rspamd-Queue-Id: 5355CC000C X-Rspam-User: X-Stat-Signature: z79ggh7s6arcrtgewbt14c7rukci7snd X-Rspamd-Server: rspam01 X-HE-Tag: 1695830963-167011 X-HE-Meta: U2FsdGVkX1+6uORt0BofCKGLgLW41nwPl6QYHeAffY1M1RVKrE1HQ4n3loOcf19OA+52h32H1h4OQMrLyXrm3X/yShHdu3iEvJMtfvopA4goB61gmsCHPq8Fp35TBxmoufMRU8nQBfIMaSb/g76yjolJO1G4TNzQs3dKsf+dKXWO646YY832VxCVz4fE6Ib9GjroCfKJ7gdpl0lNVbWlTGE1bCl67UUHFLoLxftmS1Y9Z0VkERawL0hIAr9lxA09y47y1FfnMtv3ms49nezUa7nUiRpMmysxdAwZFns2iC+badmUmHnkjIsYp0fR+J2o7ZFGTqDQNf2yAtmr13LTtSTXqlB31KmO30Gtck+JWBSas+zrwpjnR2pxVxasC7lro4FmITa5XF5h6Ejvq66CvGpJqLvawe5+7DvnRTHxR63hUACmzxek+MZamfinhWgOdASl26JuJuImhbI+ZGOUXQyMpRxxEguooIvwhYbs3uyo0wN/Vwx2uzSiTSK2eK91jMdd6I8RIhVwbFBeUxG21bYMWq0E3VqlQrstpnQMFyU0rCZvoJyiKsQYLqucPr6FcstzYu+z/VWSiDxoyaAoANl0EUDZSfZTZw/8Gg/zQvheY49YlwhCbFE/DUZ1u+JfuLBLmECUsw4hqeX6Zql1/naglmZKnHPoACbyOPYg0V8VCciwnDKqfUHayQqVLWf0boA5WwxRkKyH3uyoSyB/9uMOlVT13SPc1VbUk16jWIGE6Bd1wTdm1WNjONWa0maPDl4HhaE/AZnDFfdR3Z4RgA5Nv66D73yP0XaL0/SqcJMY3E9ZE8wtLMyKE8lY+sosHlGpH+po/CKdOvx/06OmoS4MRPYuQOXETQoVwTYxDYxm4N/fHVs6qsnr4eULsj/wfH/FwsUfuZdEV8e07rC5kXAPeJBVUG6pBLxPjt+GSKDJtZ7x6y0Qg2gdQL6FMU4QSFDOdT0u9gw5kERfO0L kHnGoIhh KrwT4dfKzGZXumohsv5WnZMf308i5DmLRuZ/WPdJnfVHeWyhJnwKLdvh2I42BDZXVaaEOhBCvKYiyWIY4hifj58IXmt2q5wNVkFUY+F6nGbGQseLOVIMZnEpMOHpbpXsW6S6D7uLY9L/LvTaHvFsQ4ZGD2yjPw3phoD2yq+pF32AXJ6rR0iudo3Tq4EhAXJAp2OHWO13qVbPyt1LsNu1eYMy7wT/kmTr6Rz7Sr+OVa3IQl6lvOQAVJS6e/FDAVQjmcdbKXt7T1jeOe2UoB4rmvs+HK3HkD1YRFZk+w23ukY7bteU8Tqhm+bPSn1bzR0iJvXIVVgn6APmj+5xx7aK9zq4YSeqVawgnBhbJPaqWtUfkkSNZuNsY8s7WhkKkcOMmq+QAEYQkOOnojwaMCp3+ZYFXIQ1YM48ic4ZmOUQmHT1YqKhmwIQR4ekOBmF1hUA/yboVBkW+qXQo/5C5YiFZ6YIYzN8L9jJxz0DBITKs7MDWU4SBEZ3bDdM6f+SGFDX6FXisejS5XHzUZIachlTYSp3SUmZqN7vgGHuap1gXCBgDKNFuurrK3MZ1KFEtz3gh5bv3 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: When merging of the previous VMA fails after the vma iterator has been moved to the previous entry, the vma iterator must be advanced to ensure the caller takes the correct action on the next vma iterator event. Fix this by adding a vma_next() call to the error path. Users may experience higher CPU usage, most likely in very low memory situations. Link: https://lore.kernel.org/linux-mm/CAG48ez12VN1JAOtTNMY+Y2YnsU45yL5giS-Qn=ejtiHpgJAbdQ@mail.gmail.com/ Closes: https://lore.kernel.org/linux-mm/CAG48ez12VN1JAOtTNMY+Y2YnsU45yL5giS-Qn=ejtiHpgJAbdQ@mail.gmail.com/ Fixes: 18b098af2890 ("vma_merge: set vma iterator to correct position.") Cc: stable@vger.kernel.org Cc: Jann Horn Signed-off-by: Liam R. Howlett --- mm/mmap.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index b56a7f0c9f85..b5bc4ca9bdc4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -968,14 +968,14 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, vma_pgoff = curr->vm_pgoff; vma_start_write(curr); remove = curr; - err = dup_anon_vma(next, curr); + err = dup_anon_vma(next, curr, &anon_dup); } } } /* Error in anon_vma clone. */ if (err) - return NULL; + goto anon_vma_fail; if (vma_start < vma->vm_start || vma_end > vma->vm_end) vma_expanded = true; @@ -988,7 +988,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, } if (vma_iter_prealloc(vmi, vma)) - return NULL; + goto prealloc_fail; init_multi_vma_prep(&vp, vma, adjust, remove, remove2); VM_WARN_ON(vp.anon_vma && adjust && adjust->anon_vma && @@ -1016,6 +1016,12 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, vma_complete(&vp, vmi, mm); khugepaged_enter_vma(res, vm_flags); return res; + +prealloc_fail: +anon_vma_fail: + if (merge_prev) + vma_next(vmi); + return NULL; } /* From patchwork Wed Sep 27 16:07:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13401332 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 78C3CE82CAE for ; Wed, 27 Sep 2023 16:09:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07A2F8D0094; Wed, 27 Sep 2023 12:09:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 028878D0093; Wed, 27 Sep 2023 12:09:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D96668D0094; Wed, 27 Sep 2023 12:09:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BA7B48D0030 for ; Wed, 27 Sep 2023 12:09:26 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 87201A0D6E for ; Wed, 27 Sep 2023 16:09:26 +0000 (UTC) X-FDA: 81282862332.10.59A1E3C Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf05.hostedemail.com (Postfix) with ESMTP id 38728100017 for ; Wed, 27 Sep 2023 16:09:23 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=BuOaCPE5; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=m0hheYBu; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695830963; 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=wKLO5aowMtFkN1v6flI3U2j8ilZzZwu3h9RuAvaF98Q=; b=Nos96N5yH4WXQveKL74XJeBq5HlISoe8uecB7CcVqU1LfSaEN1qt9f72vDzkvEpVECd/Nz aDQUOcyMlMpvDpgiRDFa7i5uaVI1J8USVVyXP/PCg/F/oRTsREQWBo5KLjpAo4Y85ZR+V1 2WHUBKbCnTmZKBmE2IO9i0vm9FnrAe4= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695830963; a=rsa-sha256; cv=pass; b=wYoSrgUEylunPFV2hU2IuOdfmg/7nFl89CMEqt6Yw9UKj6IfcxDzZIZO54iEmZ2dFJeHFq EkTdsxbGEDo0LyzEFq4aAFaEATpbzqfwdCwiTFShVATdEwHpxUv5K1l5RkvK9dRuXSv5Ia RsSbREWV0149bReYSmqCQ8gIzLnS82s= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=BuOaCPE5; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=m0hheYBu; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38RFsmvw006126; Wed, 27 Sep 2023 16:09:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=wKLO5aowMtFkN1v6flI3U2j8ilZzZwu3h9RuAvaF98Q=; b=BuOaCPE5a0NvoY16Bo3RcThian0yWndqUHHRIjjmzZbZ0mABEi1aQeG82RSXYyxKbBVf pFlISRxFXwKEbmxrhyDzWjg13kft7OcOww4wPuNf0RDdw63sHYkZn/Vy/ECJxpy+l1NI HRpoA0nIaVysbz1HDgNeox60woiIA26bO4VBZavx7FEtJSN7ugR2lGRLyCYzkP+U34Fl wa++FRUXikWobqdK5xirFmHGMDXjCHIN5c3w98uxLk68y2opiUosFS0IgfCKoFaQ2asX uE5d2LUL972zJWLPXVtEFL+W2ZR0vbR/TTbzv+j2LsloxxJ56ncU6jDFu9C9NKWUpAEK 1Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9pt3t017-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 16:09:17 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38RFQw3t021222; Wed, 27 Sep 2023 16:09:11 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pf8fdpq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 16:09:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jna6sIBtWOHJlew6LrZorg+N7mxEdRLIGCbab/rwDrTGMIz67FVkR9EoYRJvR4ehGUzyJrMEo1pqQPWvdaobgxcsgm282ZCpKxfFFxgRooMsT/eR7SOpFxhfUNl1XR4gLW6BvQ8Vi7EoSK6OM2P4ybdtHooWw1zziv76dP+87IWLtwfYjIX2yAigz0tlkuTSCtremGNMygewDN42k5289Zd2vyGkpVAUJIEm/nytR4ouz+y+LC/lwwc2jkG0VrokbRo3e7EKj3U/XsRwDCxJZxpv3M9+3oza/JeAsKjyXzx+XnRNKNa68lbFMVtWtwHy+vfcIEhT4bP9X69LYo3Lfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=wKLO5aowMtFkN1v6flI3U2j8ilZzZwu3h9RuAvaF98Q=; b=eadwhyJ058Ct8Sgphu9Odr36RILfnadmEBf6fWajnTmObEzjB5icNnMhKqwcpJzxpB5z718+8pZ9Dha+Y+ZbcTBw/zSJlBIa4sLgDCNNZVbFw3zW3xcZf9ZfhfqvOffJg8p9QWq5h/p1tQjAal2AKz3ybNrKjoLFnyeUPGgvLeaj3ZXJpRQ2yZxi/NvfMiCTqKk1gbqgboZiITsUZ8rkhBHOUc4xF3YlsirNSnE/nTamqkpzejIRiPF5Ur4uzbpmoLgSHLko4phICwigteOwJoKOXFZegXHSRgZ3+VDJS1aVMlFlAj437krDiVPkzxCNHSEt6xS1jfSN/57NY5ZryA== 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=wKLO5aowMtFkN1v6flI3U2j8ilZzZwu3h9RuAvaF98Q=; b=m0hheYBujpxtq566mTbKEuyk6CjFbDHweCj6+nYfodXfJnFTlRskaxXo5xG9xjEAgDWxeGLVrjanfXAI99zRpTDFFUQBhUCrhMnAFU+Y+YdUwujW9wXZKgeblE1oUgsiOx4A1WzQRC5MTUdeCsgJ52vVwMl63ixeR6BG42NRBfs= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by IA1PR10MB6122.namprd10.prod.outlook.com (2603:10b6:208:3aa::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 27 Sep 2023 16:09:08 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa%4]) with mapi id 15.20.6813.027; Wed, 27 Sep 2023 16:09:08 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jann Horn , Lorenzo Stoakes , Vlastimil Babka , Suren Baghdasaryan , Matthew Wilcox , "Liam R. Howlett" , stable@vger.kernel.org Subject: [PATCH 2/3] mmap: Fix error paths with dup_anon_vma() Date: Wed, 27 Sep 2023 12:07:45 -0400 Message-Id: <20230927160746.1928098-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230927160746.1928098-1-Liam.Howlett@oracle.com> References: <20230927160746.1928098-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0467.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::23) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|IA1PR10MB6122:EE_ X-MS-Office365-Filtering-Correlation-Id: 2084138d-d534-42f6-a89c-08dbbf74148e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IOgQSX7y6QWs/fnHOiPh43XePlQW2PyBACrt3D/D8H2WeDGGoutXoO11cNz3ONpQ7Ro020dyOLp6jYQ5o4GlDWQsBRb1wJsEpj2p+3iLXS9vjET5MPnZm7o/1Dj7Z2n7mDpXUPXQUZ3MXG/ho4Xk5JE+gyGehk8ILvQjfm0RaQSs0EXBwvXaCscWEJPuJ1QEIIMAbhK913RVfPRG54CIDT8AfDNusEfPJOGR5DFEn8Yrr0xgadcnqyXg3nq7IrjLVh9SKFD03n6pHohHfAxxnghgZWmOVqWgpOTw/0z1wFvgnz8RlgBEW7RHm2iuKXlfzEhSwOaQy5VBRKLNWD7TMaXPcDThjl0NsSTjHli0O+0c9dckqu/ppDzu6AdwWrDZYmoyXh9q6AofRG0xfeath5vxgkuhM8YPjj4kTBFyYwTCCgjlelmfa0w9lWEGhpT9+TIIg7Sbo/OXsyjrKAWcen3/YZ78c+Ro2MXA1/fEzV3hT4MEgpjdrtlthCMLFQWwrxH9X9rNLgituQaw4frUsEx8hRFPrD/BLEBPOtiqOMKqhFDJZ8FyoO/g1Bm8P1xj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(376002)(39860400002)(366004)(396003)(230922051799003)(1800799009)(451199024)(186009)(66946007)(66556008)(66476007)(38100700002)(6916009)(54906003)(478600001)(86362001)(2906002)(7416002)(316002)(6666004)(36756003)(5660300002)(8936002)(4326008)(26005)(83380400001)(2616005)(8676002)(1076003)(41300700001)(6512007)(6506007)(6486002);DIR:OUT;SFP:1101; X-MS-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n+QPoiVvzzfRz6G1RpaVOeWdLriQAqArgPLHtx2/Jv3UZBF1YQpNJ9hoKmlmoRBbToDTkrwm/QQQJrD2AMXeFdx9Sprca5WyFnQVLC9biE5XWBt1f6052NWQkZcONscmDL8JGYTCHGBxeHJUNUPOmyrBDURKN8E1T/2eL7+f9eX2sp00ZcVkjxev/TCaU7ojqUMyT1sqEtqTz+4yyOGJxXXteedcsEF9XcuPLPqrb79XHkXRWmPJ6ujP76XHLStWJ4l57YcTWB+0jnE0cAhGcp9FxDffcDar1huswyfha+6mnDTh/x62s+THGCefBG66FMK65Z/5lK4XUdTb15jEoOHS8MQT4cB1RbaTvoSBt+Xb34wtFsPdL0bBAdohB6Ym4pSghES89OnPKAeAIgK2v1tvnMYkNgWulo/UbbnaGOP1YFo27bI8PCq70fv3oE7abaiiVlVQdCdJYLP9+m4tzWphzil4RI/i/+1oLkrs5tkw5eWu8vtLPxlYDMcuz7clP3LTWMXXa3BsmHbdqFXQc658c74JjDQoILCwT9ZJGUrXaXdqfszd90bxHvDS6oO0fPqmkl7hiI X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2084138d-d534-42f6-a89c-08dbbf74148e X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 16:09:08.5998 (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: hSK65zzy6aX0ZDPHhnGeXodhWjVC5Q1YVolwB4RN11uSzDXeQwyMY9d4jGlIsBn7C3JY9xnRHfVnYJYHHbWUfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6122 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-27_10,2023-09-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309270137 X-Proofpoint-ORIG-GUID: StTGcNikf1_B-Srv0yNwqwz89SOIiU6d X-Proofpoint-GUID: StTGcNikf1_B-Srv0yNwqwz89SOIiU6d X-Rspamd-Queue-Id: 38728100017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: swchpwhhmeqsmegejwrp9sqbm7jie4kn X-HE-Tag: 1695830963-210946 X-HE-Meta: U2FsdGVkX1+p2fl4U7+jAABxjzxcXQjMc7OMaWHjwZtAzNU1yEIvIFg1rinTZNr72oHmRpC4CUMFehw0+5Kf8sNvCgUkpwwHuSY1rzhsYex30j7Pqlwmz2Y7WqUOEjYEd2sgvgo04lpgo+URdHdvSHOwT/Z9ZKOylouoZMXP2iWbQE9LEax5Gic+lFCLulzfoDVBS6C2OXrBZq6qT7YFG7JgenVK+uqZW8BgI/brppkQT4AJGukfLjKvKjepYxhZVbLTqzBabDbGNfT5jQ2jwyLtS02ySpUM2uryvu+ze/oJAkV18/GK3paxVZj6zBovMnGLlGY6a7s88q545ihl7D1mh1EFSrreHITVnp4q2TF5Tex2fFlk7+yT2hWJ6N5894RzO2Nyc2Nh/N8M30btoiOU8SiJbtdF2NCybaWS3QGynpJJ0UCRIpl+y7dsGv1JXzqWIKYMBO3AkmOWXgPy3DpEt5b0wp+F/Fs7p3OFjjP3kyKHuKsG3svnHbimjuoMKOLPhvQJCCdF+CnYMsABxcjjUymhoOvmRVWA8u12Ss1W0nYEL6lwq9d4ECxLThv3XnGXK95rodwzcaMk5YN5hfVAFoTdr92hQPPoKAh2SgSHLkVA1CXm6zqVg4anbCpsR2UHIxBcn0+xEbs0hpH6jcUXbGk4CQQGfn/nHRWZxkCpfrXm3eNMcEdEl5XEpccElBBINIvrtF+kJ1MJRt4ByHJUOJ/+LSqOq7wGfrKwnLGAzWUlXd+jJxYLmo87c2uaMUwQH28gFCevJzegt3gYoh3chW4kqxBlpuBmsycJ/UXY9gtrS1cqjZarAIG7KRVINuxpEqklDrNeqJ+hefTAVhq6rsF7fIwXeYrpOfhCLpJ7JN/o/iQgEBOaO0vFofwqucanUSSeTjcZrLS7C7vnaFTDojE0KktD6cuHmg8MTNGp8YLkvf49GU0ZEu+iRGvNNPPBT3wHqM699jasLw9 2gNC6jZU Pl/b/L8ZD3jwC42g5nPVapis+C+7eXAkh1bkB2uwVzuzUkscfIuBtiTt2YZP64GY2YjyHr90BoY05lTkVv5NUwfFl0jKkDHroiajQbA2zDrh61jwIbQLLV10KGDv2FjD04HJ6HloFIuu5NTpu6bY0zIBjy63bsCm5K5fEAD7XG813OgTBWKG73fyNzvyp9JGBMZyciMX7OVZwTv+zK3lBWTHJqcKwPK8KE3iI5vcHpwrcIIs5iKgDBXOiH3K6XLoOV1uUv/Hwgc4sLuwhSHSxxecqozkZRXh/LppNMammuRVemrFhb+LGWGicgTGrMhGQ6cmi+kDxH72obXmLG2tQ1qtSx52eAprzYLhwwetSleLmVOtIBPlQTO0Tum+eUM8HMUr8F9s9DeCLEzJiZeshMAAY+rjMOjt6FN66UA/5xDzY15fl1VcccpZrQ73A4TXfE1MyPi4scAD2esrXEnWiPRzbaYxx0wkvJKferg0p7gslzA4cBILlTq+iq8uHJ0kG5qC4ye7ORBJ7Cj9x2V9Ilu3gibZAwGp9/0hx 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: When the calling function fails after the dup_anon_vma(), the duplication of the anon_vma is not being undone. Add the necessary unlink_anon_vma() call to the error paths that are missing them. This issue showed up during inspection of the error path in vma_merge() for an unrelated vma iterator issue. Users may experience increased memory usage, which may be problematic as the failure would likely be caused by a low memory situation. Fixes: d4af56c5c7c6 ("mm: start tracking VMAs with maple tree") Cc: stable@vger.kernel.org Cc: Jann Horn Signed-off-by: Liam R. Howlett --- mm/mmap.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index b5bc4ca9bdc4..2f0ee489db8a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -587,7 +587,7 @@ static inline void vma_complete(struct vma_prepare *vp, * Returns: 0 on success. */ static inline int dup_anon_vma(struct vm_area_struct *dst, - struct vm_area_struct *src) + struct vm_area_struct *src, struct vm_area_struct **dup) { /* * Easily overlooked: when mprotect shifts the boundary, make sure the @@ -597,6 +597,7 @@ static inline int dup_anon_vma(struct vm_area_struct *dst, if (src->anon_vma && !dst->anon_vma) { vma_assert_write_locked(dst); dst->anon_vma = src->anon_vma; + *dup = dst; return anon_vma_clone(dst, src); } @@ -624,6 +625,7 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, unsigned long start, unsigned long end, pgoff_t pgoff, struct vm_area_struct *next) { + struct vm_area_struct *anon_dup = NULL; bool remove_next = false; struct vma_prepare vp; @@ -633,7 +635,7 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, remove_next = true; vma_start_write(next); - ret = dup_anon_vma(vma, next); + ret = dup_anon_vma(vma, next, &anon_dup); if (ret) return ret; } @@ -661,6 +663,8 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; nomem: + if (anon_dup) + unlink_anon_vmas(anon_dup); return -ENOMEM; } @@ -860,6 +864,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, { struct vm_area_struct *curr, *next, *res; struct vm_area_struct *vma, *adjust, *remove, *remove2; + struct vm_area_struct *anon_dup = NULL; struct vma_prepare vp; pgoff_t vma_pgoff; int err = 0; @@ -927,18 +932,18 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, vma_start_write(next); remove = next; /* case 1 */ vma_end = next->vm_end; - err = dup_anon_vma(prev, next); + err = dup_anon_vma(prev, next, &anon_dup); if (curr) { /* case 6 */ vma_start_write(curr); remove = curr; remove2 = next; if (!next->anon_vma) - err = dup_anon_vma(prev, curr); + err = dup_anon_vma(prev, curr, &anon_dup); } } else if (merge_prev) { /* case 2 */ if (curr) { vma_start_write(curr); - err = dup_anon_vma(prev, curr); + err = dup_anon_vma(prev, curr, &anon_dup); if (end == curr->vm_end) { /* case 7 */ remove = curr; } else { /* case 5 */ @@ -954,7 +959,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, vma_end = addr; adjust = next; adj_start = -(prev->vm_end - addr); - err = dup_anon_vma(next, prev); + err = dup_anon_vma(next, prev, &anon_dup); } else { /* * Note that cases 3 and 8 are the ONLY ones where prev @@ -1018,6 +1023,9 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, return res; prealloc_fail: + if (anon_dup) + unlink_anon_vmas(anon_dup); + anon_vma_fail: if (merge_prev) vma_next(vmi); From patchwork Wed Sep 27 16:07:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13401331 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 DBF75E82CAF for ; Wed, 27 Sep 2023 16:09:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AD148D0092; Wed, 27 Sep 2023 12:09:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35C3F8D0030; Wed, 27 Sep 2023 12:09:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AE588D0092; Wed, 27 Sep 2023 12:09:23 -0400 (EDT) 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 083A58D0030 for ; Wed, 27 Sep 2023 12:09:23 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C9A4A1CA3FB for ; Wed, 27 Sep 2023 16:09:22 +0000 (UTC) X-FDA: 81282862164.30.0D85FDB Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 3F97C140029 for ; Wed, 27 Sep 2023 16:09:19 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=LnrCc9QX; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RWL3FX6D; spf=pass (imf09.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695830959; 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=oqBlX4M5rM78uLOs4RJ0kCjmcY3RQeZAYB9nLkDsL14=; b=1jzCZ3oux+HKfuXJYu+r5OjABZ6sQ6xvBDmW+uU2xQIS6+3Nxbx60yB1do6LXKWMUg+rD0 KRAeNqMvcnaz4san6ha87A89seRKpJy90Uzn/6kMb8Uf2R4ppOt95ZB1KZZ+kQlS7eo1dV 4eN42v2Voo28Kcl993cEu5AKbO6y+EQ= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695830959; a=rsa-sha256; cv=pass; b=rzEWJZrwmNe6fBlyAHjInLblG+km4Yma3tjlteQH47hItvPccTpKXtKG7plV4HA3FcvhEB VU22pzTWaM44JEzOZxg6MSseghKqsOvzAT07C1b6zw/71sc1kMM21vey9DCxnlzL2cmwHK UCmioGvYX9Ug7FE83oD33F7EmWsSAOo= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=LnrCc9QX; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RWL3FX6D; spf=pass (imf09.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38RFtnid011846; Wed, 27 Sep 2023 16:09:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=oqBlX4M5rM78uLOs4RJ0kCjmcY3RQeZAYB9nLkDsL14=; b=LnrCc9QXS6HNkCO0qdfM8Q9/NuHLfGfT8DXxD6rSweX4uX+IjhoeiojDNghNduZTxfqJ hmdUYsj0By6AH7zLW9owcrNA6A5t0HR2uiU3LhqNfBv6OQX4st3wJh8+1sVpvMJ5atqn Uo0ffJAYkyDoUZPg0rJxuWZTm3rJKnPxtlnNDSELQV+wLRiFTPFWj4OGqn1jhaSX2RXG W30c6RlTdPoHHu2a9CdC2TE33N8lk8Ap5rI6K4OOM695v/ahE/wNualLfHEO/UCqMy7O JS85O/cr1LjnAOas2okQPpiD0si84nQql4/Pfv6FlN+kxyTklnhxkksjbintwKwr//vv QQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9r2dj2xa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 16:09:14 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38RF07mI003188; Wed, 27 Sep 2023 16:09:13 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pf8fds4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 16:09:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fFvCqk8bRpYYsWWrgmn6I/bq6idcZcEdWaQHXanjzLY6OsXGi191y0lFLX9z0tOUzxQCpPM0ndhgDxDEmXhS/0pmS25dw0ByAl/lSzW7xcp5H90GqKyMCVSPvbsvUYa0OpU6WZMXbJlsc7ek+VVXyFAm+LKoEMPc+HbXYBKjt5woxDCC2ZUGfTRscIY6uyQTlzrWCxDtCUAYSPtoONgMY7q83UmkMCuBuZ1z8/v3CMP2Yk3x2HaCOShFd7lpsxWmXuJrZSXoe4RRVPUZG8x/KFLLRcVbUT1ZOz2G+XQd9RKW2ysMwRIrD64fJL8T98wDg4a3KupFYJafZ5EZzzF4/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=oqBlX4M5rM78uLOs4RJ0kCjmcY3RQeZAYB9nLkDsL14=; b=MNE70n33LsJ0hS4/lcFg4HG8kAocjxoAkdMcT3e0A4s4orU6vzftRZTuBYsGzY5PUu+7Vrw7JQVKtgOSwjejwP+li7x7H2ECwfZkDrv3XI4b1/STLVv+Fq/VBfyHavuHyV2+RH9rqDq7zLyrnsqNqrJE2Y+oZMGf6cG2jofJn123TdCszCApK8lG/iPHhQTxZ0cIjGSwDqrlQQua2qFyHI/Cae8hZ70/LWL8wVSJpxP6pQgUN8UPz94T3cyDDw2g0v9ALibe2K2T7Qe0XqHYyGPctFvPjpbe9P2rrovTpAj7HDZ2F7+/GvG//16dZ8Cd4S71Ph2ccgHPuYoOiCXBnw== 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=oqBlX4M5rM78uLOs4RJ0kCjmcY3RQeZAYB9nLkDsL14=; b=RWL3FX6D2GulVbl90FBSxrDxcK4odSlU1hMNTuEMjnhBdzONgUZmaS/7WEFVlFtk0xrNrq8egpaJejBfiAp06K5kNC0UHg/Ar5Xs+wpV6xMsLFPZPW87Wu0rfm5DaCeWdd4nd3W0e69UYEMYfO07AjudSFX71BhJcr3jMZ727RU= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by IA1PR10MB6122.namprd10.prod.outlook.com (2603:10b6:208:3aa::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 27 Sep 2023 16:09:10 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa%4]) with mapi id 15.20.6813.027; Wed, 27 Sep 2023 16:09:10 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jann Horn , Lorenzo Stoakes , Vlastimil Babka , Suren Baghdasaryan , Matthew Wilcox , "Liam R. Howlett" Subject: [PATCH 3/3] mmap: Add clarifying comment to vma_merge() code Date: Wed, 27 Sep 2023 12:07:46 -0400 Message-Id: <20230927160746.1928098-4-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230927160746.1928098-1-Liam.Howlett@oracle.com> References: <20230927160746.1928098-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0467.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::23) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|IA1PR10MB6122:EE_ X-MS-Office365-Filtering-Correlation-Id: 5907b717-65c9-4527-0bc2-08dbbf7415bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GzqrwfoIxVMHmuax0JIhDby6Udm3jXlVqAHxhoVkaWmxivXx/gN5DsNYlkfg7KHv2O5wS1zWRpSWnliL9Zt0zrcHTJqLUu4SSvyFyFMDgoLz05W8Oq/06Z6JNhXL3olGFVWdDOzHEC2kdvN4fHlUnFVgVfGxuDadflPCN3FR5K3BboPq25GhFpdosHVrfnH1Czbt0rG9eTTO+fMTZKy2B5tx9fdu7G++DSJm0uDTPf5JYNBBN/i/w/pHnh+p5fA04+pTKf4t4CHeYHkM61L6XQtYY4DL71AW+rCodmYh4E7KH0T5OlkgR15za2d4LpCohgcIo0XBKgeYoElmW+ipk2nmxxMUWUBnrYbML2IlVxkD1eAZ/3by/zQ28PsPAzSQq2WaqrJn1zzXOn4dnqYAlunTdKR0DlINUKtorDg0gCRTKzlliGBfFflel+YFQp0tYGCEicjLUAgz1bLEDU4u0ypQRvmSTlJvMelMn+2xUCXA/Q4w8TNypYQPjnbvGd8BoJo8QDjlLkYV3Ce9j5ailAhwvzEAxmyPhEop5nd437o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(376002)(39860400002)(366004)(396003)(230922051799003)(1800799009)(451199024)(186009)(66946007)(66556008)(66476007)(38100700002)(6916009)(54906003)(478600001)(86362001)(2906002)(316002)(6666004)(36756003)(4744005)(5660300002)(8936002)(4326008)(26005)(966005)(2616005)(8676002)(1076003)(107886003)(41300700001)(6512007)(6506007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5PG5RNV8iCqNUqIpdtldL9RIvXKJGSVxtHrfmAAUdJUhzD4kds0LdHLU9DIZhMXyPelwTdfVPM/dqLT/hFM9TZiENkQVCDlwJ1AGrdkPNu2d3eOcts4X1S8N9wzQ9QhkNmvnEupRKzjRNE5szR+nJshSIcxBPtmlOcQuWWBwfkgVBCdUa3KmyfaroBdhlTWvh2qkK9U7YBz9aIu1KXqEZ0vKoHa7I4OmCfFjjsGZcJOWtHV11Jgygarh/TZ/FPTlVjQP1/Qo8JyHC0FeigbByDbjVgRwXCRWmNs/Jp4y1T1eBahpuLW8hZXnBmjx2mQQ4qy+I+m/R8mdbgG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3NgXh3Ko/kvMMB8Llvp0GQm9oRpMYkvGympfW/pdWaXKPQ7tphOymNjinq/97F71lSU21a8B66vlCDtFpIlaJ8Mb0NvfExxRb9OcvW+UZbqc59PFznxQ3v/u6kpCli2ZtB9M+L93yzM9GYNPOQbRWFfVl3Lr1+DK75vISWB35JwjkggsUIvjKF9wkvJchKnc0Rtv X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5907b717-65c9-4527-0bc2-08dbbf7415bb X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 16:09:10.5455 (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: kHSykIWf3rT2jFGjGW6Gj69G+1FIZAmXDhD6K9lRWil99ZA2nUMrjkCHb1qA27nKVpReAPhB2qs0pN/RVVKhvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6122 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-27_10,2023-09-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309270137 X-Proofpoint-GUID: 0xVaS_hhujfNjjALrxXp5q4OSLjiHGe7 X-Proofpoint-ORIG-GUID: 0xVaS_hhujfNjjALrxXp5q4OSLjiHGe7 X-Rspamd-Queue-Id: 3F97C140029 X-Rspam-User: X-Stat-Signature: ge1ee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1xpqGnmlrNF4uJUDtVAnCLe83yiEJGFZGn7fMT2aulxgYWghUk5+QZPv3o5PcGH4Pi7wkeUMHD6Cwbgq+S53+8vcK0tSPE6egmjl6s5NkHtxCXvDIUwiSide2a5LFlyOUGyqRRBjJ+tagz7t6YOSaK9wfKLwn5xWf4ayhWruDmvQjsStpuunwMCHp8SwCX/cqtT416riyINy2AGlX5oCBmKXpwy8tsNGAx66s6LKySQ1/barS6VrF6JUxwv0NiD3XLtAFE0YDFqlEZVGuYhUZAJEk7SiFkfSWPNz+kRqqZ1i87/FevKyeMSAsLp8KpPLiAagcgxcjQKmCSYGSyNd3a8gBwwSoq8bYL1IRu0oPj3qWvPLvgRmlYbjwgkZD3V5+s4lFhJ4jMeGmtR1klYIzH58WKxKwaffjjGN6zuOSrm4zWfuIn65F6JkUaxp29Rw/uEOjbW8TR+Rt6m+W1edDDHu4yClX9r6U28mcGW5oFnWpsxj7zpW1cqXwUseIRsLVeOZH+soSpWgAMaTSTkW3IJMD7xgcV5TDn9R1/dC2ATTfUaD 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: When tracing through the code in vma_merge(), it was not completely clear why the error return to a dup_anon_vma() call would not overwrite a previous attempt to the same function. This commit adds a comment specifying why it is safe. Suggested-by: Jann Horn Link: https://lore.kernel.org/linux-mm/CAG48ez3iDwFPR=Ed1BfrNuyUJPMK_=StjxhUsCkL6po1s7bONg@mail.gmail.com/ Signed-off-by: Liam R. Howlett --- mm/mmap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index 2f0ee489db8a..3c78afb707cf 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -937,6 +937,11 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, vma_start_write(curr); remove = curr; remove2 = next; + /* + * Note that the dup_anon_vma below cannot overwrite err + * since the first caller would do nothing unless next + * has an anon_vma. + */ if (!next->anon_vma) err = dup_anon_vma(prev, curr, &anon_dup); }