From patchwork Fri Sep 29 18:30:39 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: 13404765 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 E0CFDE728D7 for ; Fri, 29 Sep 2023 18:31:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 641A58D00D3; Fri, 29 Sep 2023 14:31:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C9E48D002B; Fri, 29 Sep 2023 14:31:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41C7E8D00D3; Fri, 29 Sep 2023 14:31:16 -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 330AB8D002B for ; Fri, 29 Sep 2023 14:31:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EFE0A803D2 for ; Fri, 29 Sep 2023 18:31:15 +0000 (UTC) X-FDA: 81290477310.13.07B894E Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf15.hostedemail.com (Postfix) with ESMTP id A863BA0040 for ; Fri, 29 Sep 2023 18:31:12 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=O3M36Prl; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Nwcw2H+q; spf=pass (imf15.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=1696012272; 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=EIZ7sdQCBGkQhiWKIP/GTzDDyb7apb1qxOjwco3eXYw=; b=eFSDnvZuqLzxLWwQbLcNC5bu5UQm+ax7Da06sZb1xE7NdgUxZiRHEwZlWttCArMdA0v4zC lrNVXxrGoxK8fjb3HfNWUrR1ebQfYiilEt0/+xM7ovSx9pOAKHPB37zqIdMBp2xmH0tFqz X4/ZgLPI3oFPSRaCq/gBQSt7/BQ2Whw= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1696012272; a=rsa-sha256; cv=pass; b=zR4mAWXLfWjZ9SPY7T0mS30/uZmdQeAE1knHUslbrCSCF9mLVlCEEWzHj24K2hmogtwDcR G2qjCTGUOp84C4cceo3/gNn6ejIR+hI3OTJE35KMqvz+BxjSVUjXSKk0spHc6HpExtbi29 NOXiII46aGNMgl4ZIARXRNNLVCR9RyE= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=O3M36Prl; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Nwcw2H+q; spf=pass (imf15.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 (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38TIJHTF008665; Fri, 29 Sep 2023 18:30:54 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=EIZ7sdQCBGkQhiWKIP/GTzDDyb7apb1qxOjwco3eXYw=; b=O3M36PrlJx2dbFP00G/auCZYAGN3pk42nTrRqykDhyG8Ubj9KVxaZExFwpWPfbzB31E4 D0QzLJ9uGh5ijLz0Ekg33LfQBk4Db/jphH0cjqQtQVbe3ejSOHFzxBbPL9dxAl5eu2Ix ed0eiIktGnRaiD3wOYDwwcx5o2t2TcX5nPfwV+VwsNE1+wFR7vxowfoxxt1ubmabohc6 VCJkRDSHrrcFVBQwZ2sGTGmDytUB3IFFxuYHqTjffj9fSIDGg/tiJi+MGMUjz9qX10WU GueCY8AeSei9K5qYlPKRY4tPMGNGaF/PHmaFW8mcdFbCl4G91DQtuB5rIpKZuoLSNLmB TQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9peef7w3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2023 18:30:54 +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 38TIAbWv014718; Fri, 29 Sep 2023 18:30:53 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pfc7f51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2023 18:30:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UL7p3mxMEomepMwIEcfAsZsNBRyFnnb2C7pLOdgS0ByyoTgZ6XbkYEersqxl3OSZyEQ19WHVz0npiKQH2EyvsMgBlNK3/vwL5a6+zyGS/J41YIgcfE0I3TT1TTPe3L4oeet54kqQvNDFPq8kl3i88VHd0lnQzmADv2rr981kEMp6vH7m+qK147Nlww5624mQAyrd8fyCWokDiI7xvDICiTDNkkahICm6xKwikNUtYFEe353ufPXkc66HTC5V6MIpltJB1lg+ghJRKwg2/RODUBEYWY4B8T6ue0kBrhoJRYrvEPsGFNdY4VcWUl4b94NQXl/tFQoinOGBqZmrSagQPg== 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=EIZ7sdQCBGkQhiWKIP/GTzDDyb7apb1qxOjwco3eXYw=; b=NpEQOyvHoJrUNKLBtEsHpEAAh/7/2xoLCCGfzQQwgAH7r19SeKYcqI3f+KTxj/x0ueo11lC6HOYPKwadRHEKs/x+OMAnt//cxOP/kbtiJh8Mqd6kBxdvToNkxCokkkDckvkj2SD4I4GFTZGHb4rIgvxGfMCKis5fqojCBhEpx6jLkumJmZ2A2SXfRWJnTV+2eILOLN4Jo9ivA3VBTouceW7ilRF35SRbUtsRcRA+6HVTzvmTnx5EXvBvGYG2ov3vnZS8nKHZbN7LWzrAq6UhxyKlBAYx8eFSP6GvehzG9SHOIKxCe0lGWyPHDWJ1MtAVHMRQSLdg7rM8vI1IV0s/GQ== 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=EIZ7sdQCBGkQhiWKIP/GTzDDyb7apb1qxOjwco3eXYw=; b=Nwcw2H+qylchfJiKysR0dGngn8J+7CHSNxcbnNHgM7546Tx0v1/GwzYKkeFcaj/FO1e6IU2dPDfmsnb8sW+sY0V+pZmilPmN9TFhKhHl8pDJ5Ru3WGZrb+enGqIMNEVo4J+Mq2wtfA80D+McEZC0oPreYbXGHbag/EWJCeYzh7g= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CH0PR10MB7482.namprd10.prod.outlook.com (2603:10b6:610:18b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.35; Fri, 29 Sep 2023 18:30:50 +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; Fri, 29 Sep 2023 18:30:50 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: 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 v3 1/3] mmap: Fix vma_iterator in error path of vma_merge() Date: Fri, 29 Sep 2023 14:30:39 -0400 Message-Id: <20230929183041.2835469-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230929183041.2835469-1-Liam.Howlett@oracle.com> References: <20230929183041.2835469-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0005.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d4::27) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CH0PR10MB7482:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e6eb506-6251-4d7c-ef45-08dbc11a343c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MZCNZ96h6VlBuC/KEY8679tumGpTa7z7Zy5QHwPdbEYpwLfG1SUiBgOMgz6nJshWG0tH70/KV5lctXTbn/EUXHj7d+CkA3hAEsUlxq0crQMFptMcqnF7Nb7e9mrUaVlU/NgnZoF1YFR/bqcP0fXzJ44CSoMFw7TQIZ5y7SBuqviIYyB1WNWXvoIwemj8XE41WOiLSSVdfFxQtNdOEXImCgWKtgzoMHSSy2RKIGkPCO4IKIFFDphY++JKy3xcRIRg8un93BZ0yXNdQqfWvvTbI+ES9qsgqsZcB1XclYhTb0o7JqD2/hzH76imL5K4FNieEji3pDvixiscjqQI/HVfoyhyY9VTE2NBKmrT6thmZ325nGACRCLbcd5Rx4hqWuiMUSIFNqKavJDXuo9dmhX9H7gy9RU0Uo5Z+4q+5n5jhQUHT0wwZJquP9HuYJD1ljzXevkIJzYfsuNiLcb9bdZXjH80Kw/iUhTs6y6UtzZoUcPzjQNleNS5GFhABXnCYeBggtD0Ns5WUnOMDkPWlpanCk2fYB+c0bPjOEyfV5+DtdeBwyeVqt29l6kcV6V+ynhv+UEeNvRKVFdxAlm6SyNsbhzhMe/gSGmFMums60HZkcI= 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)(346002)(396003)(136003)(366004)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(41300700001)(54906003)(316002)(6916009)(66946007)(8676002)(4326008)(8936002)(66476007)(66556008)(5660300002)(83380400001)(6666004)(966005)(478600001)(6506007)(26005)(6512007)(1076003)(2616005)(38100700002)(86362001)(36756003)(6486002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dvg0Fdf6I8yeM7DTVCpuxcqCFPcB1FgrmITrf8enQsWpe9aJo8dmiTmJ3cRpl0Z4V89cKsAIRjPaMABlOhP5d0a5XB25wYvvBZ0JcNyxE/y1uJL5YFTj8STeGFcPYjWvulko9Y+lYycNNWEyhWInzrd9Pj8i4r9XAodp6IEIvR58G3myJmOm+LtlsVlqoPjgIXov5Cp0oLvq0OMZAkou0bgdRsh3LNZym4+XpKgjbpIgEI4pARnv7I8nzecOCiEtCRlXAVJEClefcmL8fBNGf1Oe4nb9A1f7QUN0B/GTA51QzbUtmgbgpe5V3G1hThfuTGaRN0Z8WTwmfN6sUisgeGDNvLBMn+7s5pcATrhk+mJW0RDl6Ly65TqBbWKKhVtZQDXXgt1eKvcLKKmKjZgqyee7QbgAqJtbyJCmBlWFlsjfE0BaJdfR9UhWEmKTIzinuZ+xX78rPAQ9xKzOVPUGqcMj2PDiKsgS7GmMwEKF0TgRAoI/Uj4RS28dS0XSgV8Vy+Z2DF/NWoG4o+WBku0eNYKlxmOlZEuIl2qwJRXDJTBrAKwsCrguVgg/LExtFL/wDc9TBMqBchJqPdr6i+8vYCO3Al5dXe2Eyk/V8bWuTq8pjbjfCoSzJADFYb+fQtsvWdG+SC+eUyitnq8dBrmkqGhtV0PSyYph5tPhrY+TNR5Beqlp9Tz0eu9nGkL1SEFdCSAwIXlkIV8reC29twfwaHIkCpzM11ObUxZajLy8fJwPTmts4ciyRNYuJFDAydwsIi6+oaDCoRGUFExq09BQaFA65scLC1yUMWY91eihhZym7MANZ8OVRMKUZAuoHpVdg9zP2LOgoRucJXgQVCepwgH4sfuLCXOnCe5D3YRN1aQnz/97+97VXoVjfblftS2JdgR8WqakpTL8Alw/xXST3jI8duqpRpp1dWdbqP0X+0pHLkAksTifeLdIKDeVDYa7XudeXG0UGlc70y41fbH9WQ/JVDDu3D5Lys1yAM35DZvQ+gQGD7tigeA2ykjIUaAN+XuSVXo0a5S7Y40W5ogzAY80VWdYPULihQoEfnOd1SkgKeLvu4hDUVsyXQPd1ZnYNPKuoakV2qUrKlQciJZi+MpNQKoTGXPOm7lrOSSLts2HDWHHnPSkRg/y4IZQWX1hLr+lrDSl5zK93QUUcjEOvx5AeWNUmvMmiS13Hq4zJcDniRPI0zJjKPpxCbc9idhwg8MmObSWe5DYKYhd39iIWCg+s57lFGNQK+sGHyE7GWue7YVWb3oUKBGWEWZLca3u31bGdDENf1zskhWlGVllSp3NmLgYv78V4g+4hVkV6/AFD9TjfxgXTn0LA7y4VkRducLoKf26itODHd1l2jYIamfQTRMZ0WYrkVFwLS7coGwalKhS2TxfuKjEWDHN7WkcKldlVr0cwvKqDmjDAyns8WUXKH/GlQRO1AM35Na8PB3oKs2oABd7bhuKGmct1ApgqzY2hoKaHJXLLEpbdTx8UrfEU0R/54PFipGLwEqFIrn/IFOoymmRnzByClGcMsngMtuOxetk0g0mZcTe+N/IlpdJ7e81zxFIJeGeke/8Mg4LJupHcFxeSeYjrxqgzd1d X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bPVgEZT8cYWiZGmEYdedrCqVS6FkoreHbalcYzu+TBvCXjMte8jkTdUTJ67WNkD3+TLT7lv/rndZqUq6OO08ZFwLFTep1txwGRmehspONJdMqlgZ4UE1T9gyzlEhWtkQmYuMIuJkz9MOnhTmVQ2nMJIffPCzX1I5BJd/8s56J6aTRpcaa89QT/77zhfMS5YV90CAb7eKmFGKOAQGdGKft8dHSBZvaqRgu5kUW9viCkujwufEo507L+QBbC1SgOhlZEWM5B18Gw6aWOc4VG0l6NG6GXi6E+QKvzlQmmmlQ6U93g6uEhCV5RT2YJ18wzu1e/Le3IMAjhHil5ccv6L+Ea74XE/hSRBVgdAyHAWSA/1rT9fgIbR5Ao2ebSu5u3Fg0G3gW/eBOzYjdKV8iwNb3A4r7gS5YXf8WtHMfNnRmZVHoQfyHTjTDcGFpBzRaoeyYp/2aERZjD9lRY415DVO5QIP1ikdUfX4/ChTEETVQhKVcHgw/9VCsxLNaL3KARuy3U1LHg7yaVK16DJZjrqj328uN96HN+qznwMOjgTWRE448IEZ4nJX6yp0XxrDyCNTAwVBGwuHiQXaZXvyGB6QVvIjxoxQPkRcn//98KVlv1XEwC31VayZ6NByE6vlyNE3hbXWXVzHkPqYXZ2du9iMtUzNHSvkbQaGl57MkGWUc9YUPiPQgmrIqZdat4YiFKCfjl8BaAa26vr8mINM64xSyp8vhbhMsI0tjFAIxOh3Yyi8SSVMyAJFBZu42F3TIi/5U1pruvBt4UBPkItU4nO0nutPYpB0/CpqygffAQhj4iFoW6MAy6CE1+dMpPG5bjyBC5TaFwwpZ9XAss0ySWIu0pLN0azJGHqVbzmAh5CIEe5nbgEkc7VTdmBBb9Shu7q/vkGUhQ3OjxNRITUKLzUW5Iz4gqMibNQMya24SrAQoPvTSViet9jrv4RWDqx+GAMH9nb1FnevcA2rRkcyXA9yyw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e6eb506-6251-4d7c-ef45-08dbc11a343c X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 18:30:50.2985 (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: NRJN1lODVj2TDzbeJjsHX0/Qwu9nNjTDQtSmCJ3wlE6DvbjGzFI8zopk1bkK+1YNbGQf/q/BYV/5Q2ttnf7crw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7482 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-29_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=819 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309290160 X-Proofpoint-ORIG-GUID: IVGQmONZVIyrJtu6GdSsP5v7YTlTu1HV X-Proofpoint-GUID: IVGQmONZVIyrJtu6GdSsP5v7YTlTu1HV X-Rspamd-Queue-Id: A863BA0040 X-Rspam-User: X-Stat-Signature: opf5ucp96rqshnji47hxcdjaemewxiyh X-Rspamd-Server: rspam03 X-HE-Tag: 1696012272-891124 X-HE-Meta: U2FsdGVkX19m50sqOdSo+0PYYEcGmZlGWiVfUMmbtL2aJac1VPJ/nlkoG/EGYz+vkri2FvEQw5ePFEuwXTI6QhjPTlM7HApaRhj/vBj3+hcT/mo5fx3dclW6Ky/6+aA9nXOpAbbGDPqm88C1YybdfYUHeDNrVX0vZ9Hth9kD2JaAMhGMYw21+dc+TJ3qVEOX5G/h9nxBMfVMtvqOS7JU1L5Oi8huhvLQiIpsvefVbZJNjR4Sok2a/sbQQnls+CuLkAIDyyp6tKHg7LINV+YNo3uXbEjUvyCnfIVNmPKWx9icgGL4J2EVb+gSZFiwQ8kTabO9YUy7YrhS6k2oe0qahSS26nxD4/k3aq4+uhqhWa40CenRntOXgSqSlAy1lQ2cpy7l/heYAZ8N6wiL3zu47eJPkNTl1M7qNmq4sYeS+4YKesxlZUKltNtKS68dXseLfcMSJQY9YTb2S7m2WY3+0dBTTPfqJVmc/ib3j4GzqBihX4Q22N7Uxg06MRc1T93kQVcfEW8O532wgapaTcXMKKnD2zRtx9jefCp9MiEupZ/ueF+B6D+BbPBhLBN1I9GoOF/bKBpdRhgAKPIlFz3WpPXR2wNnCir6cHfPNbbFoy6iRVBcAeFr5jTYnUepajPXSyXKyiNmA18HtsU4URSwTukwMskFVo44LMvEdxDD9wjTc/K+XxSauqZPOAIDNI4TXcbXsQzHjgd3mVExu9P0L54EpkvwY73sUnpK2ixU4O6TWZiJsWhf7DAB3PFMmNBrHhYbpC7jXoI2H2TlGm0VQT8cCUK2Z0UgZRhndQQojQPT37zdas/JQeyiY28cznvT9znM+4iKDk3+dmnM1R3OWmDPAeRj87e9Tfkg1X1jQVUvj3gBACVTDKueh8KULNxV3Gy4bQt4rqKUMFIsHesMPNMzYyj8Rb5jpTYTfoeAqznjP9tNE/Usid/BdT+P967RMxTLIR6j1NnaU0Ubehz eWKDaFJD N5DBpM5LxmKW76yzdTdfJkrzF/3O7KTZIQqiuqHh78oD+JimGQvpWnEXffbzZ9scmPCcqXDMTaFQw/dycVyzw9vLXMfAXYM2TEzYr1+Rb9NAe8RwnNmNKjZbr2TfbSSrlnrSn6hm9TOd3Gf0YZmbwQOMdnJ6xFs5/L4BO+M+YSi39IBl89d2VpfgFZuNnLaniXbx6srwHhCyC2qLAvj24ilg3jr95macM9Zo8IAhipsgB+WQh+PmqzzslD/KHXxoMRkJ5rC9knadQ89qemPvizc99mAo3pcyBa5p9NoBio6Lu8TxwXxdWCKYJaOnZ5ySbMez8hzFVukR691WyiVz37xqzgt9tTOir29ZVVg3wgFDiQDeS+BlXzt4YXLmkstl2if8Zj84eaS1NsAG69HOrVs6UAWqeNddKViO8ZSoDsNKM2B5AW+zsQvMMtUzs99U2SQMX20loMDHFkeRNIpVI4fbSskFcFbiwIu6t/+cVWoi5JobGbVKki/J9w8azhGrFuy58wBsvhHW3hdeHF5UBeLzDiXqLsHPV03AbLLtFbPGFuoyah4nhlynWlNjnA8aGWPJ7 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: During the error path, the vma iterator may not be correctly positioned or set to the correct range. Undo the vma_prev() call by resetting to the passed in address. Re-walking to the same range will fix the range to the area previously passed in. Users would notice increased cycles as vma_merge() would be called an extra time with vma == prev, and thus would fail to merge and return. 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 Reviewed-by: Lorenzo Stoakes Acked-by: Vlastimil Babka --- mm/mmap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index b56a7f0c9f85..acb7dea49e23 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: + vma_iter_set(vmi, addr); + vma_iter_load(vmi); + return NULL; } /* From patchwork Fri Sep 29 18:30:40 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: 13404767 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 637BAE728D6 for ; Fri, 29 Sep 2023 18:31:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FDCE8D002B; Fri, 29 Sep 2023 14:31:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ADA58E0006; Fri, 29 Sep 2023 14:31:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA4A28D0100; Fri, 29 Sep 2023 14:31:18 -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 D94DE8D002B for ; Fri, 29 Sep 2023 14:31:18 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ABF26140CBB for ; Fri, 29 Sep 2023 18:31:18 +0000 (UTC) X-FDA: 81290477436.07.91D0954 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf14.hostedemail.com (Postfix) with ESMTP id 6344610002B for ; Fri, 29 Sep 2023 18:31:15 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=K5fKt7fT; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qgQepXnr; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf14.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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696012275; 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=GQCFQQrDB4sf0IsWat8O5FSMncreJxteifxHXWGhx+E=; b=8Z0w0twah25UtoZCMyCaZMR/7NsJrhkTWYpJGhULhqf3mBUYvKh8qocY7+DeseX7do5hMs Tco5VGopA9cAaO1ACDYeevQKnLbJdeks6LDZgtXeO4+oQUhr1d5pLhgcVNeYg5C8zhKuF1 qHn841/LcZ/OaArSWx9uVJLoEbDy38M= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1696012275; a=rsa-sha256; cv=pass; b=tqpNUivYusS+1APXa/HakK7nXJEMCnFX+SRbuXbElTDXgnff/3sy9Uhnctf9YGH4AevuYz 8CWMpu0AWK86VZfxeOOspaFoW1NHzGlxZhCpps1bB9ivx/ptuvXfwhekZwRsw+gjP8jH/N P7AZ3tqwdNtPg25gPtAZIv/RGqtAxjY= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=K5fKt7fT; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qgQepXnr; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf14.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 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 38TIJBea014141; Fri, 29 Sep 2023 18:30:56 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=GQCFQQrDB4sf0IsWat8O5FSMncreJxteifxHXWGhx+E=; b=K5fKt7fTk8QxdMyJprMpzeyOKR/SmJK8c3ZNM3WaVBY8oN4cZFYsFuj6mGwgIln3Vd+r u2/Zs6RCnUfPxzFHt2FxhdJJUccQ9+mNRKp0291EeuSUONJn8IMBL4EbXOYU3CW75u5T x0zVIa/z8njvrhTJfa6hqOhjwni+HCE9E6JJ1OspY+IPQOhVM8J7bgIgf/XbDeCPx+++ V7mibjLmnXf/5kIrdsAYFCk7OngkKE8ufTXvx4I4+e0+2PG+pHdVRGB0ljZnGPJfC6Ve A6l4gOT2r6rSlvt9I23SVpGqKfY0ERA0kOtKjnchpHHgB3SY2dKTbOzrtUMHxlyvIdL9 KQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9qmuqcca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2023 18:30:56 +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 38TI0Ot6014442; Fri, 29 Sep 2023 18:30:55 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pfc7f7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2023 18:30:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kKExDybcUQdymgUsDwzNF09D48APFxhH7GdEdXX1ZYMPrnI95lIHcg7XAWGGfEkx2/y6U1PgqiBGP7y0xHD9rnyeqG/5KDc02/ZGl4ZeK9lIe7M1XUMoAi/ywec25CZP47Oje8tG4smBCPE16tDKkJnAtTE/C+N8KMOEi33CNWphXHfbQzjQbsHjYwWrqnIK2tdUafajZORckjEzP1Qarvw4exU2F8lO0i0rtgmrcmqUJdDhSJLnGgiSpfgSWy0RTgkk3vZ6tnBiWhiHF7cYH9mpIrJcFGeRn3Oo1j8U1rAkvaG0UNcB3IyG30UQW0BMuQd31wrgjYazVJVYv+QvwA== 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=GQCFQQrDB4sf0IsWat8O5FSMncreJxteifxHXWGhx+E=; b=k3cgoNtX0BZlMYLLN3DwuzywI08dNjxngbHoUl27vv0bpZo4QFrsZ1nlWRshoPqGR/wgCHq4D91GNcHeFay+MBmznpsDPuV0ZYfFdfKpkFIcwKsZ+T8CCO69q+pWiWgNH+MrtFLViAC1LZ1rg8YzUoy5amWTLL6f4eMxBJdpUXQS/OCp8FqNeFLgYnjF9xIh8DdB3Y8K20pqkNUoBwMVlcpxnDDI5n6YOwK663QkV4VvsvCKSPXV6p2fQfJFFjM66ehjIAhCcSExvHLAW1nKmzArxABMZxXFMi7A5LGgUeAn7zZ2zARZhnKSGr3y4m6y7M9KB4B2bk5iQ+wXh9qmUw== 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=GQCFQQrDB4sf0IsWat8O5FSMncreJxteifxHXWGhx+E=; b=qgQepXnruzA2jaIivpai40rznTsxZ+yG9XOX7x8Q9KiSr0KpfOedego+p3P5ngQ/MgclyB9ZyEUaAEdincMWOt0LFgRTc6SqLg5u17FzCLTnGorz3eBIyKiWAWELfgayroeVRuLw3+o2UIEPXLS5UoGadfTitisCPYzTX/UXN+k= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CH0PR10MB7482.namprd10.prod.outlook.com (2603:10b6:610:18b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.35; Fri, 29 Sep 2023 18:30:52 +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; Fri, 29 Sep 2023 18:30:52 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: 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 v3 2/3] mmap: Fix error paths with dup_anon_vma() Date: Fri, 29 Sep 2023 14:30:40 -0400 Message-Id: <20230929183041.2835469-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230929183041.2835469-1-Liam.Howlett@oracle.com> References: <20230929183041.2835469-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0023.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d4::24) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CH0PR10MB7482:EE_ X-MS-Office365-Filtering-Correlation-Id: 935d10c3-8e28-4a25-3419-08dbc11a3610 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DnLZr1t/Ne92qL1pMz2t4Nt3YJ58AqTOKT2hkJYR9QCBFBmDWxrukADTeKce87MUrq+O22XV2BDs1MD/f3awN1ic58PlYikoamBUUlmj66q8o57cZzI5vPDFdvlbY/jHWa98Q39/xur74Pa1AwpElu0MI09YNjJ4IrIqEuab98Edk2vx18ZuMzv3vhLNoHrt2eWY9h3VX4tWlOIpggUl+qx5OYjGPOpqLiFIJEMi9vOdZPEMQ124102PhpwHZiM+qZ+vwI3QOngZ2qphJr9dqi717+tnr0HVlAnn8TfdIP8yJXvsX4dW5AK9f+D1H/KTDW3sEW9fQx4YHu4zQWM6qbMiuZK2PfIaFChLJc3NHuunaL11VxQzxpcJ1qo2s/CkkeYeBwehmFsLuIzn9nEVyoZaJbwoU1Ha2r/vfboWANgGHIENYv4zTRa5QVyAa2n1ghQ8Fc2T+/o4vBE9B9upoDcymIP6cydgGWfC5uvNfxmLE4aqa6rCI/Edyc6XLETaHnTjTWuwkXTa0gir1RB1+6e5RsoPwMIrw9F5YfnXg4UeWMS8pktE1lz8q4tJ8azcly+KNQw9Pu5gfOupDRRlKX8MNvzSKyeoD40oIOjwu6g= 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)(346002)(396003)(136003)(366004)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(41300700001)(54906003)(316002)(6916009)(66946007)(8676002)(4326008)(8936002)(66476007)(66556008)(5660300002)(83380400001)(6666004)(478600001)(6506007)(26005)(6512007)(1076003)(2616005)(38100700002)(86362001)(36756003)(6486002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l+zogb8dGhDELDNZQtg/b6LjEl5l4Nuaulb66pwLdQFZPCjkAJZdcaVLVR31L2W8283z03gVHF+/3agiHRGHSD23yU8wfb1pVq+BqCqnLhGoaNUpzEOGsc2xx8zNxZggWyffxnUl90IT8+Q3OGCaP/bUTUjwYEySiA3W7Mpyouz6TLMDXzjgofYNE98KfBgEj9tM47Dx1zvVfHvGzZSzkc3WAkOO4W3q6PANNK6susdKtoAVFLp0pZvg3AwYuwFWtNVmM2jL32A7iETDQrgzzEmwOCKpcJXStKfgDIY11mrE6FJXNvxw7YboiWUIT1pnRU+ctIrgP98RyZEYV8R3wo2vhe1JmPi3bsMy5GoU4eBreDi3NUsSPGyH5sq6DAOh3HlSVlGhSy1EW5NbF1Qem8h8h4FfVkEZIe8pWMo4CRWraLSu0g4ZZnxV/apXikvF0dwH2cfwBl0s397GwqdF7S5I/t2a4Y0ILY91Hr9jcF2Erya3CcQV2icfs5y0GntniZFup89SM0D7kUwtADgiV8eOjhIUH1U8tGwIpUiHEkgSZbS9crvKg33tIwgYOoRf3+9yxJg3yqXsc1jSrxcgQRKU/XRjzrSnITWaWGL7f4eQ0SMYR2YYVEmBTgFV3H2TujUErvh+Ehiv8NW86rG3cgolKkhI+EwauZp3Iv+cqvlOJ0VC252aC8zD01eJGoqX/RQAX8ehSeKeRmh78o492m2B6ejt3yZe3S4uQO3jRZWnZPhcbl9ol+wLK0/2LsRoVqIKdzLdYxpre5yZ3DJPYC13g+pEBrB96UJCimlYW90bWhLevE1sR+jSCssBoXTlo2m2mAdF5N67Ce4vzknM7PJb1Ex4HUB25lwQ7+vl6F1cI11qCSzqgsmYI2BfK6kAJP4h06DCRLIru3F2no3pHNA3SfpCb01OS6Zk2DxPI5dPTWCZeA5Egh0ngF8N5tbL+G/8vJSBbwRl09n8ztKApwLbKwmR7S/afA63+DDZhvFhMEqX2jKZUDb7txl/oFjdJpeBWPGe9VglXyhmqN1V8Y1WJB9HsZSCxtMqQaDTvqEpDpbEFePezNqDAe5o07P2Hl/hTMihKFp41qc/oiSMWvPcWaVBLY7lRZixkfVZPW42z6GWr2oOZX+cu02ET9sh6oz5HkwM6o1DezGT0gCXpxk/+1z60dg+sQBxci2TP71Myr7f5NfhcgIx2R5AkcpTynp9JezjOT5ZIQDohXB7vfZNwQZup3xonpqkfLfsfjCom0QUbUKbILDkB0fenbr59/RF+duad+SqbsKV59+8LTyI4XRucg8dkxJ5UkQ31bPxTONS7X96iSyjb2I0/Uykt4/gdzkfNO79mcmWGECHbBUIE6Il+r8g68FwSl7l81fM1NQ1I8vxIRXLIcscv4SsYHE9+NmhINDiA0LPAtSpfVZt1dgIlQj2jcGMEG6Q5wwqhNxmMZ5II6uIDLKhakFypcUEifBb8+KdfgrdfZJhBVjlrQgmoXk87l4uN66dNnsHuygwyV1NmyfKP4TmVTULXNtQKXntfXQ18iMhKhP13G50pUGGvWa5BON6wJY1M23CcfF2w2n4Eczqnwgcb4zf X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 4S4VkMebMJF+I2zqSPJ4pJ/tCBeEjFwG2hPCTd55suUJmM459AZxE4DS9CpdLrESXel6RYD7PQCQRMfii4QjNZJJv5SytBCl/L+XkYkQPiw+M2d689PbatF3ZwfxNMZjSdCa8tznksFQjXjpRN+s8olFhCUm6pUzvB6TvB8cO/iaGjDfUQQ5N+fveDX5zFCSdvJRLmNLZVSa/mHglI6PbkLM3Jp9b5WhCGi0GFXzH+6r5U7+wccB0Udpp1f64FeO5e3uuHe7uTwwrBkB4gWIKHgPunrSI9fx7cujHmg3xg7GthlP2jPoIvbSAAZT6S3XeQnKPjC4IbQs/TKPBfyNb7ZimrAUPMv5IeKC0ApWNd5HMJJnK7j1kTyisOtfr9RSUcQpg1SkWQmsCw76+r1xox+l52jSA9Egtes2Z0t+pSsgFTKasp3dpUX7uFpGySC+rAXQCOlC4+7FBpcyhZev1rwJRLURWLoC52y1jqiEMfrrDfTGSxTJqam2nyr7lMAoOkGSk/hyryV2nole8NJqTmPkw+Uuy1xtjHlcBdv34W3vN0NEFuA4ghui7Sv4nZVZm5suXNe/lItS8iMqEK5xrphMHmK1721l8WIz9RzTd7KOIPTghzINBV5vXWJv61hemMjFtGrABRSd70PRSoe/YqkaaI9a2J4198pAMqwJVfl/Rz88fAfYLKXRZS9vsIJ/4gDoqVASQJZRj5juLFJHIR6ppUBbicXMXzxKn+eJzSNfSQT76VGC3McHeVUC+1WjGc4V/4+4QS14xZywk7O06M9YgaogeyrDXA6KcDCOwV6WyEGedVjn6fEyveFfli8W09ntxbuDFel33YCWXoqu+TpS4mZWVyeVtLbr1z3FLg69BEUH7uiM3uZIkzlp1SABBdtY71bbMj9pM40P0UvHZRpsytwHWMBnsqwebR4MDzMeuaSgC5cfpQpkLLwlxqoO3vvROGQFp9F/xM+3gWK4Hg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 935d10c3-8e28-4a25-3419-08dbc11a3610 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 18:30:52.5034 (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: Q5dSuGunbf8O6xQ++SQJKVrGQwp5NgdZTLIP6iPhayNBj8+02mdI6v+YuIfMDJ8s0s381j6hVVm88gGGwL4Emw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7482 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-29_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=939 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309290160 X-Proofpoint-GUID: qGKedXrmf0HFkzM0JaFUnsA7PO3Z4LSM X-Proofpoint-ORIG-GUID: qGKedXrmf0HFkzM0JaFUnsA7PO3Z4LSM X-Stat-Signature: 4rusaazc8z1uy5pwwjik8fkabjbcwiwj X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6344610002B X-Rspam-User: X-HE-Tag: 1696012275-841851 X-HE-Meta: U2FsdGVkX191ItMI4qOtiBb/HB2tLFAvKn9yODMvaUViuXP5nxaPO2KdBztT8A6RfcJ8xTEqRYI6vvTTmR4NpFrzx/pByvDh41E+w4nSW107QSIt7oYXTnZcyxuQJ+xS84ZxsnhRgrThSn0zRam1iYt0dkhM8kSvEcn1cToyxSymXgwlezFQoD8vVh9tf5cesmj0I7EDsM7Q8Y/4qHnDHvLVuuKiX63/jE9BDQJ/eFQkgZUsfq3mC1j2CU03TJK9vWgrV6nmiLY6SAu6o9cirX4OA1wid4eOj4pi6F9l0VX0zlueupF/dDNSr4v26LXBhKZsxsK13amyIQzFUWNl39bpz3e/vv+m7SLUFPrL/Xzz+TfOkpC+nYZOvHsFb/bKjtn6zR13PcIy2CY2fTx+9Ag2DlRttlCGrH6bGC1TvjaHwhIcVgf+G1fQvfSqVMWVag1CmbS+mp6S5cG2Ba/JgoppBcKJCHmnLJZTKMlobYwVfDqFFna1zkpKbXhxeotdA3OlaAWonGKYu/nFBXU0VLSdkgZ9HHhOXVn5MUJMFmq7T1pn+fSvk6PKWamZQZUulWAriSJB/w5Qc7w3UKKV0d5X1D/spOA5msiDhH4lvS/6+J9bzh9Yc//mCZOko6j2QG2nnSUhdU0cnqC4EN83HyG8DDlEkQws6BL9ZUwEhYwvDck0zxvrlGhNPM1Q2Sw2/khHkbdoRQwlKqX9+ef6d/TGWmcpRAfDWpdxADpWBqnQ4f18eZz7su022Dh58GgIiu/qQve/cH1axkWcHtzeoutAtnZ/gnXxhbNHMihcZ/SCsVDbxtA0W/eObasWS/CIJUP5GiStaP6TALpdS6m25vibC5Y9h1JrYosaLW8tOY/0aoZOo6rMV54EtMbGSNtbKmKKkexkB8j9XrJW6sRmXUbVjpZnOPcYpebaj1nLA3CpgZ7PZ0zUWxGZL5WftzPljcrKzyzAL8F320yxnyW 4nglwAB1 6yy6n/AksKSnOr5mmf4ukuwm7geG2QMqjQwIQTfa+jjwLhBrNsW/VctMaLMgJurucZOJYKgGrHb/CCTRHVjq997eQAXkDbDyErkJefx024KwIxldfTRSGu5gMDjMR3rn3KHrd/mHmcO4OKKCsMpTSCRy4bwLFv9Cd0W3fQJGTgFiFAs0DpCcgzYILw4z/OBqdeY6eNvus+n9Dug5H8ms+BSx1HDRSIfTsoOBYaUGVBH6zGYsV5FR2IdDY/jctFximn8kLwtMLkOwqrLFQosewsCBg3XDCC0XEWXuCjlpvNcVeJzVkJq17QoA+y1wYDN81iXu/F0i6dwX7Pq+4BelvSDjY2LoDCBcoszfVC9JhYVfyReYygvMG+PdArfJnsFb3ZuIujm3fHyWrrg65R/ZDoe825VQnP8FG5J7j7kGhlB9BLa1RQk9eTrz8y5yxacWSRu+vX+1K7EiHoIKPvXVd6u7KkSPcENOSO/K1MTH8OtnAMg/NUW61KSIfVwQdxL3YUy09Fe0cYhIJOb/nHFGv64DKDwE/LMEUskUt 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 Reviewed-by: Lorenzo Stoakes Acked-by: Vlastimil Babka --- mm/mmap.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index acb7dea49e23..f9f0a5fe4db4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -583,11 +583,12 @@ static inline void vma_complete(struct vma_prepare *vp, * dup_anon_vma() - Helper function to duplicate anon_vma * @dst: The destination VMA * @src: The source VMA + * @dup: Pointer to the destination VMA when successful. * * 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 @@ -595,9 +596,15 @@ static inline int dup_anon_vma(struct vm_area_struct *dst, * anon pages imported. */ if (src->anon_vma && !dst->anon_vma) { + int ret; + vma_assert_write_locked(dst); dst->anon_vma = src->anon_vma; - return anon_vma_clone(dst, src); + ret = anon_vma_clone(dst, src); + if (ret) + return ret; + + *dup = dst; } return 0; @@ -624,6 +631,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 +641,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 +669,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 +870,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 +938,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 +965,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 +979,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 +1029,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: vma_iter_set(vmi, addr); vma_iter_load(vmi); From patchwork Fri Sep 29 18:30:41 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: 13404768 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 CEBD4E728D7 for ; Fri, 29 Sep 2023 18:31:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61AD38E0007; Fri, 29 Sep 2023 14:31:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FD008E0006; Fri, 29 Sep 2023 14:31:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41D088E0007; Fri, 29 Sep 2023 14:31:24 -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 3286E8E0006 for ; Fri, 29 Sep 2023 14:31:24 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F3052804BD for ; Fri, 29 Sep 2023 18:31:23 +0000 (UTC) X-FDA: 81290477646.27.262B9F1 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf08.hostedemail.com (Postfix) with ESMTP id 94EA9160007 for ; Fri, 29 Sep 2023 18:31:20 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=t5jtwpR2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="vi/Eqlkf"; spf=pass (imf08.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1696012280; 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=5nil0SxwBCPntCRyXfe7xa/INjPoi9AoymhBJu9NOEU=; b=R8TqOP9nk8/IT7tENLb9mskmd+9ef/rAeYWxd1zxZmzQSS3+5UnLdQ3U0WB2kUD/Rdi54M t1s0YcoZdZigW+0CDdgW9BcBYHhs1FALEXQqJTDAJe74d8wDYC0yIK01o4gWSHMC6B66us Okm2smbBOI301g4ImdLcsxv9mzltQ2E= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1696012280; a=rsa-sha256; cv=pass; b=H3NVu0fBgey6J8o6BZgLCngOvFopmNprHq5o89nVeM3UORltzdz+45DzLiM5upJIxdej8X jPGrPhWPx2JX+UN50wJW4IlPYUI4wGt6EYPiw3YWkufidHzn+VQjaDNHp19hjRrxtkXWq8 RpNDNtXc1cr7WZB/MkrM4Eh+q4GylqA= ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=t5jtwpR2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="vi/Eqlkf"; spf=pass (imf08.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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 (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38TIJlB8014029; Fri, 29 Sep 2023 18:31:02 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=5nil0SxwBCPntCRyXfe7xa/INjPoi9AoymhBJu9NOEU=; b=t5jtwpR2VWFCDzEvo22hpoeWcepeS9QqsP2ycSgxAd60vdnTBTMoVTyq+4DBNCN/MquM 5mB9L3dAR0f1knpVQw2JP4o3rQFg8H+kT1mFfOcOJqPD9I9/KcFqRlKssKexTyDsmPyV d+9iqPKEFIFZazKAPskmgI6qRjOZYB7Rkwe+S8VjhYQ/Zor+ncCDjTSjt8eHuAR26e3M DGCn6rrx1NBOZsZY0yMMFa200toJqh8ACfLq0KGAT2FThAhs+L5h2szKKVa6ic935Enh H+UMgqPXY1lVmQH6+/wE4lQui+Yp0INCzI6d2/Rh2JAo4grG9s/h9xIw9tyC2iQkutkv Kg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9pxc7gu7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2023 18:31:02 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38TI5Sut025499; Fri, 29 Sep 2023 18:31:01 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pfhphv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2023 18:31:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SV7ZxLqPnabUm5DYiIEWx7olipSiq77EWyl/6NKD2r8L0QIJ+apdKtVBpfN1At9fRgadzC4nuUTOGtH6AprDe8okU6RwXK5tt5EeIDBKq3KMLHyrcQv+p2+q5BzZWqJe8/kRf40vMh6qmUSYqRmxtSKRqXBVHnxPSGcjq1ngDoBB8UsNxYe/8ljpMo8JqvNJcLHvGQof0ukbbEgvblJLlrisLfbnx4ZvQoPiEkyHvjNxgJ4WRCHmNq0+1AX+Fzf6Az/aOOFjAdklA5mOlujfTEvQeiGvuNaA3UQ1hUcVp0BQn6GaQC6Oww5M5RngnGEctWOauyRfw5Apzf766kUJXg== 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=5nil0SxwBCPntCRyXfe7xa/INjPoi9AoymhBJu9NOEU=; b=fF7qWDvYn2QToDfHOlkX1iG1V4OveFr94zczp/eeEngqUsyJ6LL8HG2N/1YhRIk19PlCpi/Ofzhn1cAH60jAOCbEF6g3rIiHRe7pmjhpWcsMj6cM8yT7C26VOI4kXIEwhlLE0rRhkhS0Hzu5Jvapf3szI0ty3+a7RA5jLaBQW/y5VTHDzK8uG1F74E4bqplr3hFyVqvGDfV2l4BKMZc0ZoH9dHDfSXk0xQNaiDhtqD36V0Z98PABvRy85RwgQZq+XZh+b7Mx3/GOuVecKWpMl3UshHypi6T27eqj/4Py2zV+uexI60IRIKVpU1WglHBD6hONHPJL91D7Q4pXUGtILA== 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=5nil0SxwBCPntCRyXfe7xa/INjPoi9AoymhBJu9NOEU=; b=vi/EqlkfkpnJwKsUqSYTumEu4oJYf/nKJ6RmVuDZXdCJt+VJ7u6r46OUnzXlZNUTUP3ww7EiED7NIqVjjpm+JU1KziObzijg14O4jxaSziA/d/lKO9VZT7R0D0XkcQgYqiM7i0Vc8RAYq//qTuSLZSC7BwjCUYxSAy4tTefM+E4= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CH0PR10MB7482.namprd10.prod.outlook.com (2603:10b6:610:18b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.35; Fri, 29 Sep 2023 18:30:57 +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; Fri, 29 Sep 2023 18:30:54 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jann Horn , Lorenzo Stoakes , Vlastimil Babka , Suren Baghdasaryan , Matthew Wilcox , "Liam R. Howlett" Subject: [PATCH v3 3/3] mmap: Add clarifying comment to vma_merge() code Date: Fri, 29 Sep 2023 14:30:41 -0400 Message-Id: <20230929183041.2835469-4-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230929183041.2835469-1-Liam.Howlett@oracle.com> References: <20230929183041.2835469-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0063.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:111::15) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CH0PR10MB7482:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a4db761-7c3a-4a21-a5c8-08dbc11a378d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZN7hMbEK4yJdt5qnh5dUT+t84eR8XaVXIPdKoX6LFHVPK8rWwK/KuDrAdnADIqQ4qZWbS1DKKc+GKL5PhTN0dSVAadtXEaoMRJC3EN33BeB3BXoS0jg5+81IPZmQmTzGAE0lasjABdNWclaU2qTQydDVaQs4EUfpiCR/JYVK7G7OkP3pBuB09VaUuYPLUbw+PYOPsAuvg6s+8/PGnnsujXZY+23Eww+G6jlaAwmQncX6bey2fPJszXnIYGR2jf5Gih+n0oIO9gguuduN5vKst53nne9kkXQZCwOszMi03r/vIsMfG+F/+od2IgSayh0ao94KYbvID+uZAQsie7xyygtv5fmrOG9PmNPAwhx526OBBh/14PkNzYNoiOItj2mF2L2YBMzCAL+njNkt/JVwrF9fzkZKaPOuudSRFAU69SZfwr621KUllc+VhHUVi1DWn8TIHIaouO/3Brdp0suQDmyQj/GveN34T/zzzd5/KyESItUlaRUwkeXj04hQe0QCk1PT0fWIjid+u+x79Pu0IfuhgIR2Q6fd2ox6G5fHV2cObyg3VhgWymbP4bHWp62LQXZ97cjShwsm4PclXUQ51/eexU5MsCrJtLY222LLMuU= 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)(346002)(396003)(136003)(366004)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(41300700001)(54906003)(316002)(6916009)(66946007)(8676002)(4326008)(8936002)(66476007)(66556008)(5660300002)(6666004)(4744005)(966005)(478600001)(6506007)(26005)(6512007)(1076003)(107886003)(2616005)(38100700002)(86362001)(36756003)(6486002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QCMbe91uvGZ6VIcPH/JNVWUmQdpwjLFl57rFdUvU5vVuaUPlm26fuehWM2Ux+M4cQiaecBqBEKHgPd3+8DgZoziTzaEyIB1D1n2FS2GnwjIcpYP/VkRGgv3ldV1E9aiRsL23OU/I+MNMYK4zRoBX425bUgs6Vvtw0wNt1wX3MppY9XSEWYEwIfL38iUh+4Bi5Z7nrUNXgGkMOvCuDz3zoUwP5THAmOFdW6m4q25f8qxL73QUjrUKZQ6hLRSvOn24vX5jEJ6r4s/9XLba2bzEL76oUPUvcv4/nSh5otz412gFW5xSZdHhpJVYs9+vknjfcV1IBbWya5G61Quk/lUGWqSJQ9ha9Wvnk72O99H4hD/ejgtbtXgYZnMGrPH6Zm0Km9PrIDTxQtY5erBRr37oWWDkQ5jb7cczRZAJo33AsWDFlqWlOJJGM0ApjhjasQTNhz76SrbEW9tOdk6s0N+mSCTdhozPalaZhW5kjAQXui2vssKakQkEsQ/ztIBxIWZge/W/+8pw4XC8dO8Zv3h2dfRVi31TTCEKFBmI9x+A7wc4W5dL6sDveZv0E4ayU1VrnR8z0gTXYqfs1ca/CFmo9HIa6UOy9zQ244TkLIIXLLT2ox5+3ugUGfaSXd73c5LcLqC3OkIOyJcXKcOI9ER1PW6TTTAqvUBrnS5209G8LGjiv3hy73WA8v1ajxmZcC4vZeTwL/7XpcR7yZY5hZGhQEdWvPcIT3SA/9aYlJ0KNwO4XijCXiHFqiZT20U4aeNc9Eog9rT9/Qc6nzWC6JSUUXsaGIXW6K9hKvZyZKL1VLqnEN238Sk9O1n9Nj0Dbeh6uPJTzDVAEMT9p6UCLwR5US6Q5xe/8iplWvC7XAvV8GnxWbdMQ3MRjQGPvbWo33j4gYnvc6vG3Egta/mM0+KJ/8Vo1lCkNHAk7zpEx4qgYVj9oQDEAs1ypq9VAtfYMIXk+OvmfEM2zcIhfhneYCYcCzULT/ai/AdsKCLI40b/0oB/ORhRhXAEzBAnQpw1cEeSY7I40JZKSaca1ayaaruV7nM9rh/OihtwhDakBfeNn4Y+ykrmqcF5943Dn6mvYwfDmZderJFlZ9aOpNqRnnn7qTl+1EO3E3qVfb/uldr9sIWP1u0hmWOpbpKtxVE+3RBBu8k8PcStUEmj1E7wzFIvHNMb6MNUn4kY/V2o5BlOlqrPN0YyRySppoluDxECLor9Zl+3sxZaFvXskPW999GEzTYls7S9++P8/97pCKdOP+Od8lYG74WnHOgj4YQDoYsHRV97Xft3QTR5F2B3ya8Z+hX6RXnDCrfJrY7TtwAOCKP6xP2cR4R+yF1aalnPgWk9XuggX88mcipqNxSr5dHanqjQJze/Xtj4X+Kpyt+QpY8Y8bJ94ViPuab6Me4+nI4FVan4oxOhsMBtdyI7nUmtVfzQFCBmaaBSMJr0STiWPKzMwzvWFpYm4PMTCD3uGYcnDZ3eHxalRCpL0Qk/W8GXN27Alzbnx3rJ4WZYZJnwNrWDNkae5ru27QDR38sV6qM9OIfZO1L0r0r7Y8DyTujYY1TpxFsHbhORV6SDJRo/mUOga9SUH//TEvZkqN2HofIw X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: WGHm2YKBV1X+loiI8abPoVnlspK9xDfjFBtIZeR+xNkleWmn/UOu8TkO1XkqpJG/9IRWtLdN+0R/jlKiaYp0NQO18iqb9MsT9w2NzDzMJw5fybAA2nfZg7yOE1MsVASeXlmfoJTcU0P7jbCswMt2qteE6S3R8sJZDJI4A1q3O/JD3qwZltlQVtcys8fTWf6d22oAQG28UXODMoseexgD7QoORfUv20CrCzziod8VkIaGaJVqORGnrywx/d0beIM/RX0MSBWugs4UHLKBF3kPL9PFujV4ZR4S9Xx4ecpkLKghIYwiQC8x8gQSwTsWhvxY5lXy3yaH22/E8gfUf/pbozkjz/3ZFF/OP9XSuwlGlgl+/MKrinWe7c3tRYvemh/c+ovo0Q5euPnnYYIxKHYTscefmmiRQ9h2gfuISC+Q56PT/tjdt4hEhhqu5Fkr99p4KjkSU8nHArgnFreCSbYSQXs2wSsaEYDnh0Rs8YcakGacpKlVBEsIqisVRWukVqtoJyeANTKLBxM/6Ki16tMv3AOTQ/oDYkniEc6FClEbYP0ITDERDhAfHvMBVDddGcbfYSfXfgyLhpVtgrCj4NVa/Rbuc2cTakTrPnTa5bLDBrzYQJWWFswdbtunYRYjpjDutNuWcS5Q14Hi1vCprL+pGuKMgBL9LCrJ69muFDnzk4ISBzRBRE587yCMXV0Zw2IYBv0AnoQfB28Hb3RPhgOllFo8CWpvbV6XTnbf4wik+xSHvo0C/HlG+sYHAtp8oelm4E7ArsAeHIUYAu2EN7Bo4OJFojGDXnTbBeUcPLONAfrfWW/Vs4VdFQGC3/xP8b4w46WvcAumPk0z676eLnM8AZEzqlhrRAQUX0GO87SyBS4bHBioc1a9FQK5y7rl4K7su3OHhJ9pnnichkGYHSFr9k/OwSgo6VFiNXwreTHAhccYaJNw5A00wkV/iD5t02Zp3Iw2UgAjqb6JDtRuu/SyoA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a4db761-7c3a-4a21-a5c8-08dbc11a378d X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 18:30:54.9544 (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: ujGEhjsRzfrA3VhUzmqXLT9VdcFe3zQqMohGuxEet5ovlsW3+FY8hFHPLaRlydMHxpxE1XU1tpYex/lDCsJMFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7482 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-29_16,2023-09-28_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309290160 X-Proofpoint-GUID: T2udX_rXcYI9ZNWQXCW4brP5RmhRsUfJ X-Proofpoint-ORIG-GUID: T2udX_rXcYI9ZNWQXCW4brP5RmhRsUfJ X-Rspamd-Queue-Id: 94EA9160007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6wygq3ag193ti99a4fng7w43eae354hw X-HE-Tag: 1696012280-662099 X-HE-Meta: U2FsdGVkX1/vq2PDtqQJsTFlBmU5aPQk2rdcBVkP7IxtFKT6NeqGil1WoFSB6dyuofgz9a0P2reolzT0atJ01Q990gqJZ+ljhOuhq9btS099EUueVAPbaYlaGUDTpfy5KHFwPiw9NmRWzqEdIwJWFNmrutwkwJPUio740YM5dE1YEoJdysuFkVZSI+1S+WY/aJnixab6I47nvbYXnELBG4gPHSqm+jibl8kOCd1TgBDJ4Q5i9nmzz00rE6MkDD20D/sfnWgKcKZKBx23R0qsZNRZH4JL3hbwhNubpw0ShMHW/Qz77pqrZ1NvkkE1zbeY+ikNOR6h9eaEuGNYPOY0z47WVw13PJRf6rZyqaQBJ7US/pZorCE77TKtf0/Tp8npsCsFgTqX9hVJvUETu1huxInVGw0w1GKDEPCIZXYKWT5iXQWy32TWUVNyZRH0iKb8y9rDNYnI/O/oQfQj2vXnxYWOOAsiawR1V4T4ofT0PaVf8vHslpjKvCQ8LytU/D0qtcy5qu13zTYJwmqAj8L+zW19puriCnFTpGh1GvAJC51nrqJ4RJSqEFPDGAs9dgzWdNTiBblo8y2SuAIJmuoW/HbER+eogv5d2yGiBnaL0Q2R0ouj0msqp94DaLLvqUgcRJeFUUp5qnab6DWmcoNqLJz9V3Im7UZYzGgvbLfxU3Nh6XOZn3tZ4EhNiNd9kpa8DuQjS27wmZAaKnMlGRHez6yYWyYBa4ef/5bC8xxaPah6H/WhYxWxPXIfMBh5mQ6P20Y/5v/H7LPpaHZho8voWbjSGJCBZ7jQ/qjeZ9V/J6pXWMRVlOO5JDQgTyddDFd05qvJa/Mw7Fb/9zpeHqN0uN+e0XtOcWRT+F6Tohl4ttSdkQyKFXEoyGV2MAKYeDvTFEEt5svku7OePR4D9N5QDGD63B09/CpkWVHYx9kP6gAGlsTyC/EAQvLKVUl3nglJouV4JmUm6p+StuzLVGE QGDpN+p9 PL2KsBpMQBZJICc9yhwCEpFL30+BOS8iU1OAi4ShZl3EzwGRPB2+SzWjve2U1fa49KsxSZBRFXaE8cYOmQS4tuKgflSTBqwbHxDZp0OtXnbmKHat5R4NYmcrfxUT3P1ZqfB1Js7fn95X/R8mBa13ba98IIW/le0eERs6wbsLijsxZQIOCQaSlfBL5KNiLVjFt1kshNKmYnuO0Y07+ltI3nixL1KZ2K8JCmiVa7yA5Sn8NXqJ27r6cVvHl1H+W9PZ0ZHacxHoREiM+sCks8likq7mHC8tuzWgWcmBuLN8bgZt8tZg2DKWG8IkAD6MJ3z9z0oMsovUcZ8BptUoUcp1mro6NFjvcudPxe1A3beNNCs6Myw9gdENrhx9Kxr1fQx/Yg5aGPKTmFGTt7LGbuiTqgA/8iGwZh8QZ2OKZbdWErsLjX13f03v8BVCVkWGH1aoqiQtkzThkrQAX7CDRoYw4yUOEigcZ5kemQ8L991qXdbtZVtRaSwA9ze5R3PVyEbNSvu7HHh61bc3LX6FvzM0xPkn/3rQH4yJu0wiYrzuIvMZgMv4ycPJBcQCiKw== 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 Reviewed-by: Lorenzo Stoakes Acked-by: Vlastimil Babka --- mm/mmap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index f9f0a5fe4db4..9967acbd070f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -943,6 +943,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); }