From patchwork Wed Oct 23 20:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13847894 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 2B327CFA46A for ; Wed, 23 Oct 2024 20:39:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B35D66B00A9; Wed, 23 Oct 2024 16:39:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE6316B00AA; Wed, 23 Oct 2024 16:39:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E9CA6B00AB; Wed, 23 Oct 2024 16:39:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 692CF6B00A9 for ; Wed, 23 Oct 2024 16:39:06 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5BE0240EAF for ; Wed, 23 Oct 2024 20:38:56 +0000 (UTC) X-FDA: 82706030988.24.19F5644 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 0C3F3180011 for ; Wed, 23 Oct 2024 20:38:59 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Ab7rGpCW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=geJxMFBR; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf24.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1729715818; a=rsa-sha256; cv=pass; b=AMXzeEEF+nwg6jl7g3tnbFK3qNkUJIY6gJef6U9vQDym0s4g1IPkV1Qbc5RL9WusDVffc4 zrZkTuNau3RPB0NsofvYujRNpa+uVIgOv46k3iLB3TeS6lYcVDwtR6U9ZNwKT1zXFiXBnb QErW3mkglcradNDRuBiSIPDB6evQdLA= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Ab7rGpCW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=geJxMFBR; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf24.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729715818; 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=isYXjEUHVJpnaUR/SKlmRO3SkZ58UHRLRDJ+bIB+HNg=; b=ATTpXZDquqMjYfNgAPWkju8pOqHd/DfFhRWfOdmZVo0zd+GmMWnCJw7FimLmiiD/rXha06 YbIi7zeJ0IFlC3kIMLhcbO4kWr5w9z8G24m2583ZY3QK0fUhzRpl5CqaI340MkB1o0nc18 UOXK+RgGNhT3VaWg+2ci75TsD5EkdNQ= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49NKcZKS025393; Wed, 23 Oct 2024 20:39:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=isYXjEUHVJpnaUR/SKlmRO3SkZ58UHRLRDJ+bIB+HNg=; b= Ab7rGpCWlni6wz5UCHnIpmQGIT2Lc5L7WvQBXZhlk22Bk2Gb0ib5YhY557RbXpTU muZuPIJr64Bwnq+eN9bFHci6b9ZM3/FWVGj5UbgljPoH69ePxhATc7ZLP6+OxkvY j2XlUJ1y8JWy2qfxi4UnwRpfIibGkRsDuEj9wNIqz0dgvwzQf8SlbnbrP3FtHRWc aMPtTKnZ0LUBaDecWzn+ENwO+QkLFetXQTsp90eC+p09pKxRF7amLNS1Z1BwQi/O jD45y8n6kq5yxH8UYJMkP/RVS4M0f3rBoYR5Kozg/F+cGzRm7+yQnXcLASSfW6g4 2y2tkXK+PaenWgsvebublA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c57qh5ct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2024 20:39:00 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49NJUVje039523; Wed, 23 Oct 2024 20:39:00 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2170.outbound.protection.outlook.com [104.47.73.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42emhbj44w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2024 20:38:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q2bBUG09nj28x37rNkTfmaziMfGAxuLy0e+ffwaG6sv7WIfxqhH1HkpsfsqHhksRf3iej3mjAzi35d6aanOr2ojSY+kqU2IivzwyaU7pNE3pV1UyKbNutLF9qMCBGisG1cSuZGKg44HlkGy02VSUr9BAD1zS61+DA9l/Dob8hZgrkgTjClvpgwHiYV1K8vWgGQx0HVVszrve8giSvO7Ae6Dc0oJkpfaoXLaa1YoWAL3GXmxUJLYbiEOJQYkXGIxMdN67n0cb5cKzd+WyezjD8ca01ibZRffRjh9rHAFPPdVkbiiQ1tKavgXzrJHdIOLnLI+zJpoUQ2A4yVmqlVMWgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=isYXjEUHVJpnaUR/SKlmRO3SkZ58UHRLRDJ+bIB+HNg=; b=l+/IrsnWzOSAvwLGlhBR32DHcceENHoFnfo1jKIXlZ4c+kwDRe+4WoDtDElOz+3EXwTXIMaNSWTT9tRbOR9wn4Q3yAk1kvyUNb3h1ufvJVz85mrdegkV6uwMq0oEhlMoQMlNrTLpo08imDma6sgub3mApOj2frpTIRwCrJ3O1ByapN4URWt0FoaZAMbQQ7wsi37KQd8U+/uJuI2ByRRzHeMeNP7WLDhDGkHTmPzFRyLm9imFlYc19HQDJWPsPz5B1Jg+tghraKQT+LwHDUegmJe0+13lDoh37t8/4BDwghimuO/ElRiqZaJEZvwLhHa683yJDSiB+GU/fOspuEiOaw== 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=isYXjEUHVJpnaUR/SKlmRO3SkZ58UHRLRDJ+bIB+HNg=; b=geJxMFBRfc2bgwob1tvBUEdI29x02RnKDAJj4nQOntFb5m7StU+yWM7TygScCfl72nwXGv6ftGYKouwij/cWpdl8CdrtNJ43Aj9SNtyygUwC/xPcylMnY123pYJwUEdqF/+vT6HZFvg0mjHE6U3f2TltfZfpC1Qo2EuYgEfJImU= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SJ0PR10MB5833.namprd10.prod.outlook.com (2603:10b6:a03:3ed::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Wed, 23 Oct 2024 20:38:57 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8069.024; Wed, 23 Oct 2024 20:38:57 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu Subject: [PATCH hotfix 6.12 v2 2/8] mm: unconditionally close VMAs on error Date: Wed, 23 Oct 2024 21:38:27 +0100 Message-ID: <72a81a6fb997508db644313a5fdf4d239f620da6.1729715266.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0028.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::15) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SJ0PR10MB5833:EE_ X-MS-Office365-Filtering-Correlation-Id: 35cb7490-a50d-4333-26c7-08dcf3a2b767 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|10070799003; X-Microsoft-Antispam-Message-Info: YAEl1lPPiYImrNxjt+zyAmv1NiHnF0PHzrzNgteahTq6cb54YpKIdepOsTG1ioI38ltRS3mULSbid+9iHoIAheTMF6G7eLojlWct0NsI3xx3AF+YDoG72xT6WiJU+SPLZ63yRLCJYFSV/J44BmAiVqdxnRr986bEs4sY0xFk04Axj0pFIFtFSmDAMX19kwb4pRdf4fyB4tOF8U/CG7ORem4acEMNySD5yN4M2OvTScRb7NdK4kxnROBvrKlV01A5vnJk14Py3l72WvXlEk2JYHCE3wrNTPM9B3gTahWyNTEi+S1n3SY28fDGoso4ReTf6qccZXq63dn6lP6W4gv/+sY+beMFqxucLmfs0AFnRNow6z2VXfpXtAe4NAbk5g7Y2R4lJqASP8FWbmofezH7E/cFAq2YubMTZP7/iKrB9FGZYUEbK2cfS2QHnvixKZjCN/lDwtFhoI8ZXpa38QQNyT1Z5s54sZS5JPYbjyB8v3UuwvIUbbF+eZxUqe4eIZYlk+8JGgdzaAnkY+ZVspnjBVgEv7SRAPrngLczPukcIbmQrx9ynOhPyTYiUf5FGQKrtW2C6KU+Es1EQgZKisaEGCpSHc5abFtJO/APf/VI5qJJDOqLh2vJxGAjf5Gr5oW0tGqGSu6lBJQNuGn89wN8mogAaKcTGDOiHTR5VmEO03txBnbRhvvsXWHRQKtsMXtWmqb365IRK8tDynqOUzCU2Pj3+7UrPB0rW2wD2vJAoEUFywBU1a8Uo7kWmMpwZeAILCJ2gWJ2600scQdSGRC51fFQ+O0z5bcnP3GcD8JWsDyS4NWd3rJkspd1PNoFOErFITGA7e7TzPg5AMIdgu8skAq2IfY1VlDy+ZQ+STXZ9YMdtTlBimzW2Ll6WX9oJVmteCCBNa1QzVs+baCqEWB2xw9BxWt1vRIyrM0qKeNzmIKsZRDSl7D4EdAQZDvPIiQOFJhixCkh9iwuwaYg7u18Z9NS3OYi7qMxBuknBap+XqoLShCWvZjBlsX8hNP2c0AAJF372VoJ1FJyxdhPQYUhmN24rHA1pqFPt47wboEITMw3zcO9GEkt4+NgGFeWxVF79ORCUgGx1oQgmusOukhGC1Jj4sm+SuLePlwNaIJF/WTHlQqLWXGK1IJM4RGfGTfN99U6vw8M2tYIZV032tkq1GpjjXHhU1CkZSzDaKUBPLvu8LCh/6zzKWQTlwZORSDRM95EH6v26a+5sQUZjPfgcLoi8qu40nfoJi0b9DkZDEaY+trIdOof7IAL+szQob2Hfr0iZNkm7fgaq65cNhPtSb6pE1tFfvmyaR1JJhm9YUW9mIiLM+STKi/Zwoulc0Z7 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Sm/bshCd9g8cr+jL+Ur/LwBauj31IbvNij81H1GV4X1pSM5O9yOtm3KMO20BjJzeCaVnreUbc+l9Hq+zs4IpeLXwk0b6XwGrP3vruyAHwpUj+7bkPKo9WTKynjZPlryi8rF4339t1itEsEN9B3q77iw9kwn84Kf0GJdWOJ2lQjlXdIgGWrtQkAa2B6T9eYr2j1mjmCggjqdUQQUrn88EtbgGqTfQLyuAyrqeqwxNTEA06N16B4gXtNFdj5eWVAaOT2X3C+71/G0PudsyUgL04ux9x9tU46EAxSWgoYn1WIITqODY04Vth40fM3ijQ41TGFXU1bAf7J1cljviVe6E5oQHUX4K9BLFtFd2hVAKyNaCMK6fz75rFXCfnBmMxO4G829OttYtiCTer7+R8ljf4+BcWS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sVhw79SfGatVU4jnEcBX9OaaT4UdOnhVtJlp+jRDDEeh0wH0CTqu+b9D7JqKsSDH2Z0kqx1AVIuE+UekNek2Np1PVrZjdPtJN7Ozck9XVmoyL/drSs5sfpQfJi5X4LiemRJEFRu5VO7rXF2U2VqTTDIcwWb8cWbOId7LqAPZRM8jDEWbYxh4nikx7MyNg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: sJvXq9AZbcscLgU/dpaqPmk1P9sXog6t4+B+bsosd2zPDz0/fHnMwQcZUDlHcbCxpsa4zhqMNUNbcZP3/rDIcgaYjQjwQjKZV2vheEz6YNuezWJ9+FPGcu9Ij2r3FAyIsCxiIWIyBk7Jb6a3SX5NNeEGzLu4rBBKbaIZqfbdIZrtpP0ndbW/sXzLsvXp9jbjwMUn/tvd1/+X8PtfDVLyW7FGCO1V2F/4mk0rx78841NKFdYlAOmmLoKApINDD43QHPIrldcD9mqbvajb8ZMphCtOuveb4dp2VRca3Ag+z+WVrjFsirCxaeGatPc1ktgX2X/kymObxMTN1fjNOam6JdYgjSuhJU5s0e8cdHipBzP3GSma/yaQXTWTHiankjztmhYRx9zyS+YEFg7UnNtc0ClbYgsVEHd6tFvK/PzTIMKR6cY3iJpiJWuQON+rJElhjs1WjL7frlz33MjTDMANBPKyISdZflg11GYKFIGYN85Vkp7rWB5wOi+pWj4r9RD4btNiEW4u9UONX6TudQWpY9zHUcuH1oeGol1y9xXixusWgf9ZshSMbSU8LHYmRsXF73SK0pXgBJwQCGFFT7PTnfcdep7dj4oqvp7w2bHkyjA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35cb7490-a50d-4333-26c7-08dcf3a2b767 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 20:38:56.9640 (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: k6RfI3Q4fRgYXsv8RSxSb5/u/rKfOdXBd6jEGTI/n8lLoPG1k85wTWEXzwaO5y+TRdvL4iOlrQRXcB4AV+qPWEPaf+UHneqDzrGY7h43fnY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5833 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-23_16,2024-10-23_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410230132 X-Proofpoint-ORIG-GUID: 9god8jj7Mp6doCKpcF5T5EvsObyK1tZs X-Proofpoint-GUID: 9god8jj7Mp6doCKpcF5T5EvsObyK1tZs X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0C3F3180011 X-Stat-Signature: unphqojocfazxrake63i3oieajs6cipc X-Rspam-User: X-HE-Tag: 1729715939-645933 X-HE-Meta: U2FsdGVkX1/qEsZgYDaTLF24NPL5Yfd5NXQai9x5AcR9KIT0DgfirZKA2QmMzokbq1phgoGqmLLO35BQ7Hy/MHR8IYYaLyFU4u3t+0rLdodoPyAqLQj81bt3m28VajuW0JEvvHe+w2mH5xHyTYH0utGzImhypkM5ff8fw0LBnEI2J7xRiWvNOFiwde1Agfk3LSwnLLabVvhyk1zdFXhNVLv4KKIC3MgRdvfIFGg4SWRKlGmr53O/qQ1mGZgKbZF3X6o8lt+liJt/E/Hi2beNIUsDe4ifrOkWDK7PabwLoiXeDkgzaU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O6Xg0YPwMHfhXaG/1FvZHhwLF71phID78+ZrGLK++Y1XSLeQdqSl5IoaIVf4sVYNAuXY0EaMeMxj+y8aDVtoY9zTiAv9Jq3xxD94uzzZ4EYT3kYd2JiQHkyGtbKYjlXlxzJOUi7XGJdUJ1vKcryiRdpIGkK1vt3HpTFBhvmLSqKmryhU5IZEi6S8NNgcB X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Incorrect invocation of VMA callbacks when the VMA is no longer in a consistent state is bug prone and risky to perform. With regards to the important vm_ops->close() callback We have gone to great lengths to try to track whether or not we ought to close VMAs. Rather than doing so and risking making a mistake somewhere, instead unconditionally close and reset vma->vm_ops to an empty dummy operations set with a NULL .close operator. We introduce a new function to do so - vma_close() - and simplify existing vms logic which tracked whether we needed to close or not. This simplifies the logic, avoids incorrect double-calling of the .close() callback and allows us to update error paths to simply call vma_close() unconditionally - making VMA closure idempotent. Reported-by: Jann Horn Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails") Cc: stable Reviewed-by: Vlastimil Babka Reviewed-by: Liam R. Howlett Reviewed-by: Jann Horn Signed-off-by: Lorenzo Stoakes --- mm/internal.h | 18 ++++++++++++++++++ mm/mmap.c | 5 ++--- mm/nommu.c | 3 +-- mm/vma.c | 14 +++++--------- mm/vma.h | 4 +--- 5 files changed, 27 insertions(+), 17 deletions(-) -- 2.47.0 diff --git a/mm/internal.h b/mm/internal.h index af032e76dfd4..0c4bf09bf788 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -135,6 +135,24 @@ static inline int mmap_file(struct file *file, struct vm_area_struct *vma) return err; } +/* + * If the VMA has a close hook then close it, and since closing it might leave + * it in an inconsistent state which makes the use of any hooks suspect, clear + * them down by installing dummy empty hooks. + */ +static inline void vma_close(struct vm_area_struct *vma) +{ + if (vma->vm_ops && vma->vm_ops->close) { + vma->vm_ops->close(vma); + + /* + * The mapping is in an inconsistent state, and no further hooks + * may be invoked upon it. + */ + vma->vm_ops = &vma_dummy_vm_ops; + } +} + #ifdef CONFIG_MMU /* Flags for folio_pte_batch(). */ diff --git a/mm/mmap.c b/mm/mmap.c index 10f4ccaf491b..d55c58e99a54 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1576,8 +1576,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return addr; close_and_free_vma: - if (file && !vms.closed_vm_ops && vma->vm_ops && vma->vm_ops->close) - vma->vm_ops->close(vma); + vma_close(vma); if (file || vma->vm_file) { unmap_and_free_vma: @@ -1937,7 +1936,7 @@ void exit_mmap(struct mm_struct *mm) do { if (vma->vm_flags & VM_ACCOUNT) nr_accounted += vma_pages(vma); - remove_vma(vma, /* unreachable = */ true, /* closed = */ false); + remove_vma(vma, /* unreachable = */ true); count++; cond_resched(); vma = vma_next(&vmi); diff --git a/mm/nommu.c b/mm/nommu.c index f9ccc02458ec..635d028d647b 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -589,8 +589,7 @@ static int delete_vma_from_mm(struct vm_area_struct *vma) */ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) { - if (vma->vm_ops && vma->vm_ops->close) - vma->vm_ops->close(vma); + vma_close(vma); if (vma->vm_file) fput(vma->vm_file); put_nommu_region(vma->vm_region); diff --git a/mm/vma.c b/mm/vma.c index 3c5a80876725..bb7cfa2dc282 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -323,11 +323,10 @@ static bool can_vma_merge_right(struct vma_merge_struct *vmg, /* * Close a vm structure and free it. */ -void remove_vma(struct vm_area_struct *vma, bool unreachable, bool closed) +void remove_vma(struct vm_area_struct *vma, bool unreachable) { might_sleep(); - if (!closed && vma->vm_ops && vma->vm_ops->close) - vma->vm_ops->close(vma); + vma_close(vma); if (vma->vm_file) fput(vma->vm_file); mpol_put(vma_policy(vma)); @@ -1115,9 +1114,7 @@ void vms_clean_up_area(struct vma_munmap_struct *vms, vms_clear_ptes(vms, mas_detach, true); mas_set(mas_detach, 0); mas_for_each(mas_detach, vma, ULONG_MAX) - if (vma->vm_ops && vma->vm_ops->close) - vma->vm_ops->close(vma); - vms->closed_vm_ops = true; + vma_close(vma); } /* @@ -1160,7 +1157,7 @@ void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, /* Remove and clean up vmas */ mas_set(mas_detach, 0); mas_for_each(mas_detach, vma, ULONG_MAX) - remove_vma(vma, /* = */ false, vms->closed_vm_ops); + remove_vma(vma, /* unreachable = */ false); vm_unacct_memory(vms->nr_accounted); validate_mm(mm); @@ -1684,8 +1681,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, return new_vma; out_vma_link: - if (new_vma->vm_ops && new_vma->vm_ops->close) - new_vma->vm_ops->close(new_vma); + vma_close(new_vma); if (new_vma->vm_file) fput(new_vma->vm_file); diff --git a/mm/vma.h b/mm/vma.h index 55457cb68200..75558b5e9c8c 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -42,7 +42,6 @@ struct vma_munmap_struct { int vma_count; /* Number of vmas that will be removed */ bool unlock; /* Unlock after the munmap */ bool clear_ptes; /* If there are outstanding PTE to be cleared */ - bool closed_vm_ops; /* call_mmap() was encountered, so vmas may be closed */ /* 1 byte hole */ unsigned long nr_pages; /* Number of pages being removed */ unsigned long locked_vm; /* Number of locked pages */ @@ -198,7 +197,6 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, vms->unmap_start = FIRST_USER_ADDRESS; vms->unmap_end = USER_PGTABLES_CEILING; vms->clear_ptes = false; - vms->closed_vm_ops = false; } #endif @@ -269,7 +267,7 @@ int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, unsigned long start, size_t len, struct list_head *uf, bool unlock); -void remove_vma(struct vm_area_struct *vma, bool unreachable, bool closed); +void remove_vma(struct vm_area_struct *vma, bool unreachable); void unmap_region(struct ma_state *mas, struct vm_area_struct *vma, struct vm_area_struct *prev, struct vm_area_struct *next);