From patchwork Mon Jul 22 11:50:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13738733 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 158E4C3DA64 for ; Mon, 22 Jul 2024 11:51:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C0336B0088; Mon, 22 Jul 2024 07:51:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 748196B0089; Mon, 22 Jul 2024 07:51:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54C356B008A; Mon, 22 Jul 2024 07:51:00 -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 2CDF46B0088 for ; Mon, 22 Jul 2024 07:51:00 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EA612A54EA for ; Mon, 22 Jul 2024 11:50:59 +0000 (UTC) X-FDA: 82367222238.08.ACE89CF Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf18.hostedemail.com (Postfix) with ESMTP id A3F571C0023 for ; Mon, 22 Jul 2024 11:50:56 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ILcg3fwP; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=E4GGjxGc; spf=pass (imf18.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@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=1721649035; 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=bojfiDE+vLogRuiloJdontKGidCCrH9BI//DCTgUuqQ=; b=uv2QxrHqZECPJnZ8LKSdCFHLGhnJ+LofzCjY6mfQLSbhsTIsLEU8sMoZSVHcHgNaD91gdM ehsmb0rv/kXNJKtYr7vqiIveju55CJ9RPdGtiWqQDvOZcpGEh2C4NTWYmqdS6bas6nuial LMiV03Scc2ABqBnhGhi4Rw+gs5duD0s= ARC-Authentication-Results: i=2; imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ILcg3fwP; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=E4GGjxGc; spf=pass (imf18.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@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=1721649035; a=rsa-sha256; cv=pass; b=RHNmpNUBwl65hBH1UWZITebqJPLmoeGznNQfoVy0b4UCa9AqN+6ZXZD39bwKq6arzjKS6N xO15SdELnkmg8Q2i07pI50gJyRyDAgO4BT3Cv5RiaLzXxO7ybXXYGaLn1Zgxxh6RQFmv+k BIE9dI80GItiaoI++x0k+SDmxg9BuVY= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46M7d1o9021211; Mon, 22 Jul 2024 11:50:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=bojfiDE+vLogRuiloJdontKGidCCrH9BI//DCTgUuqQ=; b= ILcg3fwP2Eb0Gl034hAQezg+X1qFgUSZr9FONyM00vCBJExvTMgtw8GVayM7D96/ wzTJxN0yiXbobjD0aItij07YjEgRPFaudrmSbwPdMteQNJdc+9K0/ZLQbY0N/0F4 DlDWKPgbJheOMAtd//m/7nRABSm1gfBtB3TaHa5AQjBAzkqgc1uQ+y8pdd8JNbGx +0uMCiOEiICC4nm7JEOqLDlPwSonkNO9wzCZ8H6XTuP3+VryzBsJbDb+ahugUHHQ OW2vVWymdF5DwZLyaTwjyT8LS4j9D8oYtJWBwhNc59bDk9s1ZLProaKiEWWu+PCK NsnxYZLYvcNDPAWF98c86Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40hgkt1dk3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Jul 2024 11:50:49 +0000 (GMT) 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 46MARVfm019196; Mon, 22 Jul 2024 11:50:48 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40h26judj8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Jul 2024 11:50:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tAm1FV7NFXbZt6MSPNYQYDTsAXSuR3Ekk1hvkmFMfqm3YNj/S/0L5jqWbGyVVrUQoQczBlrbEaSU6xsQrBpLeFKbWJVjudNk5uyK38HAFgihmY1UACQns44+fK9CAiI3Ec5srQOjA63zxnRSBzZ3m8Y3644H+FytY//KoCX1062yCqwuTmMv0AHGSlPE9KYZ/vSUK5B55zHyMDv8bAjnPPTqmTl0tczDiW/XhNav/QCANEUjyGAbLfK5Qa7UrAm5/OfrCcs696wj8w/Ol7cGmiuWQRE1SVR1Uj5ojVZjwmieRU08C4xEwQE3hpF9w3SdTMtmhcbKciHxD/fiz9lIHA== 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=bojfiDE+vLogRuiloJdontKGidCCrH9BI//DCTgUuqQ=; b=SxB+E8UBSsPhicKmGwpucS5bL8eLyByDe9BrKXAKti4CAKq44G1Fv4/Ntr+cVVDLeQAOLJXpc1/eEXynG2OQ47mWamX6udyvfEmW9pqf0hCAQbyiq8esqiQkmviQcIL5Ua0RV0z4NdAq4g4c+PPL3xyaHGZzliBcb2A224XU5vCf1PP0afZNsunEWWNGuZcsMxYOcrp1w5iSMC/x8itbgQgQkvevMWFme2ppXiin9b3J2KgYMPg7yisaZP8rSiDlQ+1t/4UFwsdaqyVaG+vqdau+PMogE44ToOXGfY/bt1dEc6xZyx9MCDe7JSPtLr6K505rwGxBiH9SKyWMyIL3mg== 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=bojfiDE+vLogRuiloJdontKGidCCrH9BI//DCTgUuqQ=; b=E4GGjxGcIs5vp2kAeHEMNIXl1OgMZPXy+jgCJut1AtuGuLk92LiK/VfbEdw4g0fsjoM7JEG7vyGoDW9iO+GzJPuFy+ZAsP2W2eb+VAke46YPDRRq0BJRQ0I/6VbQE4JZEo+nfj2VNtx8RrXt8gTdVq2AVGQKjGUOpEsRNv9it7M= Received: from SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) by IA1PR10MB7358.namprd10.prod.outlook.com (2603:10b6:208:3fa::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.17; Mon, 22 Jul 2024 11:50:44 +0000 Received: from SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e]) by SJ0PR10MB5613.namprd10.prod.outlook.com ([fe80::4239:cf6f:9caa:940e%6]) with mapi id 15.20.7784.016; Mon, 22 Jul 2024 11:50:44 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Liam R . Howlett" , Vlastimil Babka , Matthew Wilcox , Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Kees Cook , Suren Baghdasaryan , SeongJae Park , Shuah Khan , Brendan Higgins , David Gow , Rae Moar Subject: [PATCH v3 3/7] mm: move vma_shrink(), vma_expand() to internal header Date: Mon, 22 Jul 2024 12:50:21 +0100 Message-ID: <5909552e51936191428c007c4be8628b4d3faf5b.1721648367.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0289.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:196::6) To SJ0PR10MB5613.namprd10.prod.outlook.com (2603:10b6:a03:3d0::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR10MB5613:EE_|IA1PR10MB7358:EE_ X-MS-Office365-Filtering-Correlation-Id: a7c19032-f9ee-44b1-6c84-08dcaa4484e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: Wrdo0jAW3J0x1JyDqvAPsMapWjgwhibn6uHPPNHNBovMLZ0CCKeZ43vyKsGODvmaheg7XD64g60B3u8ANoV/eUPBGFY2RU7ly4Ozbftq/uK5uxBJr6xJMuTXHjQRX3sXX/76lmEz1iC8N2XnFEREQt42ny8n98kzmUPGTE90WZ7yGulnuEMrKpkplMnY035oC7RkTXs4iNP8mF0z73FuWgqGdgbfs0NZOAjKBxx1w/glZCU3RiLYSSuXMnPCz2EuQ8bg1WgAEAX4S8mYzOgYFfqScUoYhGj+Yt/uvRGk0hSqCPVDs/QlDZhJfagUpFepqSy4xYVQwbyl5vooQhXFxUF5Ayt/jXyzIrm/fHOonjIaQSCzLHc/RDDUVp0gKwBVcrGmdevmSHNqHBoL7J9yErWd9AsbwECH7FYi+60b2jMcHkCCkvkPZYenn3Vj9GGRVTnDMTgGUcIdsJX8fZJOg8yUe07JRRQdWZWApy2BCcsUC1+AhREAmUFUb1+jalAEvdDXIN65FP+swP+fuKLlHCiq/gVMcy6Zc1QqXLMAGsh1n9hjLqRSBSH/OuhnlHRzSIRGtMNIKBzUd9MF+wsykXwZjkmFxg0EtG5UM/wnuBIoknkhkE0mG3m6zA0OioxudJft6mvX+pUMvF01RhahX7ILSA2SJtH/AWnOHTjgZZJqEW+jIG4Au5YEAbH0zeeomrNUZZeW21vVNBF8oXEip/sMXZm4T5zuuY7SKRGfDwKvSK0gTTkMgpewRkUvCAQJgHulbwL+49aXnCBSXcJSIIGUa6RhVYOcjKNzF1kuIR7pJttRjnxXAOkKtG9mMttIfqmuyttBrW8qhZzb0rY0R+w339MTunFH/uAkLZVtubQ+J+5yNMO0vyBch/0KM7wcFj9l1TBVLagXsOfVXAwI+9y5APNTsejR2kTbIU6NryocZNKDx+ArJwCx5s4AnjUVMuOAI5F5KFuu59NsSo4Tb2zLuFuuurVEkJs5JS42vK7yvpSzr5f/uqVy/1+zmdASsbkdx9m0O6WwFWCbazhhxVB8azd+voHX2YQYKTVQ8payO6l63ly+06If8xJ3oMzUgP8rTMK1Z6VfmsQKI6DAk302uycTGltYYxLg22tY0wSLePnOQqUe5vi8HVB1rJQDgh2n0YVQnz6Ew0SqWPUqG/Kq55fZDfODMI8lXhC9jdRGIqBb7KdVBDu1PCnaF9QrdwfSdYhgvBZoFrY5b8Cl14j2nxnwajhqkpUkZejQzWk2qwcNWGwsxzA5yd9VJfxgtz9MDMjGn9foM8bIP5vWoH49k1DkJqr0rC30iMiOTtMjTENetv2Ng0y/+BCXgX4b6NCZ3eMh85YjwToz5wC3kQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB5613.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dt/kPDstDVH39rGS+ATl2JoNpQZ6rUcUpALt+db+9/fD2QXCsH6aaG23nXtW6o4zHM7R3llSYDLNeGlE/XIsM/YECdujG82SKhbOZW2ARPOEyii1baVzQ8NNtl7jBTjhJ7Ik95a/jD2UdIoV4oIEVsnp+8zIOD5PYo3bwE6YFf0G9pFBY59qOCj9OwjOk5S7K/vu+VEsrX9ACN1iv8seCBFaxqPza0TnTPTMHSQXqsOe8iR9Pqhf6gHhEIUV69el5bS/PcrPj4C8Y8hsgoIksFeXXFcIZwA/uS5YktK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TRW9Wjlm1ggFEOXiOhKR8cE2v7AQAIgOA+WtwKu0hRkdVcYQbSBNAVPvqiraEQrUkMG9edRlMqIbL7PkMd466m97/odYOQyZN/+M1xNaVhWWP1vc1M+nvCaToKfEjOXW3Obrr8sSok1CGYAf/DzTxfJ8rfPPpZhILHru0Ng9tk+7sEUhrXk0pseqmDCqBQxm11rPcuv1V4nDN3rgJvYqhwTIY3Nxh+Md3mAWH+VtT5c+TI0B9hxO8C/omcAhOKKj8HcQ1QdhN3v5T2ny1Ip89RIjyfwLgSaCsDPgUp5ZC8pAETatKBtCR7Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: y+LVj36MuVFm+PZOIemLKGVuK3y6F1Pj1OZIlDtck4JaFzmO7JAaKkbu5ZCGBU6aYInFb0wbE5kz2HJjwCGlxodW3tNslhB0EPjESqMLSoetjdmtWUzPF4uBzijxrvFhPaXtfIkPd/8VHx8sjy5NIwnTOFfoRQjnfWXYipFOGUk7H6gV1rkggh2GAocpbYWuXJ8JmnotdD8wR2LP751L5nALu0yILScZlEgU7+BN+Rga1AvuRP0CiN00v6PViWlv5raScZx2grk9SdnlszECkIVi+b6XRHWDOHoZruMy26A/12+QWjx/TXFtqYk8LaorvKtQjqKr7YFGBwknfmJp8k20PQAQ0dYkrxgh6oIEqH7Vnn0yzhR2GmynaOnPTmmtC1RxbVrxJkyRqk8QAS7o8SlVY4E6Wk5QXYUSGAMEd+5N7JHlvre0x1lKXq6q3ZYkgcMNWAQplp0I8X8JImEkUFzlaUbRQ4gNKfgJZ7nE7XSX5avCvPvqSy1NgGSWVze+98eY4uNAxND1dBfOHiyl4ILgjT2zd2zHZTEJdAVc3DBXCb5UGfjYzttKGzxK4CWuuWL+YrLFlD6oQRxQnQzEVT/5VU29SfuTXdYGkU+Xv2A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7c19032-f9ee-44b1-6c84-08dcaa4484e7 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5613.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2024 11:50:44.6101 (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: Ulsz7+utLnZF9fbeUtpuYgL6V2KFO9emhAOH1mkj4yPXgeL5s8t/bEFc3l8dXEUJ4ukdjZ9fx4ut31TmAv1KV5Z4jx+YzVfcGOg/kK5OEBo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7358 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-07-22_08,2024-07-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407220090 X-Proofpoint-GUID: vet1VF7cj619PQdCJn5PmL4zYrsdC3MF X-Proofpoint-ORIG-GUID: vet1VF7cj619PQdCJn5PmL4zYrsdC3MF X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A3F571C0023 X-Stat-Signature: hjg6ahrki6wwo8pyzeaboa71m1ah6pkz X-HE-Tag: 1721649056-636838 X-HE-Meta: U2FsdGVkX192VEghVCjhfFe7EbeAColmAGpHImFYFf02bl/o4pMRzPRGgVCYGXEk2MgfGGFqo9YiZlRWT3+Awcu16WiPbKKekET7tHx/ykQolSmTKxB9fu9kZ6OKQdiXAlSfGMhqTftUscAqFFxWjT2dYXUmn9Z2RtrjKlV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S/cdLJESqC58eYzE9pPaj6GDvdldAMv231jTfgLdt54WoqfK1nXWZsW6eNSLWm3vEpqZXZSpMTDETh5UVNelT2Fk7WEwUvnyAlnz349239BCkXuHU0w9/AbLz92V4glxXF7yPrM3gheAw3Gvjpzgqa/iuuTZZjEERpQzBnZ5fUq9zOsqW4am0ZAkaAIRSdVI/N1A1QmD2yXnC/5kvXfk6wPs2MGDhxw== 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: The vma_shrink() and vma_expand() functions are internal VMA manipulation functions which we ought to abstract for use outside of memory management code. To achieve this, we replace shift_arg_pages() in fs/exec.c with an invocation of a new relocate_vma_down() function implemented in mm/mmap.c, which enables us to also move move_page_tables() and vma_iter_prev_range() to internal.h. The purpose of doing this is to isolate key VMA manipulation functions in order that we can both abstract them and later render them easily testable. Reviewed-by: Vlastimil Babka Reviewed-by: Liam R. Howlett Signed-off-by: Lorenzo Stoakes --- fs/exec.c | 81 ++++------------------------------------------ include/linux/mm.h | 17 +--------- mm/internal.h | 18 +++++++++++ mm/mmap.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 91 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index a47d0e4c54f6..2f67c1481e67 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -711,80 +711,6 @@ static int copy_strings_kernel(int argc, const char *const *argv, #ifdef CONFIG_MMU -/* - * During bprm_mm_init(), we create a temporary stack at STACK_TOP_MAX. Once - * the binfmt code determines where the new stack should reside, we shift it to - * its final location. The process proceeds as follows: - * - * 1) Use shift to calculate the new vma endpoints. - * 2) Extend vma to cover both the old and new ranges. This ensures the - * arguments passed to subsequent functions are consistent. - * 3) Move vma's page tables to the new range. - * 4) Free up any cleared pgd range. - * 5) Shrink the vma to cover only the new range. - */ -static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift) -{ - struct mm_struct *mm = vma->vm_mm; - unsigned long old_start = vma->vm_start; - unsigned long old_end = vma->vm_end; - unsigned long length = old_end - old_start; - unsigned long new_start = old_start - shift; - unsigned long new_end = old_end - shift; - VMA_ITERATOR(vmi, mm, new_start); - struct vm_area_struct *next; - struct mmu_gather tlb; - - BUG_ON(new_start > new_end); - - /* - * ensure there are no vmas between where we want to go - * and where we are - */ - if (vma != vma_next(&vmi)) - return -EFAULT; - - vma_iter_prev_range(&vmi); - /* - * cover the whole range: [new_start, old_end) - */ - if (vma_expand(&vmi, vma, new_start, old_end, vma->vm_pgoff, NULL)) - return -ENOMEM; - - /* - * move the page tables downwards, on failure we rely on - * process cleanup to remove whatever mess we made. - */ - if (length != move_page_tables(vma, old_start, - vma, new_start, length, false, true)) - return -ENOMEM; - - lru_add_drain(); - tlb_gather_mmu(&tlb, mm); - next = vma_next(&vmi); - if (new_end > old_start) { - /* - * when the old and new regions overlap clear from new_end. - */ - free_pgd_range(&tlb, new_end, old_end, new_end, - next ? next->vm_start : USER_PGTABLES_CEILING); - } else { - /* - * otherwise, clean from old_start; this is done to not touch - * the address space in [new_end, old_start) some architectures - * have constraints on va-space that make this illegal (IA64) - - * for the others its just a little faster. - */ - free_pgd_range(&tlb, old_start, old_end, new_end, - next ? next->vm_start : USER_PGTABLES_CEILING); - } - tlb_finish_mmu(&tlb); - - vma_prev(&vmi); - /* Shrink the vma to just the new range */ - return vma_shrink(&vmi, vma, new_start, new_end, vma->vm_pgoff); -} - /* * Finalizes the stack vm_area_struct. The flags and permissions are updated, * the stack is optionally relocated, and some extra space is added. @@ -877,7 +803,12 @@ int setup_arg_pages(struct linux_binprm *bprm, /* Move stack pages down in memory. */ if (stack_shift) { - ret = shift_arg_pages(vma, stack_shift); + /* + * During bprm_mm_init(), we create a temporary stack at STACK_TOP_MAX. Once + * the binfmt code determines where the new stack should reside, we shift it to + * its final location. + */ + ret = relocate_vma_down(vma, stack_shift); if (ret) goto out_unlock; } diff --git a/include/linux/mm.h b/include/linux/mm.h index f02532838f42..bb1d9de6fa81 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -998,12 +998,6 @@ static inline struct vm_area_struct *vma_prev(struct vma_iterator *vmi) return mas_prev(&vmi->mas, 0); } -static inline -struct vm_area_struct *vma_iter_prev_range(struct vma_iterator *vmi) -{ - return mas_prev_range(&vmi->mas, 0); -} - static inline unsigned long vma_iter_addr(struct vma_iterator *vmi) { return vmi->mas.index; @@ -2523,11 +2517,6 @@ int set_page_dirty_lock(struct page *page); int get_cmdline(struct task_struct *task, char *buffer, int buflen); -extern unsigned long move_page_tables(struct vm_area_struct *vma, - unsigned long old_addr, struct vm_area_struct *new_vma, - unsigned long new_addr, unsigned long len, - bool need_rmap_locks, bool for_stack); - /* * Flags used by change_protection(). For now we make it a bitmap so * that we can pass in multiple flags just like parameters. However @@ -3273,11 +3262,6 @@ void anon_vma_interval_tree_verify(struct anon_vma_chain *node); /* mmap.c */ extern int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin); -extern 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); -extern int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long start, unsigned long end, pgoff_t pgoff); extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *); extern int insert_vm_struct(struct mm_struct *, struct vm_area_struct *); extern void unlink_file_vma(struct vm_area_struct *); @@ -3285,6 +3269,7 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **, unsigned long addr, unsigned long len, pgoff_t pgoff, bool *need_rmap_locks); extern void exit_mmap(struct mm_struct *); +int relocate_vma_down(struct vm_area_struct *vma, unsigned long shift); static inline int check_data_rlimit(unsigned long rlim, unsigned long new, diff --git a/mm/internal.h b/mm/internal.h index 81564ce0f9e2..a4d0e98ccb97 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1305,6 +1305,12 @@ static inline struct vm_area_struct vma_policy(vma), new_ctx, anon_vma_name(vma)); } +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); +int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, + unsigned long start, unsigned long end, pgoff_t pgoff); + enum { /* mark page accessed */ FOLL_TOUCH = 1 << 16, @@ -1528,6 +1534,12 @@ static inline int vma_iter_store_gfp(struct vma_iterator *vmi, return 0; } +static inline +struct vm_area_struct *vma_iter_prev_range(struct vma_iterator *vmi) +{ + return mas_prev_range(&vmi->mas, 0); +} + /* * VMA lock generalization */ @@ -1639,4 +1651,10 @@ void unlink_file_vma_batch_init(struct unlink_vma_file_batch *); void unlink_file_vma_batch_add(struct unlink_vma_file_batch *, struct vm_area_struct *); void unlink_file_vma_batch_final(struct unlink_vma_file_batch *); +/* mremap.c */ +unsigned long move_page_tables(struct vm_area_struct *vma, + unsigned long old_addr, struct vm_area_struct *new_vma, + unsigned long new_addr, unsigned long len, + bool need_rmap_locks, bool for_stack); + #endif /* __MM_INTERNAL_H */ diff --git a/mm/mmap.c b/mm/mmap.c index e42d89f98071..c1567b8b2a0a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -4058,3 +4058,84 @@ static int __meminit init_reserve_notifier(void) return 0; } subsys_initcall(init_reserve_notifier); + +/* + * Relocate a VMA downwards by shift bytes. There cannot be any VMAs between + * this VMA and its relocated range, which will now reside at [vma->vm_start - + * shift, vma->vm_end - shift). + * + * This function is almost certainly NOT what you want for anything other than + * early executable temporary stack relocation. + */ +int relocate_vma_down(struct vm_area_struct *vma, unsigned long shift) +{ + /* + * The process proceeds as follows: + * + * 1) Use shift to calculate the new vma endpoints. + * 2) Extend vma to cover both the old and new ranges. This ensures the + * arguments passed to subsequent functions are consistent. + * 3) Move vma's page tables to the new range. + * 4) Free up any cleared pgd range. + * 5) Shrink the vma to cover only the new range. + */ + + struct mm_struct *mm = vma->vm_mm; + unsigned long old_start = vma->vm_start; + unsigned long old_end = vma->vm_end; + unsigned long length = old_end - old_start; + unsigned long new_start = old_start - shift; + unsigned long new_end = old_end - shift; + VMA_ITERATOR(vmi, mm, new_start); + struct vm_area_struct *next; + struct mmu_gather tlb; + + BUG_ON(new_start > new_end); + + /* + * ensure there are no vmas between where we want to go + * and where we are + */ + if (vma != vma_next(&vmi)) + return -EFAULT; + + vma_iter_prev_range(&vmi); + /* + * cover the whole range: [new_start, old_end) + */ + if (vma_expand(&vmi, vma, new_start, old_end, vma->vm_pgoff, NULL)) + return -ENOMEM; + + /* + * move the page tables downwards, on failure we rely on + * process cleanup to remove whatever mess we made. + */ + if (length != move_page_tables(vma, old_start, + vma, new_start, length, false, true)) + return -ENOMEM; + + lru_add_drain(); + tlb_gather_mmu(&tlb, mm); + next = vma_next(&vmi); + if (new_end > old_start) { + /* + * when the old and new regions overlap clear from new_end. + */ + free_pgd_range(&tlb, new_end, old_end, new_end, + next ? next->vm_start : USER_PGTABLES_CEILING); + } else { + /* + * otherwise, clean from old_start; this is done to not touch + * the address space in [new_end, old_start) some architectures + * have constraints on va-space that make this illegal (IA64) - + * for the others its just a little faster. + */ + free_pgd_range(&tlb, old_start, old_end, new_end, + next ? next->vm_start : USER_PGTABLES_CEILING); + } + tlb_finish_mmu(&tlb); + + vma_prev(&vmi); + /* Shrink the vma to just the new range */ + return vma_shrink(&vmi, vma, new_start, new_end, vma->vm_pgoff); +}