From patchwork Thu Aug 22 19:25:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13774126 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 44E5DC52D7C for ; Thu, 22 Aug 2024 19:27:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 928118005B; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D5648005A; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68DD48005B; Thu, 22 Aug 2024 15:27: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 2B5708005A for ; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D1DCF1C5759 for ; Thu, 22 Aug 2024 19:27:05 +0000 (UTC) X-FDA: 82480864410.07.6F03D4C Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 8F831C000B for ; Thu, 22 Aug 2024 19:27:02 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ZYpnxnYt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=J7xyziGl; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf28.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354756; a=rsa-sha256; cv=pass; b=6FEIK6HcsP0nT6df/ZzaguGV9vZ6Lo1Yzd5ycrNlpQbt9BInZHC0/y8QVVJOmHc9F3RiZ5 lpiAZJ30WMQz72KCkBkXMFm+buis6SmpT8G7VEWmYHe2J6Z1c8cwNrzyS5V17Tj2UEtw97 B662ytxd3OnCqjw/Y3k7v/C7lmNO5kk= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ZYpnxnYt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=J7xyziGl; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf28.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724354756; 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=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b=aJx99tOpajVuVubQs7yPO3vhRBdY0nRGWkoKOhppeSDR75w/fnYRKVQ83LFKnYpzXN7FjG inBGq+aakfrO0wlOHT9Z5O261O8YK8behKN3IQiwIyL33TmcuSwpmbLhXz0tgjhe2BINl0 htBYVbKBCtKtCzfgoNcEU6tEdizZmvw= 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 47MIMr1d026289; Thu, 22 Aug 2024 19:26: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-11-20; bh=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b= ZYpnxnYtusDbMOdnGVMe7Snaz2B9kKhh5L19BADADm7oLcJ70U+ec4dBesFWoYQs l+yP8qqC2mAlSufmkTeZ76fuLhahqFfxVDTEXQBdGnuZ5B64B7HcvNjAGCxVBKnj A3KuNiD/BNRHC38ix001YQb+DLEQJHwUOUDKHG5ZDKbOEjycFOyU5GCOaVzi1k41 azw55clO/N0plQCAmGRc1jrUdEo5xmG+sttZmBNN1Gk+3NzWLZjrzWyEgA3jG2rd RctsVUzLo1xeGKaY0cYbAsk97EUmC5wrX0K/9aJfRfXG3b6mOGCX3T8R+X4jjhsg CAtVkupmsPFCyK7xPUpUTQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m2djxyf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:53 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJJOnV005646; Thu, 22 Aug 2024 19:26:52 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08bq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GtS2lWwHosv5dqqVd4A2hDdHrPolpnfql7vF5Cd/IpDn0u/N3wNiWYi6AaefurhscMv7dm5M75zftcWP1vwJvFst0peuvXzuT+eVPFyqwKxp3tH8EZAV6yjQQiW/0vH8vpWLCEKJ+tIUpVSL83Kai05d3pa9otXPzhSR1rWVmTixZBidulxvbL21bXz6zJq9LJgqyX1Ve8WZm52ziNf22SKyZThVkYnYTe8znRzQtozQgWM1CSFjA+GnJQPKatf4aZt8MwrxNdHkVIjcjNPMkNWhuGq4fS0nK1kIDU8QBYsajOmpDx5r25FMIXy6KYyceqhRcdqGhTyaHnAhs0plLg== 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=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b=o6PdJhZH5k6il1QlEP4QdhXbxz1V9noi893PRs2PkhsdNzSUPZSNajO3yyvy7SWtD9My6soVQV+4QVMnwFAx3+kmGydZMIZs5S3T08toR5G61D6ZHRydywioGgshs6ZGREsP2JBS0vhr26TJX0xDVZG2c7CieKWrgBBOY8nE/bpwdQYlRwKxhBq2G67Rfe4sMMkoK959jyVIqlVUDwhcFQGqIcU5UIVV/a17TN+7IahuS+BuNAmnkCrvWE7mRU7JJr1hqhNK+/mqdfbGuINYwKbBm67ocJg79EF2ItvbHcpE/z9W+vkOyXDXUMvw6YmG1JiLbmk1osDRCHeASFBAJg== 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=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b=J7xyziGlt9qpmWf9AAJWX6I1CT94S09siIIhnjLM8P0vGYmr66D2BBd9PSXTa5Iuc46/wZStM8zdYXhS5XiUANqFgYZXoFQJh06LO1nw3TK6P64UJxKBMxekmIbTqCiH5D/D+kRs7xbRSLNTUKPBqo1BnRU1JQrLnG3q7snideU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:46 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 19:26:46 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" Subject: [PATCH v7 19/21] mm: Move may_expand_vm() check in mmap_region() Date: Thu, 22 Aug 2024 15:25:41 -0400 Message-ID: <20240822192543.3359552-20-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0007.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d1::14) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 46e1499d-837b-4ddd-b9b2-08dcc2e05c33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: OBXVGMw08qUaPiIxfCQ+DNAlV3xXbKEdLnQWzANLbcag9U4DqieD/lfKRm1BirmPAyHMQBTkRQOi+PqlGl28dJd0MfixuuW/SMwTHLwR4TGZO+GSzikx230Yj+7CF/9uh3zUDjPbgHgFcQbNpZCIasLSXINS7bzPNRps4/q1ZTAkHad8E2mzIbskJXydikg3aGoJFlXpARh4efBAapg6iXpg+E80SBXTVxyYkH9XTQCGr7Co1Vom6+msX3Gpto80+wjgEeIH9pJmYagTE1ihaoHyq10taVcvg6fC0AxIIhpoY6B+1Q4EJCu7xk9yYzSLCy/fG1omaDx8G9XqB7EF2+9mAdjSinr3GJyKiCFfQ6Y+bf+RS3ansz4F3Ty74MxsdD99VOluAOHgWklGPdDrP8bdDaV+7G5x3HiYbsYdP6pP+6V0S4gbNzJ/nrCaIvlxtcc/QprUq4Ri74rlMOtDBDyRkSq7MXcsb1CD6b8Lk25jWvlt40MOVigxhYp8lXBT7FeOUFPLuX2or8tQCeqkQcg4qEinyZkmp+nmSltBc4LpSI08fS/GQ090GSMSqLt5iVu/tWOt4ggDSbWq4LE1jpMJXXQs/dSD3clpy4G+1dY9F/vIbrHEKqTBXRXV3xHcNZQZTjNz4nm1oXjfn0xPfJQvyCWd6VBGN8dVwfdQ8vkPu4rkpf+e6k1RKSHqszigk2MuurjOgffqLZe8IDyQeIjH8GjWypftKRYPOR3UaggDlZR5dRs/tFr/jhisvG2Ie0WZcSrVJz5dzZwtbrglUkmZACVXV5KhkynC7BlnQKfohdcKjZMA292t9uCUhlR6Ma1tlqdKKAN/0PoIHTrRuMp4MeDsInACKjOkggZ7JdVbLJMmdBNWUYUZ9cexXNjF48elqwpu3YdZnoSPkcilT0GLOVH8vzh/kgXIn63hn4+5mn1SHYZ7esUvX2Emozb0m3xaT1kGShPlx+CavqM+51z/Z2wYY2fpPDtcFWNZ08LonkVmQdAJrjyc/a81bXP9ntHVTbXp3YoDf77X92tFMGZON/k/nDqDXlb4mCYz6I4fjYaeapsnHUC9GTLgfpY8IEjVc11+cc3tZBllG5mayxQD5E3bk/NZaYyAAy3Qywm8N48dugSkMtkVUjw9D+1Wz2gd/M9Y++JE6iZUhU78AR5TqE6ZbW4HWS16DQPE/IxRCRU6/p9N9FSbpwVdknVhdWvNKAFzovQF7IHuGHoEyNmN1kgDEYwnnZa5K42niRkYfgf5atV09IIchK/ZMSzUqCnKJQu2gJaIqTvXoy/W3Nk1wfEGtw/cxuZb8kUMnIIp0/D/3Woqx9j4B2mktc1AFwfJ6Kw7dA+9ga/ViXW9dw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3eizxDnOYYoppcNG/vBrFopCEGNd/L+jm8c4squqFVC/2GkXfe+YhqNHPHOkWcWMIYTXIit7WM4Uw6kwd2ayG9bUr2ZmcDKZNdCaYRFduXAtXxmmc2Xb81+vF64TuU3S6QdnwlpTTnIyIAmrhKLG9S8f5JZp1DM+MZLxHawFKtvm9APS3i86oY/LFYcKgM8HKtRPqKaUqiVXhN2R7qaByTE5e6MC/Wy7qE583rLNdD9QwH2ULRqzGppN+L85N1Wh6+HyDSEyRhGgAgZ4+wtrdA3JtB8BVYOrfuYk47hwHu7iWFnpG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s4Q+vlnWceGXrbCpn+rOZt7u0URejFU6Rs/j4fv5CgCJTq5XMW7OMJyXc24rG/Z46y541H3hmf+AleXzBD7r99obIG5EkhE2ep5mcPFZTameJzfEHx6RctgwJFhGI9+cdQAC4zN+Y9cxY0XTaTXwkzWwEzPWyN2KKsoYVZNPCDo05SpHvneb2whSF/8SdBFAn8OAHHxb6Q/VaWAl8nFQLYD4/aUtxpIk4hGYW1mDkJTDfLNw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rhYRglO58dxL1klGcV8VQ1YywnOXgjrCt9Ar0Q92QkAafePBgxIySWrWy0C0YkHCQ6dS8C645NARlsLZP3cgKi2Ki2vW0ENVxERmP9Iz0hh4KeKdKUhmJnUB8iOGZHXU4+SbXXD3axAVfvw7/8mvWfNH3482S517g1VcR7aQJN+IYSJ9KbTqvgXo6EpOwndP5zJtSNk6E1xxv7cEMFoRHMLBQ2yH+UMM/znt8F8PQ+5gW2k7t+lSQSOV32iDiLRQ2C3Kz8rWF22FpTTqA9A93hx4G2qm+/vySV3SESP4zw/c5YtBObQ0BBPZXFV9oy/urtS/I0EN9P9a2MCydlni5JKFEPa1JPdBDCFxxwaAZUZZxgAoyRDC5RN9XodcVzjRF82dDSun91PyhpNndkbntF1MP7p9r2VtNNZPal64oY1w3AJ6GYWXHoNAy1p9/rO11HvJoJSRSQlKbBhRhIyMexZ/7pBWV2F+20PYWej/yimwAHmLarXioQ8RKYIwsAHDYBnja+3gSQADITB8fq6RdkmJtOZm1mQtvMzb1Zedt6xCBHxTQT+4/H0pY75LufkSTuI3WIgz1MZKlbwjzp6AMtn2mU/ETC3/ncMLURxsq/E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46e1499d-837b-4ddd-b9b2-08dcc2e05c33 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:45.6245 (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: uw+L5/rREj/iQcg90wvYm4ZOEEY62aUYOtYjitVZQsgfEMM2A3Aho3UsudAVkfn5PH6XIIxfJq4U6FpNEgFK9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=878 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-GUID: rE9GjZmo35itfnvAhGFVqcBnA_aCbUwk X-Proofpoint-ORIG-GUID: rE9GjZmo35itfnvAhGFVqcBnA_aCbUwk X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8F831C000B X-Stat-Signature: eonpudif3b41nm9c7hw5waypwnndc5i3 X-Rspam-User: X-HE-Tag: 1724354822-239708 X-HE-Meta: U2FsdGVkX1/J/Z9SgRQabIEEQncvV6PYDZOicCd7Agaq8Z7DCIuWX49zNVoJgF907BUeN5TFO/dv9DJYZQ+MdbWf40faTtvlfnVqUMc9w1AzhhboMVhDAMy/UIXGX5quiDf0EzHGKJgaipzU4mcjMEHwGOUy+Se/VNCOJwUz5ZUJMacm0SNMJOjfbQXquPY6ihwNfLECmaFIXjgTs4AH0DH6yDTRVZioYIs860w+GDi+qIYg3bRRPH0P5MPogPyc0HgBFYpbfc0fek3r6JAX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64S1I8swj1EA/eM3Saz+mrRFWE4oHr3fx2g1tFl6TebJjW1bMmnAgw0CgHa6pPADksI/mVsJKISXfcZ2j/ArJpSahx9dlSODPzlb4GX+H3dSynWLFFrOo7JywjP50ezUT7H8evuG1XPDgNXpiFiFi/xwEC+r69/KqUOSj/d5ZdDOAW0iaXhgPwDTIvYZh4sC/sVf+3LOzU= 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: From: "Liam R. Howlett" The may_expand_vm() check requires the count of the pages within the munmap range. Since this is needed for accounting and obtained later, the reodering of ma_expand_vm() to later in the call stack, after the vma munmap struct (vms) is initialised and the gather stage is potentially run, will allow for a single loop over the vmas. The gather sage does not commit any work and so everything can be undone in the case of a failure. The MAP_FIXED page count is available after the vms_gather_munmap_vmas() call, so use it instead of looping over the vmas twice. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 15 ++++----------- mm/vma.c | 21 --------------------- mm/vma.h | 3 --- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 51ab0bdb856c..5937607f6949 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1376,17 +1376,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, pgoff_t vm_pgoff; int error = -ENOMEM; VMA_ITERATOR(vmi, mm, addr); - unsigned long nr_pages, nr_accounted; - - nr_pages = count_vma_pages_range(mm, addr, end, &nr_accounted); - - /* - * Check against address space limit. - * MAP_FIXED may remove pages of mappings that intersects with requested - * mapping. Account for the pages it would unmap. - */ - if (!may_expand_vm(mm, vm_flags, pglen - nr_pages)) - return -ENOMEM; /* Find the first overlapping VMA */ vma = vma_find(&vmi, end); @@ -1409,6 +1398,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vma_iter_next_range(&vmi); } + /* Check against address space limit. */ + if (!may_expand_vm(mm, vm_flags, pglen - vms.nr_pages)) + goto abort_munmap; + /* * Private writable mapping: check memory availability */ diff --git a/mm/vma.c b/mm/vma.c index 91b027eb9a38..61d51677eaaf 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -1645,27 +1645,6 @@ bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot) return vma_fs_can_writeback(vma); } -unsigned long count_vma_pages_range(struct mm_struct *mm, - unsigned long addr, unsigned long end, - unsigned long *nr_accounted) -{ - VMA_ITERATOR(vmi, mm, addr); - struct vm_area_struct *vma; - unsigned long nr_pages = 0; - - *nr_accounted = 0; - for_each_vma_range(vmi, vma, end) { - unsigned long vm_start = max(addr, vma->vm_start); - unsigned long vm_end = min(end, vma->vm_end); - - nr_pages += PHYS_PFN(vm_end - vm_start); - if (vma->vm_flags & VM_ACCOUNT) - *nr_accounted += PHYS_PFN(vm_end - vm_start); - } - - return nr_pages; -} - static DEFINE_MUTEX(mm_all_locks_mutex); static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma) diff --git a/mm/vma.h b/mm/vma.h index 8ca32d7cb846..7047fedce459 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -315,9 +315,6 @@ bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot); int mm_take_all_locks(struct mm_struct *mm); void mm_drop_all_locks(struct mm_struct *mm); -unsigned long count_vma_pages_range(struct mm_struct *mm, - unsigned long addr, unsigned long end, - unsigned long *nr_accounted); static inline bool vma_wants_manual_pte_write_upgrade(struct vm_area_struct *vma) {