From patchwork Thu Sep 28 17:16:32 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: 13403337 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 33F86E732FD for ; Thu, 28 Sep 2023 17:16:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E8618D0023; Thu, 28 Sep 2023 13:16:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26F4A8D00C0; Thu, 28 Sep 2023 13:16:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 073F08D0023; Thu, 28 Sep 2023 13:16:56 -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 DE8DF8D00C0 for ; Thu, 28 Sep 2023 13:16:55 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9BBD11403E8 for ; Thu, 28 Sep 2023 17:16:55 +0000 (UTC) X-FDA: 81286661190.30.219FD13 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf30.hostedemail.com (Postfix) with ESMTP id 1548C80023 for ; Thu, 28 Sep 2023 17:16:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b="xZ6QuJf/"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VwAY40M8; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf30.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") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695921412; 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=ReaEeKMqxObRXDD9d8gCwYRWB+q/MHS998BcLo0Q20I=; b=jxyU35Wq67JvNU4AbJ7TF2ZapZImUozawLp5XbTxEn19nWdpI8GV3Nz180RWB7BP/Ojpyg JD3lNlg0fS/j8S7yzhg3Jamr6ZHLhVpfNdehsYu1TfiZP2NpzQbJeQx5hlwP4oyYzswDG6 tpGdmEC8Qjhbas9OwU1IWko2ttPhUGM= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b="xZ6QuJf/"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VwAY40M8; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf30.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") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695921412; a=rsa-sha256; cv=pass; b=iWolsouZFy9Gthnv1QJRseVHXP8KsY8Fubbu4F0BMXoXd+RdL+C8w7uBuosMtu9Qw+686r X1ryAkwEzd41XAdwokP9Qlh5FoL4ZX6n08gdzUgvtUYb22OUgyZz3dvdOGKpp2dzPMmP3v e8kssNP+f8Oi4vnCfYd1L/ClyPmh920= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38SGi5CX027549; Thu, 28 Sep 2023 17:16:46 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=ReaEeKMqxObRXDD9d8gCwYRWB+q/MHS998BcLo0Q20I=; b=xZ6QuJf/eOpAeSmg/mxzVkeq4IyUvushF/1POVAoz563JkauPfEFV4HsQTl+K9mTqDIw y7ijCrGCm8rn4oxb2ZkzRqg9/LOh2DQKLiScwYALoN/RXOeepZk1tGR7DbTqh8khSYcd 4u/7GNEbiRDvtCWvYPPX5sICIgwEaUA2MMkvjG2AOTKBDz/H3ONUwDCqpEBgFitbeFEq 0+tg9S4V57nGBAScUXIrWo8blU/yUOyMfcQ6vpjOpRlLNTaLlmeedzcqGnubDlNgQu4j APyn1iY9gOyak4ysiBhWwdnEzkDoEw9LUH4hvsURZzW8cfDuc6wd/dFtQpFyf+ZhBBSz nQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9qmun283-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 17:16:46 +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 38SH1oEA013823; Thu, 28 Sep 2023 17:16:45 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pfadq5x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 17:16:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eGmAXNBxBGO0ZNkUW4TIfsIlvHDghJa4x0jUgaGrv7kUobYlzjqOiYpoViFlYXIGsUL57yknHCIMQzjh9JVhWSd7nQcfdarG6O/CxkjdCpsbjpbtRzHi8pRXoNnGLnBAesOx2n1EDf6w4Ttbgut4iOE+BG4RUc+tYx8MPBIMP9zCutN7Qk5XAe7kDlxK7oNLd8IV7IFnnXJ5DCjjE1Pl4dZajLc+4zBzTi9CfouJpvfYNM5EUt35Pcz8h05kGDp6KRFKciy0+YY1BhkIebSXMCt2XpqsMoyMFM9xjpJ/GekZBjIMqS6aTM0VfxEEryyFi0qYom6iz35DXeMYqhc5Ug== 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=ReaEeKMqxObRXDD9d8gCwYRWB+q/MHS998BcLo0Q20I=; b=RC4GWWwWLAGkCtKc8ohgkE3YIIAp6RxkNZutRwy1dLejPCtdBpqKk4EHxUUYm3riMOast5jpeQS5FL6Ism0rcTBZXpveQ7NA7sTEkDKkPdqEwv5PfX9X6zK3AguznfPVWHrz2807jTHMEWDSQOCMwQ0Ild9KiegLIu5WZr9lj1VFc8jFi/aqGYIFtnog3RspWvP7enxulzrjQvrnwbyh6WiYXhIXnevFrFhhC4GdPre2WzJ8gvT3EozvJXHw/H9dntzs5poqKqaXO2QbyETAlArM7rgVW9hlwn/HbrhL4bnei3rdAwhy/Cp00/OWKijQnEsJDvrB7vvDbCyTWTzw5w== 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=ReaEeKMqxObRXDD9d8gCwYRWB+q/MHS998BcLo0Q20I=; b=VwAY40M8i3zKBaFH5YnA3cYxu8oGd0wE5Ajwvpbc7EzrSbHNnHKMARkKJpbWpVzTm/o63d16currkKBE/qMBHjHfdHyLBfrmHZpe0HvAhpXGMu/j9hoEQD7f1XNyt9BdkmYvAhTe0UA6QMxJ0VhtTH3QGa8xlpBn1y2oF6T0fPs= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CH0PR10MB5273.namprd10.prod.outlook.com (2603:10b6:610:db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 17:16:43 +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; Thu, 28 Sep 2023 17:16:43 +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 , stable@vger.kernel.org, "Liam R. Howlett" Subject: [PATCH v2 1/3] mmap: Fix vma_iterator in error path of vma_merge() Date: Thu, 28 Sep 2023 13:16:32 -0400 Message-Id: <20230928171634.2245042-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928171634.2245042-1-Liam.Howlett@oracle.com> References: <20230928171634.2245042-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0115.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:85::26) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CH0PR10MB5273:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a58ee02-0b40-4400-5d04-08dbc046afa1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 95tFYU9md8I87K93ccqrupxRyLfkJ2bRok0EbJAYQ/fqZhJmL3WJL95AtPaoA0b2wFjcmgO5TUrl+obRR0to1tuNep+acvcOQxEMTGJkuQ2Bp2uvQMrxL1MiQNLcrD0POM8d9W97+tvcE/6DPGcu12hPV2nd5JIEZOtjk8p+3/MmUUPKpy415EL1hBhkSDEiEbYmOcrnGyLvhJUQQ+CT85jERPm7H4juE0Wrei/db/DjO3zxMd/xuXgzMSJneY43qR/xOCm0v1pAIAX7rj8aBtWULLkT37BPaPhYjNYC/f25Nb0z7BSIil4y0RYNGy9n4dtIqlk0Shv7e62SKrgGvw1vcZUEJ2Z0fivEyo7nVmpNjAGLjCAPoYLUIQF0FayqDEGEMsz/Rv6AmI36FF+6I2ibd1uku7mZVuKrzI7O8XKp/q6u3ZXMNev5ZPkc8YurxEqS6cLrMKK6FgBlqbvJyMKlz1YWUcvAMTmQwiImFL2OiYvrbA28oT+EkniyaitHLA7eYbPN8sCR2OBd76AWSH6yHxhj73HmZJ0fYqnxvYo= 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)(396003)(366004)(346002)(39860400002)(136003)(230922051799003)(186009)(64100799003)(451199024)(1800799009)(4326008)(5660300002)(107886003)(66556008)(26005)(83380400001)(1076003)(66476007)(8936002)(54906003)(316002)(478600001)(66946007)(2906002)(2616005)(6916009)(966005)(41300700001)(6486002)(6666004)(8676002)(6512007)(7416002)(6506007)(36756003)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mCR+/hYEbY9gYr27tLfB3+CpQPKTwDCA9PevFZOR7V8NdV/EdXVijYN81il/DhsKcWxxcHKivvTlDZgK4yILlRBg9+r9LOSm9JhO+BH0W8cBLbOrAsL+RaWrRMHbIRDb+zPcz0QN+JeiZyOi3FiQSZMi5vUZMuTQQe2y/4Oy7qYgQfWWdrpn3uy1JtBBuqKGE3/HD0eeMr7ayXSDI/FerosXSqNJs77khYkC/LlmxtUcSyuZ26eTbzm+d0ugp7OHc5UUWpGLz59LM9SGFpbEFjmqyhGKjKrij1CL5mn/ln5fDrx4uuuQFFLVoV8ZUJCeE4cAjJyFBhFiaw/oEJ53HbjHrGRPXv/i+hNgi4+9nB68Yc2M2+fIPmk3KIuAku60nCjDvl7+17M9dHUrzQLY+c7goH8w1K0DjKCnjPYYQbu9FlOR0Vpgab9UTmrboTOtkANJqGdvu5MYOGVeUkcHQusSOPZDpSyqZomsBCCod7ijvnd2AtSJQ/bunJhp6cAz5xDbtTUmnrHKtipOFYDFGyKxHQRz2w5M6v0lp6VYwcvf2IJYOPffzotOR9i7RX9kSbyFgkgOC3X7ExEyJlSUCZXzC60ysc6kK+YiTLSudum42HltQZyiN2T6FSSelb7xjGNhGrYgiMh89JCNJdwcC4lXBWL7PFV+NySel4P08lIBOeyZdTqr60kttrHrUICMurWhhpPQqT4KHYqoexRKrBqBEpsE0cl4IF+a6EJQRZqgJdYd84VA/fA0fKjWGlm5sBU7oapAHgquzWmczaMA91AOWr8iopwo7lR6oLHwVltXJ05tUS9w/+Xt4EXc5H32r6mH3PkO++OZzfSC8Wf7PIMXm+QC/uWKRGbJweFaLeBKHF/PqltUi6OyOl14BThLQRMhUZ1SkY7I5v7g6i93zn/oFyHeYiO6E5x9xY/4d/YSPNBDB9PHW6KLybmWJ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qH5BCQZLpfQ8pCx0hPqel6W4pCYCJORRkwZdXoweh8aOAganbTrC4alv/OA9ncibTIcJzinv/HVxIlkoPEW+Ym6M8FJxHKcvIooqp2RbsfOg8D3qTs0YqBHnl4fxRPIZJTJCBRXXwEjlJARHwYcNogMQNSr6bofegrqfzhd3YBxpSD9zkXUVVp2xmOtVcL5sU2TZu6e8CcD92YLbN0JpC6gvYV7d3TU14fw1ciFVTQDvlm4lNt4GPpKtdR99a+m6tT2nCt8Mu6OC8g3HCbJo/MnCj4F/P6XiP35gH0aWr60lhIJtOTT3kD+0icDIi+P+IgysQ7B1ehiGPSUPvSUuh3qDR19Y5toXeVLJOhFN092ypIop9vXUL03nHh3Epgn6EgNAgFSuulV1uspy3V+ZT80mmGFf7UzAmTh5gVW4ZK6hgjkS6GEkONR8AlEfT+YbOd2EzelGBTYx5leN6R9vvSz697WhQ+XQBR1EUgGDcRf+6Pkfoi0f8/KHX1LYCZFKCYbyk2mbabScqmRJPFl+doZAmiFgmnRnBD19gyQ2/3PaFt9rnZpgYakIja+1ERwqJXlcz04p7q6txzLTR2Q1PVtcOOFFmZ6zlKFyeuQ+JJUNXZcNMKJxo1vPP5Leb7LE+9qtOV4u+i464n6+q X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a58ee02-0b40-4400-5d04-08dbc046afa1 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 17:16:43.0680 (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: UHX7smEAFyAJXyXrJ2zAkthRapqhD06pMMaHKCHYcwN10TnVROJsKQicJdL8MMuQiXL4VNgXNuYSFfNXLFYCQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5273 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-28_16,2023-09-28_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309280150 X-Proofpoint-GUID: _dFsmhfqiwfKCdybeskL1k6Sx6TMN1k5 X-Proofpoint-ORIG-GUID: _dFsmhfqiwfKCdybeskL1k6Sx6TMN1k5 X-Rspamd-Queue-Id: 1548C80023 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: mb4rhsfi6cp6qp817cernzyhsuxe5x1s X-HE-Tag: 1695921411-818011 X-HE-Meta: U2FsdGVkX19dGPL3F0sVV/8hg/hOH+5Xu0s2amPjcthqJjIqrkuUMWriGTeftjGbf7IkVaWVxxwJUvxYfojUOMdDO7tfld3xhS/Sk7xgNOCSqkbnQWSnwWYz6itVKbuvPi2CQXXoGC+MTDdEvOkOW31ng0v67MPF9Xeg+TkHOm1QNS6C1QQfkoQun/AnjabwzZtcaC8AUyqHfWMjRfokCOmafXjjtwHM1HzWCD7L1ai94ONtTgwXCwFEVJywcK8ez2oFW6avMeuwiz0eVt3vmp1ZsSRxO4TIGFWeY82jNrB70Zg36lQyt/3sek0R5ggvLgSBXxp0hYh0z0Pp0q/pPz96vSq0o8Jl/4ova8IBJSQp59CaBLWTEtXx5AD6xCeNDaiCk2z6W1qpax/bvg+LBCizB8uqdVf2+gxq8UMP99do3ywB6XcnWwyVBCmavnLTcNmRQ0WAepP+Zn1ME21y6HYvaW26xdJ/Xb7eC/sE2dKtw4GXabD0X+alQnalOvNU69fL0Pq0ZslfPwST9SpNT78V7LNNtIT2MK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-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 would not notice the effects as it would result in an extra vma_merge() call if the first call ended due to an out-of-memory event. 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index b56a7f0c9f85..a4eb5a5626bb 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -975,7 +975,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, /* 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 Thu Sep 28 17:16:33 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: 13403338 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 D11DEE732FD for ; Thu, 28 Sep 2023 17:17:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68FD18D00C1; Thu, 28 Sep 2023 13:17:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 619AF8D00C0; Thu, 28 Sep 2023 13:17:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41D538D00C1; Thu, 28 Sep 2023 13:17:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2A5418D00C0 for ; Thu, 28 Sep 2023 13:17:09 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DA3D98043B for ; Thu, 28 Sep 2023 17:17:08 +0000 (UTC) X-FDA: 81286661736.01.CAD6F8C Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 7E5B2140034 for ; Thu, 28 Sep 2023 17:17:05 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=HfWjbu3X; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=q85CU17N; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf09.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695921425; 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=KdpvLeiQzpN6qyRq5Qgq0mEAcAwcBRptjh4Tlk+3k54=; b=5iPwd+aSP31NOJEpZo4L9ENSQwW4WiI1aKNdR0FmSrGKdieMybARWU9C8Z66RIqkjgnl8K n3xKjglzWuX3tjzppOmSO7XHQlGddkqWfgwNTqHv9j0ICvydeHPoe0tIW9lPiXEKR6w0eB iMac1SK3C8WlQQyix5UQSBvU3E0U9HY= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=HfWjbu3X; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=q85CU17N; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf09.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695921425; a=rsa-sha256; cv=pass; b=sx3utam8wgz2wuSMX614dRXpoICEPENRs96ZZrB14lHrqdkIR/z/hi1PKy/XO/xQ2EKxbA kMtQC89gwAaLq7YFiarrzOUMaNxyrytnyhlQBeHPPkCt2kGqPF2Rf9focYaACnafHLiiL/ kDjuQNJPWzo4QCv8MMuqToM5HKjnfIQ= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38SGihMB007048; Thu, 28 Sep 2023 17:16:49 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=KdpvLeiQzpN6qyRq5Qgq0mEAcAwcBRptjh4Tlk+3k54=; b=HfWjbu3XbnMoUsEGdV4ph+FN3RAGIHjZhHk/kA8jl3pyTaHD6dc8XBKL6dBhFZjRO2sX cRZ9fn/uD9QWqA8nhPz9hXvEFJ6QFAgI/YRj7Qa3V4JX1YVzySGqDt2q2BPjfNk23Fx+ ZuILOe+gtFhYMyCbQUfuw5OdDIyDa63PexFkb6OHzAQtLDpOMuLMQfPo9MDCk3QkOaw6 ZyV+035N3nJE3Ygat/eF+qx6YHASPbD4l17yPqrbwlUUOmuDSYTquDpF8Kj5jESRq8F8 kXzXXQzaz1UXc219B4it/YaZXpx36TmwL8WReppM0rC6Qdz5/Hj1KQacQHjy62jEDhYw +g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9pxc56d1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 17:16:48 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38SH2Nad008178; Thu, 28 Sep 2023 17:16:48 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pfa3t23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 17:16:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DrE96nmG6hPwtisVSOa0GXu2I4nRWCplIEvUSyxhNmIJMzj++ifeS0tho7d91ObaLuVlMckvneW1/KSOYAc+XLG6isJHgQu3tGuxCqA95C7F4kumHO3V6HhmER4RLYh3umK7DThAxPgykLKI6ILNxK+oGoktlr9gWJ3EuOVl+vY2hAWmu6LAezRmmdoNMpCvBMybHLjxMWDQ0spcheFNJPpglu8B5/za0JUlf6ksGHDfaxDl8dyUTzWuuUTA5/UBVQ/pln2qQmbyDBqF/IjMb8CkMCLq52kog+up/Qnfn0+Wki6n2xOd1B5RzuW81EWYfqc5+iuBMQGgLF/Bm2CGOQ== 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=KdpvLeiQzpN6qyRq5Qgq0mEAcAwcBRptjh4Tlk+3k54=; b=MYAHljti3RzC8M5Jf188aBM5Ba/7zx7TwW+kDTRHua01KBOHbgDzForQ4uWHjtkLYwYjQTzdqJF5lew4/wvCuVx5WhEe1WcXt7AUcNXAEX55A6EDxKvo1cZsT6skGPKFNdUGPvBX1dI/Q8YDrNeWmmIAAPkvS5bNSPpk42fQavUlPKfaIueLTPXhjzfxJTyUntPmXdcrZ2Ia21JPVTYYwbTBdpQ9VQXP3m3VaxGj6RoUntxSzYlWichhGINGKMiSDNmmrDw6eEby30r6DChG6JvTKN7RGe+W0YXfNSMp49kdnVtS/pcP431uYP/g/7uH+fmaBHR6wqblJNVCHe6dkg== 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=KdpvLeiQzpN6qyRq5Qgq0mEAcAwcBRptjh4Tlk+3k54=; b=q85CU17NqXaVGmzEiMkqYj+CARUY1xRusRLtItPdT0HprenR3X0bFp4eoWy5U78mqER0gudcMSY/r4SA9UM3GyC4OwqMxuG+7Wzxrw5XgbgGdgGxQB97FYHL5YxHw7sERI40vseTgtlTvPBD7yzG6PcOIKjRTytHfOLaVJcWZpA= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CH0PR10MB5273.namprd10.prod.outlook.com (2603:10b6:610:db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 17:16:46 +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; Thu, 28 Sep 2023 17:16:45 +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 , stable@vger.kernel.org, "Liam R. Howlett" Subject: [PATCH v2 2/3] mmap: Fix error paths with dup_anon_vma() Date: Thu, 28 Sep 2023 13:16:33 -0400 Message-Id: <20230928171634.2245042-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928171634.2245042-1-Liam.Howlett@oracle.com> References: <20230928171634.2245042-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0229.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:eb::26) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CH0PR10MB5273:EE_ X-MS-Office365-Filtering-Correlation-Id: 6181460b-f4aa-4af9-cca8-08dbc046b13d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wKgrae15V+HXnMhuP9IjIfLC/dPDwpk3yDU2Q8Ag+py38K7jKKm7Mw2uogNuZtdTxbqtDvPIcdQiv4oV2tN3tXjtQ5WgifNHMF+QqqVOPc/wHYjj3WdyArxnMdfaHQjN+gfcKK4eGm+JWWjVb5GaVJEHltop2Mg5KtW/ei2epabE+WPyJZ3UimpnGboH1Vo3Kkny0+7MQvhHb74G+sTsVZjrfLwxedferVbeUUbyEX01yG9HRTGclHnf/HEmEQKT2wuTLJGWhvUPmdYdNUgCov8Kef1tQciH2Gehjb42Nd1IxBlMEZTteFPTZ6nyK7Flj9OFGikkFYmwV2Lxa7eCJLMdVhutCNzikba/FqPJyFYLydxZXBUuW3SCCf10q+Z1mqxSjPhEgxi3SnsNHxmGUwaCACm0zk1GKQAtEOW0OqcX4aJjVdJKZrU/ijHj7UPm9RsZi+m+8iVqHnXzB4zGxwP9AevN0GIHUFKKklWxO+hgxLH05fVWMJXxvjcv6PdlwX1ussYJMISrHaj/alYwSuxyO9nXd7WwnXAYJSyARQAKTtqMPqrK2LXvAnVonpud 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)(396003)(366004)(346002)(39860400002)(136003)(230922051799003)(186009)(64100799003)(451199024)(1800799009)(4326008)(5660300002)(107886003)(66556008)(26005)(83380400001)(1076003)(66476007)(8936002)(54906003)(316002)(478600001)(66946007)(2906002)(2616005)(6916009)(41300700001)(6486002)(6666004)(8676002)(6512007)(7416002)(6506007)(36756003)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-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JmWHV1IzKta0TE35MaJ3FQDR7qngkfRV2qEhq6Dn3N5eQe6A+uAC5cPif18fahVrUiq0M/oV5cKJBuTmxnAgg4d7uO63WlDVL7rf0ANyzHD3nWms1zS/aUQKBsf8HRG+PoU9rcEz304/8mSFU1pTYPLiWnvS6xVHb4ulLIODIe6xIzghpIBtqWyIwD4mST69SqOpdXQN2oN7Kt+y1l/E0K+xx7Z9NVYoFRBRjUKibbUbaGu6db+DILYWApyM1MlN+Jk6fqTe+Bk/e43l/I9NahMoRj75vVAQMz/nGQgzGjTtk9rvWItwAg9WtrWuLBDNSfaH8nlpKYPZHKxmxctg2e0+SuvC5lME0pLW2ruRaweTQ7bjI3OQRyE7XZEfTPZ/k4Saq/51J0Bs8ZLd4XgeWf/79nB2znyjPrrzOErTgbyil4aSYfUEPRpEEjFUxj/m5DsQyI5hKE6qedW3Ku53zMch++mCI/oliESToAj5d6KZS4c0CsSH4R034pl9U4vEy+RSZmX0b9XeVBtLTwnuOyTB09c2UDVQJFQhJ60Z8TjFjjHLKBngKNFUq0gbAvI8BtBaDYbfT+ot1T0Dw36Sbdszf X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6181460b-f4aa-4af9-cca8-08dbc046b13d X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 17:16:45.8786 (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: YHfX4cqSql+kqm0njoeFp/OVUnHCm8mXJ6Q+PI7HOufyEpAjH1QMVLNElI/cDvdKOuNTWG/4Sj8xtqqhlEUAAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5273 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-28_16,2023-09-28_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309280150 X-Proofpoint-GUID: q26wwM2NSbmFX2pRjBnRRVXfSnmfaqSx X-Proofpoint-ORIG-GUID: q26wwM2NSbmFX2pRjBnRRVXfSnmfaqSx X-Rspam-User: X-Stat-Signature: ksx95ojjouedz97srip6resok88zuatg X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7E5B2140034 X-HE-Tag: 1695921425-488940 X-HE-Meta: U2FsdGVkX1+Ophl+DpqD8UkPbkVs0ZFSJ/0x/6KRSExCzasxma2H4U3S/44fId1GnSXvQgKmCCjuZqskvet7Vfr1ul8sGddPIfhbjwGGOyREEbDp+X0UqoC2ZpTJbOCZGt81yBjsKIRMhtNcMWMZp6xRG94Jvm0ax8xgFuOomQDNFH9VGTt2v182LiHFeS37GhS8h6QgDUV3I2bkF2U4Z7lvswbuS8mUFZ1pldzHC3s55xTnBPGwiAYQ02g+2b6JtNdlmH/U0qUhoeF8AaUD0TDmiOGhU/g8crdqVaIxq7rYr5yswS73DjmjcZFBy4VXgHj69SmA7hN31lXjTwktRYEGk9FdPBgfOxpk2PSFN1Eo8cifsn33mzfNkmER63xn6LL/ovs1fxWUV1oiwXtrD4zvkmSJC/fBvr7EnCD4IfHcl6h4/FlqqTsnlccXHk55RlSZa3S48Nh5iynEaa2mk/h9lbH3eTrWK8XOTRx0RdWo16rH9xLaEYDA4iIXhrNzrfeH8OBGRiLhZ5EsD+1UylBz9KuB/gC+QsyWfHCF4n1w6nFk6pA1B7Px44evdUxTce1gAvwDNqxo/u49lb6/JOTItdHXlnltB5ch8bAJAL5LlvFM2BPpi5z8FvkaSC1zjEs7RgsuBbY7GOdXk2dSv2lXzkhN4D9vcUyKpsscpg+Ank9ktnUk85pBQZxijRjw4od4XJqys8UDYN1+uTSruQhoL4r517Fcry4i8Q7ELjYzxf4ERXyJ3fFzcRk2V7u9hOlkn/clFhbUc5mBm1N/T72vERhVQPFoq3AwfwF5rTtymvVOflyuSFSrXSwZNWeVPX03mVM3pafrJMylQriGavPmfHgBfST2JqsQKuJ+4irc8t3KTF9jzu4LQhC4gjTH/wi3Ih11+WAQnbHOTixMR7F8VhGfK0pVs0N+SjQ2QSBt4oUwiF6b/ST18aB17E1GdRIYQ/No58xSbUmpZRt 0XRrU/cm DINXbZ1/7hcSOo43txOgS3Da3gbD1iT/8EjNA3MChTh4FL8pUC9vO1uk0OmKQqeWDKDB0HPTgnCzNWjDMFM8XRpPVa1kz1NSsUsYdERpQLbkHXv4WO1NBRXV54WspVSZ6VROWm+U5PkYQHEQl+SVdlb5vD3y6omohNDKUBriSiVfDjRp0i4V3aMd+buhDeFqohpIha8Sot3KAmsy9HnrN+IT70J+q+AyoHbGp0AT8YxIz4C4bdfCyip0nMSmsfTaEAdPvZXpDiexNpPaVwBcdQ8HX8iRYldr6rWVRZ1BbNE5Tt24q4igz25+pnVmSboA4v3fwLuhoSGx5XBeUsKe61p970ff3d9TNUB2fmemlF7Wu/Ld96dJyblX4uZaRiG9i9utO0WqDfRizmXZ1t/hSfFm5wdzkafBk/L2uzu+JXd+0IGR9pC2x3YWLQXzrgnsJr+ltRNoCpjkKtAeRzQnTSSgSpde5+0og+S7Szwxi0L1/tbqoKOKaGd+dNQrVA51jqiQE 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 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index a4eb5a5626bb..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 @@ -968,7 +973,7 @@ 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); } } } @@ -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 Thu Sep 28 17:16:34 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: 13403339 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 87D1ACE7AFC for ; Thu, 28 Sep 2023 17:17:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FCC08D00C2; Thu, 28 Sep 2023 13:17:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 186468D00C0; Thu, 28 Sep 2023 13:17:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF6878D00C2; Thu, 28 Sep 2023 13:17:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DAB688D00C0 for ; Thu, 28 Sep 2023 13:17:11 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A47B5160F06 for ; Thu, 28 Sep 2023 17:17:11 +0000 (UTC) X-FDA: 81286661862.19.71B24AD Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf25.hostedemail.com (Postfix) with ESMTP id 4891EA0002 for ; Thu, 28 Sep 2023 17:17:08 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=vDICG589; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gZNLE8qq; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf25.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@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=1695921428; 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=0puTb4IoAdlhTbyVTv7gdUc1GZTKVZKc1KPHN9TLwGGijSU7diC420pADvT4TcXJgTBmtJ VVO8qxOuG9cHI3l7KZoNlfiqjJMkh69xh0+MrRD7vxr3KggTLbPo1jd5hbszJ0HTare7eT aEZfRwP9egF9vnVL0ApXzpUAZctJqSU= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=vDICG589; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gZNLE8qq; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf25.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695921428; a=rsa-sha256; cv=pass; b=i7q5BAKc+b+LtoaUTDBoG0A/Fj+e5wP6NWNTZAHOoumhuuudXV/B6n/aFsqh9MTaZbD+pI gv4a84BYR4epUSg4dyD/5/9YcUBOmbODBcUMrYzzjj9ofiy8/eAKDrkgiOJoadF2ThBPRS 1flrHOebrFp7XgNtvB7VtKylL/qZdbU= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38SGipbR029126; Thu, 28 Sep 2023 17:16:51 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=vDICG589HkEcn0XSBzDG7PcsDH8ZR2w1I9VVo0neLcfPFOV0H86oWcK/he1lEj9P99L1 iHiMTs73VCMMVkAR8JN9hmWK85RO+BfxBIQ72KfEj2OX6oLqEO7XfsGyU6oF+SDJvuft BT1VOrMamtbKpjB6vlff/IDBRBMr4bvHhM8DHbD9I2asxhifihVHuwpenRHDbAz2Z6vR s2Jfhr3W7pWociaUjVGc6H9YTM0k7p6NmssogN2WMHW6N7CX3mCMpsaAw6wJxA4BOvpm /R8RP8tNKSC6kThs3X+N7NCQmEnVKzOTh2NvNkKPGcC/bPLWEwnFIh1SQc/zaYzslVjS Gw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9rjun2as-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 17:16:51 +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 38SH2E0P014372; Thu, 28 Sep 2023 17:16:51 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pfadq9y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 17:16:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VBeAG2UY/T868/5fP6Y8qyllIA/qi8EBURbaOhE94cTCKQNshAYLBjkXs9kDClhR5wDQzuKBbXdJ8W+1c/2QWNRu1yY/aVACeQUcraSI6gliewaS4sHTPSYcJ+MNZC7+9oWUNx1qS48zS99616cJXBuAZoUz38g+s+K6Z5yLfdN+yV6qJaxK4uzNVUBB9kFaWtEkbxbk9THI0JU1yzrLa4ebBY+En9I8teLBntUjMClQaCG411gKC4UTOuQIr/KWz0J2Fzl28dvOi5TzqRLjIK2WoWwWFYp14EClMiUHrE9iTLjT1kFfQ9mR5yB+81tT00sjg9mkibyP/RvZMIde3A== 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=oSNRBP9iHVYg63hPlmRCVXjJQFaPI3aM9UQmLE4EJKDap4U7SB9uHTa901tMPKVM0vgJYt1sZnx+oxGeOzqYL6RqIFniBW3m7zJMatMPVUNSgw+qN5MSDBepF08Aiw3h+mx3pCZnbk5gF3p6xz8fA0WqeU+/oKRdHD/25fn6XzNyr+Bdl+VQ/pUl0mfx0UPPgpX07+YOrBfYADNWGTqm+6a0tP4NFhcrmOt3W9Mzlt4ljXZZrlnb7eb5IKyWywJ/1up7OauAGCSiB6ldRwUBgZ17PvnM9uyhVu1S6+W4MwELocfCIRR3XXTWWqRpU7ncmD9Qg25Kw5xeli5kTIvw1A== 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=gZNLE8qq/wjbfF12q7SoDzZ9BuFCH5/g/OrlXA8KBPJBhSq7VPR7Hi6KUat4Hotm3vWPuKoNY3NZkb47XbyhHd0UtEgKNx7e05buD8QeZRNY8aT1KoHlTlsSM1g0H5etWLOIJaxdt+XEEi4KGbK/akFLJ3jVXrtrfOrsVgihaxw= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CH0PR10MB5273.namprd10.prod.outlook.com (2603:10b6:610:db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 17:16:48 +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; Thu, 28 Sep 2023 17:16:48 +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 , stable@vger.kernel.org, "Liam R. Howlett" Subject: [PATCH v2 3/3] mmap: Add clarifying comment to vma_merge() code Date: Thu, 28 Sep 2023 13:16:34 -0400 Message-Id: <20230928171634.2245042-4-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928171634.2245042-1-Liam.Howlett@oracle.com> References: <20230928171634.2245042-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0089.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d0::26) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CH0PR10MB5273:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e1d04d3-ca19-4e6b-f084-08dbc046b2ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vIIWUNMO00x1onDjHxGtkiH6QcuN6In0GD8CveMN3E1lpTweRXT4styW1X/BxgJvFL8G0OHIjVw+mbIY3NHf0f0rAV654oKXiWnhlyBQuBxj9qloDful4Odu8oFY9fCa2Le3Trkv0XfQ5KA/FTT9Tu3flkU7j7FCuB0INMA+FCGJm+T+Wzq13HjziltigN5iS0wL/Kp5tzBi0rCznLRixxaSPkscThKNogjwkfEYxenNbyvb9y6F7BklHjLwzQe8xQ+JbQlG1kG7CImuKbvQGdiTKRP8HgdboHEWXmVe92UuXihpn8vqfuMyk7208h+3jED4/m18XLF2lxcYrAW8ZhhkuJHtEgrg4v23UoN8kGnP6HlNwUmwMcSGUl7BvaQ4k3JxcQ2JDibNf8scWyRqlig02hfL52zZJU0+7kE7h08EKAcro+gZ4Iu0cP+9xVODuieZj0HDgLzchKemrw09vlYu7tjYNMndpFWqy7sTQj07lVgSmNXZ3o3nEObyQj7dZkX3hRTXMwU/vXtuBDca8oCrA5Dam9+2UF4qaXZY7EM= 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)(396003)(366004)(346002)(39860400002)(136003)(230922051799003)(186009)(64100799003)(451199024)(1800799009)(4326008)(5660300002)(107886003)(66556008)(26005)(1076003)(66476007)(8936002)(54906003)(316002)(478600001)(66946007)(2906002)(2616005)(6916009)(966005)(41300700001)(6486002)(6666004)(8676002)(6512007)(7416002)(6506007)(4744005)(36756003)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ADAsGMURm9w3fG1K3krse0Y0Nf6Q2DvNa1gg2r/q0CYfjBBb8dKqSXDZL+MnweG9gMzPl/FhWs/hJRsZLQLLJtr4Pt6XulR7Nzrc4JNhXS6H9oQ8URy1DLFb1OpPN7hA4vWrw2bPulf2Jfu9ynI1Rr6OVO1gCFAUJ5YAwCd90a+LYLmBp/WX9ItybcuTKZD50C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KKrenT29XNWSocJlkLQlDS8sJJdOVo4d0cbm4iBMS4r+vcFyxWZlCepNemQFhSeLDg58S9e1z1iMuT4sbRrJqLxylO5YCXDtfCt/irhnZ5bLlXE/O6aG7NUAZqBH6869111gD4zraX5kM/V48XcPmFY+mb6uwvvNvBVW3x0I7GWShjzfIQKcC2iDs2oo4lNda8MSJlYi08GC58WM4V5TA7V2eFH6QtVke5TM5U50wsToy/1jF4qcCJiTrRCXqVRX3LBYnqIIczBuCAQsXGmYtMt6peeOVUlSIuDyIJfcqTvQ7WSOM/0wNcITs3W0VzmTIhcQ+XRidn6OvQI4/y+qPaZF+AFIM43YCTH8+rgPnCQyTPED X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e1d04d3-ca19-4e6b-f084-08dbc046b2ac X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 17:16:48.1849 (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: Fe3dbssdI5rQS9i5BhIfWMX8xFGm3LdGkuDTu3Rn+kXW+/LN6EVKQtxM+DSJKV3iK/TPQCR8iKhkuHBjgtGmQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5273 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-28_16,2023-09-28_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309280150 X-Proofpoint-ORIG-GUID: NxYjELUyBFJZBWbmcnHtjFtkJLtbXpCP X-Proofpoint-GUID: NxYjELUyBFJZBWbmcnHtjFtkJLtbXpCP X-Rspamd-Queue-Id: 4891EA0002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: rb5j8qksj5pb75e8oybzns7youusrqak X-HE-Tag: 1695921428-573661 X-HE-Meta: U2FsdGVkX1+hS1cbqeL632osJL8zqM4eOxCZydrYmCAaTEOlNVjJqg6wu5xuCxDgoMPjXakDkIULgvflHBSJnWWBhbH8UpxHPeBwAEwHwXFTQzjAUo/J1PN+kRxymv9stbABSQEc50YItFH8b1Tf51EdWfruGczjAw/qtEgystzdusWsCxlkIp899n0z5xlGKY0LMV9hqn38ip1cVQSwlxGb8Q9nulTt7tl8QSmt/s0gxhBaHTIp+H43LpM0n6am2NAlZcAOErPU093Jw8QspOuMQqwZ4fNt61LLOX9lRdS44/e3A9i5L1VrCP81sNf4lTSRBFcyLyCxo+U2k9pvaYDklnttcxs+7sJjm+sz603Y5RX3Xhy2Qj9OQFYLhhFl1S3EEGZbV1+IwHgMDq2D9mIF4N6O0pg4Nj6v22YeKeYFKpompepUfQEPgSZCaBEHu+kCXP9gxtt2siJly1cBwDXptHsWbaItl3K7rPjouzTmwp4yJkFDISwa6+Q4Ujtz2JYmyOR2c8LV365rW3R9PBpkBBlH9dtEWV8OEkcbHGyqPzQOjqrv/lFvq5zpj/ouJF448YAGHHRbnKb4T4+ynWZxj8XZwfBpCXzEWvc/C1RoAzuxX+gnA4OW2j+YE0TK/v7I4ZLhL7RzBD8ZopAeanAKtU+buKyrH7pCN75rT9ObN8GTgYvO3Q9LG0O1/5bhqmWGjzJvNFUoBiUKjzhoQGZE6YrPFmTX++M96BPVHKO3bEMrbEQfx1fAqzrg4/cchzimXu8jVQ3NiY5U5W8/GOvlAj0ZnVEzJpZW9suuPIHY1z1EX2s0qyuwzzFhen/9s4Ub2tDwMVG3LfKJfGlJx3awTTE8vrCt0iKCzBMKL4JtU09Nx9UUPN1CPgyaxTqAZjqQDOBCDhMNN226hK8YNy8Qs8xG98fFmrXM7ySKCItPQ/Ic31wzt8KUIp97CKOgvgRinQLLvaA7rg6QsJt mvobX3ws 6vaFQ5Yq8DQJ6bWULFwc/09sOeKw4j0rhkYI2ndeSl4J/j+S9GT9KKH5R7ARo2M5x0PUJwKtXKtIogDMlmrtfwIbJXozC8wX8rHTqU7ymi07ZuEQxs+oiDBwjVkDCyjap0JUMR9ORm6o+zFAQDZ5/f29u6DTDrOIRqfBpKXfEAe03VMEhy1SiRFI/jU38XbDkR7Y20PXLUQERRuv80xSMkjUgxB9YgsgL/maohOWE9kPYpctvWCjCXDUw4lNARkhQm+uk1gTq453CDz6kXteBYN8rDUSwF+yF8n1HEKa8ayAKCkRmcz41VHDXF9Nw4Kgq4r1EAWvozdwQHPec3Q7c/T913kQ59514AY09J5QLz6GtJwEw0eKZSh4oO4ZEo5lOMhqE03aN5WHsaX7pycIJo1QUnb8t9T3Lw2l0WcF7vFDTHDGLM88rO1Jf+OKu/K55KBeQezYQwA/uw17gdcAfYVmfmOtQKu7gKhpWmXTHU4sslCl12EHshUKfCupwsxDxpubHPhmCS2HQfLJQgmZrFAF23XsyhA0urld2 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 Acked-by: Vlastimil Babka --- 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); }