From patchwork Fri Aug 30 04:00:59 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: 13784292 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 18A0ECA0EE1 for ; Fri, 30 Aug 2024 05:30:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 770AB6B00AF; Fri, 30 Aug 2024 01:30:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 720266B00BC; Fri, 30 Aug 2024 01:30:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54C636B00BD; Fri, 30 Aug 2024 01:30:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2F5456B00AF for ; Fri, 30 Aug 2024 01:30:47 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8E566141471 for ; Fri, 30 Aug 2024 05:30:46 +0000 (UTC) X-FDA: 82507787292.18.09959CA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 46476C0017 for ; Fri, 30 Aug 2024 05:30:43 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OtOETeOC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YyrqeELN; 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; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724995798; a=rsa-sha256; cv=pass; b=rVKabgxBk9vN4jSaCkYKyB81VsA8MB9n/wyK9AEEN2Am5lH85MqB1pZFmX2rmawoOobWHL fV/3pvoryjar6yScUY+UzcGOn/TzqdquGCWiVJJVxzsUhGSyWeOOPucXPO0WNDphGwd6Pp opxhsC29l/NP49q3fpGnWm37jOx/OtI= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OtOETeOC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YyrqeELN; 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; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724995798; 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=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b=FBTCQSKv31PpUNmzxvx5Hkgsrd6CGI2dmWqCUWG6ATXAfwIrif6XAwKh0IYHtlpPk2mdvu 6k9IhHwnT6xNHpVhZRrRfRRr2AvxZJ2TqdJelSuc/pS6H5hY91tjjJM4OWsJR3fcK6p1LK wRb0TpOFG9wqZ8TUhmCrXIiFYutoKJQ= Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U2uL9I019681; Fri, 30 Aug 2024 04:01: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=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b= OtOETeOCENI+UV/YzUmpykj0qWupQrlXh75cyrweWNFvEVwOHMXvkHh4t9avgYT+ 3GiHvJrsRrXDRFU2u/pu+imN4tDZtVlgUiiYls1qDbKIEhsgBfcP9wjsWGgM8nMG LWrXUfT8FgVzi4GY3FQvrEFThHb9TpXRmNCA0Fwo4F0SfICaCLB1g21FJ8ueyVC+ g8gQFp65RwrqS8IxjtEvY1gEzwdD5q+2YXTXNQvSjplaSQS0H/lXdHYsN/TQjls3 xy668czWckjo1IMijqCiaBytqhMrplDmgiSRiWtC2ChPOhiTXq7IxYhBbiPh9COV H0LUWxrWm51ABsVoZq3Ndg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 419pugwrfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:53 +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 47U0LvZn036604; Fri, 30 Aug 2024 04:01:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2tga-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FRCquFTjlwz6mjQLAKWK7sl/+oHtnYhtuEpxdupu4owqgPEbb9OX9chAglANmafBlySVRQWbw522KLKZiW3U9vhGsopA7veDl4gOyWcK1ODWiw2obVsMf3HNZRI4zIW6IfwTBRIU833vlERMiL/TvLfELkHEKixHefP3ixnPbub5q6CCEHI30CspmT1Q8KHGLZqPFULbINnv3l6WXqwfKgqLJ96QHjWAj6hHVy7YjcgihjWcw+inI+eNI6OJjvobw4zhdTxTntWUMmdBKR+DY051LwVMA9Vk5onKA2RMEMeqN8BHIBF8GaCHSXPEBRKgPACEjZ0qureAo+JDpAyDtQ== 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=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b=VoFHlwM0cLjlraVK9ytP43qpM9GVB/BGVnxJYBJ70KNH1wPIMW22fUBLn1NZJ10c36u5VDzOVBjDnPyHaq+wVuvUVWeeuWnIQmrt7pbkAxvKgv4FE0A23mk2SOo+TJU0fQG6D0OubvG6CRDZybFJZVTkAHgLlikqSpG9Dt6kZX/5lXHDSDRP6Vhm7plzmefglON71euLgrOS/PnOdyswo2hCFPSRZl+Em9ScEZsIr6TsWd9JK0zM1+avaOH+HkXMHBujg5VtkIMQN9XJk9iKA4ZxUYc/fYlljOVCLhu+LMbC9YUE6mDvu78Abf7z896EBgz2aFpmtJL1uBFq92oxNg== 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=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b=YyrqeELNPY8dyNk0wuBbC5sIBpD1A9jIP5GEYXajt3ajp7hAu5SUdfmC1L6Mnn5xJ5UjiImf+kZkTaJPO2SrtkEvz5MXJcGNY2pOF2YyljBISTUjHQb6LNFkQwQRt3ob8k82xPQ33HHbuuVj/sWUvD1haxCyFbQcimWsqEraBUA= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA3PR10MB8115.namprd10.prod.outlook.com (2603:10b6:208:506::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.19; Fri, 30 Aug 2024 04:01:49 +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.7918.019; Fri, 30 Aug 2024 04:01:49 +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" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 19/21] mm: Move may_expand_vm() check in mmap_region() Date: Fri, 30 Aug 2024 00:00:59 -0400 Message-ID: <20240830040101.822209-20-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0056.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::25) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA3PR10MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: c769d78b-4085-4f64-97b8-08dcc8a8792f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: 7/tuBpwMzUkHAHnUPRBxKTUV1azZ9uwST74CA6ssFQ2J26MGpJngyKQVLlyWMz8a/cFL0Yh10neH/fA5EbdJeIrh/Z3N2JAsyrO/pgkfHIMBYDmtDl1SDlf6HfmHnpAe008gTizHurHEnoDxJguoZhFILAXupcJO64rapXJ0mwliQDnVyH1pXzIloSY4skVuGZOvFdFqM9BoK/fZWYU8JnWPRDAOedMRm/X8koyw7IckogOi/bXJRd1yRwxluwFdOxFyisAtDprsL6iQ0HasrLisj0eQ2fNgbsBfC+m3103/dJ1Q08Ow6hUgiRw06bUZlyVo1wz+cd3Vzl9GiRwOo+OioGyCqK+gIKUwuQyE2bBZ1tqaUVhAvAcjwIFZtz4GpO8ffImnOn8Jg+7PGEhIWxZossVIZJLeNTzNUhTmVVsD+7TWOENpAIWAVXdj6qHNH0xBp/daOc0q3cOjmRm6g0TUPjqPwjF0zLxTtsmip9DLoRr9uWE8MgNLjNAwFK9ppxBRbkrHBBXJhWqOHFxElQH0lLlD92BROMZ5AgTCpZ3aUPmj0RENcwULQCSWlnhIeni5G5xFGUAoezG1ezDF+pGgPkRkc+i2xX8MTBz+IUuOQvV5YCm+y9nAJm1Qz2NHQnyoijr4fM1R66gFGSKhSwXRRD5RWgU9ChfVlYlVDaSrEkvOqw/ZcZTyN8JrIdEg+5euQiS/b99wP0jdGo3/fbcsvwqRtnLlFtNoQ2Pdc9qvnpK7Be3xiShrKyzZPRkUYhfbmD/z4OH1A162PDUaMW6VEzeN4cPH+p18XRQZYJGWyid9GWO+Klt+DvZtSK7UskoZhIAhrzCJ5C1mNmcUF2nPChEqIbFrcGKKPfKD6vjZiFokYpAofK5irGs+S9sXCX4V6dM0NL4xIloZqxg3xeV/ASps6UPbFy+muAk4+w5CtBT25v6mX9bwmzGsAa2iNjCBV6DY63EVuff5xdDcEnS5h+VI9fdyYEIY8zhNvZcVcBKdKF2Tkd2ALXEckZahc1U9tiHyeTN3E/2XPnSersXgdkorwpBvi5ISZwjRFdW4i9MlFcbx8PgG0SQXgQIDqvcKWynJvMajmE5tsFQjbY/0XTOG5I1l3l6rsspPLXoWN0YPP7tmwWB6rZ7MKCwyxtQ+EvEd+h3yfD1GbzGjwTFfizExZE0dcx1piO5FMeDgcPrjnEgg39ppbKJ5uOD6jDl/dc/0wJfRLhI+rGvudp5nc/UYDH4kW1XBNsZVQF4SP35FUZq8Fx5/T1F/VhnNGs6VJnmUqe6HB/gjsIUEZaqF8Cbqmpou66D7FedEwg1bx7z8vKZF9ukp/RDMcow9HKKukIas6Q3ssEAtjZK/SA== 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)(376014)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gXTl6CGO43aldaAfvqb6TPuGzUrWfnmt0ZCgxsUUAfO/lyXJLbdRYrZ+K1QhpS4IVH0vfsytt/1YODiEGoVdfCi2UtQbTxAC+09REfjuG7veLRq16XG6wBlyMxxf3Nnp3IQi8ZvZVRtZFMMnjFJt1wXgESf8fY1S7VZ/5CVQwBcpdETM5rrtrcLgzRkI1kfPq7ZIDaBRZoHlZmjZQOHFo5swfyCwwUNhXK0Yj0VoEO80JeOdANe5J7PGasJNl33Oj3OPTnlBby4Y6BOnIrSHifD4t1Y9OFqW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wV09z4uoUxmpAXg+ATF9YVWWbmn+kCgGqL2ZlGH45EKSXxXOVrpMkmprIQ6aHHu5M9PmoFYK9b1iyd0zIXlE4bdMKYrlKBRuWNPT3+2uquh3dn0KME44s9uINaVY+OfSP+sqI2fdkpbOWQ36oO7MuAg9Mk5E10HN6kvENeYAyzY4yLIFbhepR3nOSCPZaEPUyXgNviw/P4KKruXt8PwgLCaMEELas/rfsJB/wcgmRj7nmo4rog53vqw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eUq8eiU7bPCcZegGH5tYw/C7x7a6F4tniPSmIkrRbJGeJV2xbmgTcMINSmgTqZ61iT5iVOQc1zZk9XmZuGeFEKPAveKEQxSLddF7VazQTLEn7vLT0nn1p5kaCnLdy4T5d9miTc6643kmsTNbtf1vklOuILCD3GdHhwLyogTuyRFd24IeRLeQwU6SKI3JR80PWGMQa+2NEbamncTURYnDWtGdgAUF6H6QMIazah3g78ACB+yAehJby5pQ01Tgiy27EJxrniRSGBjPD++dX9MG5uIv0Ibvy00qqB6qDo/JIEK1V8hTQC2IoE7z2P3WuHYZR0qxtUe0delJLy6K7L5W12v118pfGW9UD0ekXjX3iaKHQZnxndZqbP7Z5hGRqMYIeHwhsHkqI/a7/q7I+W6sy3PowqssduvxJH50XON0RIsGa6Me2/5YNrfletOnsVpAOXeoT3/o8xBxObBYVOccsEOC5nzTQ1RG2w41iTL/fh6UHTxd810WY4q3Zs4NxDefrPSCzFHYU1vZ3lzQ728/StTyU/0mbQqiA0NB158yyLU8abk6CwaNyIXY5O6S66vgN/QSkmTHocJggBJCGH13QhMbao4jpuMLto4MMtsFlQU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c769d78b-4085-4f64-97b8-08dcc8a8792f X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:49.4056 (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: rWPs0jN3bfJmaRT/sxcCUk1LJ38oSQH6Pe/I9Suw2gelOBg0hFLfGsXzSKoPEocfn2txSxoS5pmcTYcxpM5W4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8115 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-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=976 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: -zRDwOCZO6MDemVYfKCuJLUwuhvqzR5y X-Proofpoint-ORIG-GUID: -zRDwOCZO6MDemVYfKCuJLUwuhvqzR5y X-Stat-Signature: htxcax5eidkmzbqyfuyqhhp31h9ii4et X-Rspamd-Queue-Id: 46476C0017 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724995843-827684 X-HE-Meta: U2FsdGVkX1+VH2YO3f9QnzNZXCjhWRmpmRNSLW3tDtDEE84bNFsdmld880QutnNe1x3Poy3HNYYCuSx61GlzmELJL3t5k/RblvFmwpd12zcM+k50p92yS5l4BnPVtVyywqpMy2mQr+k8guv+TKOEc431rE6GCQvQnNLGDqpyUNLVlJnQ9qKBewE3Fk6U+spiljVyA9Ptg2i4iDxz1dwJOc5cPOAFiPpDJbYSQTaI9hln2Cay+CqJllFlBNo18zugO//RN6jtacTpzRn0kKV4puKmdYxN5qxvQx3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JQrAWBg17DpBuNfMTPtiS4iSPbSAYuKNzZRlTcqFGQZ6pm2WDVfqrmeopoFSIkpOM9Zrm3PTqwU0CZ7UnwDnE1H58XxurfHnquN89N9GoLpMY6c9lZNtjuj5T3UZyDaZ9WBmP7/aWkdXVs2IG1kfNXUzgMVg+e0+WsDGZic0Mm50hCur24E7GWTNRXHXeu9nURPd1Jz88sy7Q1eABPpZfgp3pySkGCcEyQbrYIt4dFdw= 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 6485f2300692..fc726c4e98be 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); @@ -1410,6 +1399,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 713b2196d351..3350fe2088bc 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -1640,27 +1640,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 eea1b5e9c15a..6900e95bcaac 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -319,9 +319,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) {