From patchwork Thu Jan 2 12:10:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13924459 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 5F32EE7718B for ; Thu, 2 Jan 2025 12:12:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDF876B00B9; Thu, 2 Jan 2025 07:12:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C8F796B00BB; Thu, 2 Jan 2025 07:12:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 982276B00B9; Thu, 2 Jan 2025 07:12:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6796F6B00BA for ; Thu, 2 Jan 2025 07:12:15 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 88B2F1C645F for ; Thu, 2 Jan 2025 12:12:14 +0000 (UTC) X-FDA: 82962397854.05.EE664E9 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id DBCD6140013 for ; Thu, 2 Jan 2025 12:11:32 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ASNsGRkM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=A9NkmNVo; spf=pass (imf26.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.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=1735819884; a=rsa-sha256; cv=pass; b=AdggbiKpMV9oZh5qOBXjWczkgW5z0mBp0Up8F9L+/++FoBWuc9fBww+uL+Q8J+rOpSZLiK oEr34XOGCA32BNUAiMeDNn1hvUzcnLSTpcoCXKbcSa4gxgZj9Px1L4xZbJjXpnmrhnsHaH YUOG2HIKbWR5tEcgpO2um/I1ZPMbcS4= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ASNsGRkM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=A9NkmNVo; spf=pass (imf26.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.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=1735819884; 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=RPMwFte6ft3Ci0McZVbfCvwGByLKCsXDAFOmeVJDhmU=; b=KBL/zomdNKZTZVDo/KBQrFmyFSTdcZKqr+w0CCFSjsTm1vmOSAr8KOEVyeORU/rU5E1/gF chZ/i9wj1XzSGepeM9Mpr6HdGvEVsiP1F/2vy1rukwUcvU0f7XFg5Yf/BbncCLvQKssHRS V0AeJ5O8p46mNDG6FLA7Borkf4kNnm4= 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 5029fmLs008118; Thu, 2 Jan 2025 12:11:54 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=RPMwFte6ft3Ci0McZVbfCvwGByLKCsXDAFOmeVJDhmU=; b= ASNsGRkMgq7hkV6InQGJ+KY4u6RxVtKs/Q5SUaZgNmCbGmt22aUaFzK9QblyuFLk dtpviT1kDwRGiP+RDy4q9D4t51TGWUoEc9zYsBB+1fZx6xd4VRMPTK0jjaEd2H7d PNkij5sBjYoitlmHEVYl9PivcAkS3jIZUvzNI1n/M6eMawH9NXXP828L450QbWHt P45BAEOX3+Mt3ukGF+8xeHyPxXMsHZEGw8csWnVpbuEuJ5XhfyDcUckEqEyLWtGc 5w+SwbtE70bK8B+wE+Gxjb+3PrWrMOpQB/FGqGMo4DB2JIeaUtKLbxgejFU4nBIF vS1kSQ9+rYjRsieAdapbyA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t9chda1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 12:11:53 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 502A0OjU027772; Thu, 2 Jan 2025 12:11:52 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2046.outbound.protection.outlook.com [104.47.57.46]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43vry1hjag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 12:11:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zr9sZzLoxSVMPPwpk6pcjMmKBKZ9ju3rRivFRWUgBotZnPK3xyVP5FiQiM997tRde63F/U3W0jTJQPk92n7Q9j8oH/kAgIc6lkdBhQYvhhNL+55HWfLJ2XPfgLkFkYRGF9b6+7aO3S/v5V/XC3jeD8qyGVrA1gG9iWv+fshsuvpmQYgwo4xoyP6DE99MVZzFi60cYNgFzcRwFY/xvzlSqPhtERuIktQDXWWZ6azZnAn9dzjjFebZrpPdwfu1AVlinWVpbN/PL15JBi0uNcv8RNiW4iV2ThcEdXm0uzTL0ShYGkBXzTEW9qJPE5VK6IEX+OTVvGTPWxiiRA0x8SOS8Q== 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=RPMwFte6ft3Ci0McZVbfCvwGByLKCsXDAFOmeVJDhmU=; b=Redrj1GjPZcHWKtQUbH15qV1cQGMxZ3Vz7jR/Nhcmz9P5G/S9plIc90ElpZSXnCb1xSTu0OCAL4saJXkKQ6p+NtsS+fqegkI7ycWm3w0I3YKYXvpbMN7qpV/ettI43L35JDpu1sAPrs+PpcGCykycmnqoW1gYZvoy/qnarEZQHswSM7KUhYi8xtO+YRHJSSCqxUjanTLzm8EgCujV00RbLBoBVUTYmgY/MAShFo70PWkTl8QtjASDDorNG5U3n6/TpHv1Q+aO4TxnsqBUr0Q4T9AljxV6u1vWYzVivzFbSxy7aBl0zmW8MNeoFQLJ98m9ECrmpmdDqt9hprYLRBBfg== 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=RPMwFte6ft3Ci0McZVbfCvwGByLKCsXDAFOmeVJDhmU=; b=A9NkmNVoD22Y8/tSItisGorjy4u5CUPlMwtggUSj5YEq3FdiL5XxKjE72beoLku2mn5Rd2oORMtZXGI5FcLmJXnIXBrO5sh26f2phmtAa3dhLJnpl+cEk406E2ZZUB/Q3h0uuz6boTSbJCHu+oszg1tcfLzskxSZP9+mErU/LJI= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by CH2PR10MB4197.namprd10.prod.outlook.com (2603:10b6:610:7d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Thu, 2 Jan 2025 12:11:47 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%4]) with mapi id 15.20.8314.012; Thu, 2 Jan 2025 12:11:46 +0000 From: Lorenzo Stoakes To: Andrew Morton , "Liam R . Howlett" Cc: Thomas Bogendoerfer , Vlastimil Babka , Jann Horn , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH 1/2] mips: vdso: prefer do_mmap() to mmap_region() Date: Thu, 2 Jan 2025 12:10:51 +0000 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0249.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:350::14) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|CH2PR10MB4197:EE_ X-MS-Office365-Filtering-Correlation-Id: 0524e643-81b8-4ed0-2c20-08dd2b26a115 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: AgAChrfpVX6vHlofdN86Swu5RpcLr+BoM6Rmo9F5TONJV1UdE1djI5wLXMUvkczlXPP9KyLY1P5gcQbOpOKneDAXXrrzNjGuWBSJ0roikmJT9FY1uiQuRfjxSmQF9GQa9wWRDzcGIF+ZKCtQTlj6Y6Bs4apOxjRSrfTwYYtNFZTC/bjnTThnvqjQ0MDlwfTx/gyvbPz7RBNH6hMPG/jiR47xk1tY08ATZPwnPQCZMSqB+IfRDLC/r8RX8EzmwwCMfECQEqIJnKWyQ+IVeBdxni8G30C+lKQ1yzsiVr+tRAemxKV/Gw+tBl6K3FrcrYkeGbGXJi5/hlPSLBK8V9uKspKmUuKyXpJ5u938QEcyupd69oK8FMKihKrTfRZsFlhdrQHwOPXyKa6w6Oh29hABYwjVQi+3DdBgyTp9yWR/QpjA3R+qZ5SHZDpCEyYjItWxNtJjZ48fxZEv2p/9DTSTC4R0agK/z7/feJSkabWVSdA9nsnlSRRfbCX8vG2M7yYC3PzamDGWT1ujsssEMRFhvuqs3ve/W4W1dkxDqUfDC3SspxNkpIMEYOO/kYtSfDwa7EjYJk9Gk73hx4it1qzEZS2Piwc+Bsi19dSxcwWwHnmOv8FR9s+0ixBKRxEl98ySBohuhfIYPZ6sngO6mdns1Rjnv/9A8bLEZtvAyzsdu94P4lqbkYAPHreGdJ90xcWu3LcEsDoF9OqJEThVadvfoZcVo+T9P1J+/geIS0ZJJkEfui6kLfvMx12dXL79fIxP+7TmZHTlpPUicNs7a0MB5Ee0yDGnwm6gFHTqJdYn0cJf5zQPQoR/YSQn3ctiPBP96KDFmpHr3pc62ja0IoVIreiRvV1GoGXYTYWhGSmWg8rcuGR+PsDEliXx8kM3ni35i4/jz2m0UkUwZBaRRxwsVaP7PZRLl77VIHtOxHlYE45wqGwESktB7UvcsYP/l0mEF8juDcGjyqgmvv+ZEEG80GnzYyO6U48eMdiXwIvrbNd2YRAGyB4nZuCQAzojzFtO0WrtScoc3bZsqESPUrZ7XlZH2vtsJNEOhctJmzdOStLVtxUbkwwf5Ny1xbvdW7/hgyuGfNdf7iCwMiXcrKf8s0iAXY+1dDmgU/BQxadwl22wlvODI1QYDNLKtXWs4UKl7FwjiV9MMe29PktaHSUpWSl+VPB79fQFXgw4OFYx3rCoDMfJ7Uxi8UGpdNQ2Yn0C3f7UlJUUFdRKGX6a1QpUiohvurgGodW7Yq9h4tVg56OPY/JRK1euJZIFwl0pJUUQTkN1kxjXIxhY+mg+Ua619QjjAY/iOwAt1gUi77HZJPhNScC5GiZJ0LF8XywRTAqJ/SW62di+Igtj+0b5p8xKe2GYaqKF6UHqqhsUrYFHD1ZNyd/M+oNpxo7SgYkFOQ0P 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)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0ZGAVV6hA58POmps4OeHAMv98qmTerwyQUOlZiBSgookdiQAi4tWdIgsdqv9cQ9an9iZbCq7coGTLXuvFkZKTKC4rifZo9QsV6hTLM2WBxYKlwWZ9QQGWFlEhKstQp1bV6os0RZWpr8SaOlcsJ7Ld6SmBH1LQJTvtFYYvSBWprF1pnCg9s08Oq4uJZOpoxOr9T9eCbX/9+GIwtI04f5AwRK1jbiWJANxA0JBkDvoIuYDXVdN9ZhUxbcMlnHNlo24CPDeYtX0s55UxokuC+tAytpmSs6teWKcEAPeaiXrtTjVoaKonpFElOK484c2yqAvzgH+ENKQNwfk5XZ2CKKF7/gG/a8Z2K0Wk8k6oTVkwo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jiovvfIE/ioYf9v26ZiW8qs6AwmPdvkG673Y450qKveISEYakis64gRytFsBHsC8roz0gVDn0b39A8AiYnb7Tm2mTohVACSQ9BiJTApHK31dAzpsTCkBc3GbKVvjCAJb7dazM2IK6NK9qVOAqrGTJ2Vqj8B9hRgZcJ1dWmWDNwFS2g994ghX91twA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: FV7cAkKI36KsQV8+WydszyeNZEUGLI+g6jWbrzWWwKaQlyUWJMAmvPdh1PXbg+GFUVjA2lR2l0Ul0co3pO/g+Qub4fhQw+W3gGHy592mz50hA6aTt+NbBlUE/1CyCmoDbOWoCc2JpyfptDMCsPRIlyIXNQNklrVFfunXArpfkniBD3LTmIqNAV4uAhgAtzmGu3Cw9VnzMdmv/6h9IDRdPg7OHLVLgwRaYoN/j3erJpQVXFIB3Li8lngeGXzSV28Zw8H34rNgSMRY6WyYaRsnAmsgKHzSZROtpEcZgHfVCikykkub6WYE8RjIK8nTeimFkiTL9G+GhrMV0UmPynYo24/TEkY5kaNE2GuNgB4ywXnMlOBwxx6DjvRuC22jT58Sk6eLEmnUy5mG2GE/N3JyCitg+N3Mc9GAjjXRAVmJufDzkoVFTTj7kHWikOXl8+0g7/bleBHyltCcJhFD9C18hPxqO/ynUBbHaS0gdhnPVvY4b/BujuXyLOrQb/eBmLNdNn5tV+6EY95p89OPS66CNiedn2UseGSpkPHHTIIuxBXGINoOhQTIyTQS+fFIfX9Q0P3CwN6MqgCOlU3MPrNeRQG3F6+096PY2YghUaQgltw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0524e643-81b8-4ed0-2c20-08dd2b26a115 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 12:11:46.8951 (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: IJ7Cb590TG1MywmBhzCBTnse+KjRiv2up9XqLJ4g6GQEgv5+wJgd5wxGDXR7mKCh2WgdY6fJ6BMGQBJz+tsEMr/HDdsXcgQ8740cZ6/scfE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4197 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020106 X-Proofpoint-GUID: pr60IA1CrjlERYXzj9qdcn1jeDcnFAi0 X-Proofpoint-ORIG-GUID: pr60IA1CrjlERYXzj9qdcn1jeDcnFAi0 X-Rspamd-Queue-Id: DBCD6140013 X-Stat-Signature: ws1i3wycgsk4zwcbfb6no81pcar6u1bg X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1735819892-218001 X-HE-Meta: U2FsdGVkX19hy1D1nCHyzII3bGq5473tYmEodr+iOz68pFrFMuHkyhqHy80ZAUNmqKQ+f0zD7uQ04oorsKwpHBCxvLLZOEW3CaulgRlAeADhdnFL3m2znP+W0rmTm00wrR5xdIvHEiXszDcRm6I9jmLyqEjpiVgRIAi6z9pRi4l8IVkEcR8apeo7PWiXG1rxwQztY7LXgCGVMZ9aDMmsNCjD7asdWQS73u768+rZZrwn0+4boz3KWRy5l3ibd6vncclYktGZ/VlTEnej/gRdP8mCvQz6idx15Mw6XNQRfrVk9NladhyOOjZ/6/psqXGu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hrM+7TwI9QsWpzg9F5jdOSZj+TQ9mrLtyrqmUqyLI+j2sP+Q5zwgXMtLT8n87bFBs+VRE+Gbjv9Syaro0Skpjxe2q/USKLSkZS5k65XygHimLeM2S9fAFH4E3LermIstWnGsk0mfMZagbA5szpVALomnQ/1+7tjOTarEVEmpN965yY/pOvOqY+Y9IA1w+O7w87+bpmLSdyW5XUrP7HJ7QtzTiMZZdu4B+4k5E/Qyd9pJkQufh5p+bZSQy5vLTjC5YHknfxvfr3Hcw== 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: mmap_region() is an internal memory management implementation detail that is not intended to be used outside of the memory management subsystem. Map the delay slot emulation page using do_mmap() which makes use of the already-held mmap write lock and bypasses unneeded populate and userfaultfd logic. This should have the precise same behaviour as the existing logic. Signed-off-by: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- arch/mips/kernel/vdso.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c index 4c8e3c0aa210..75c9d3618f58 100644 --- a/arch/mips/kernel/vdso.c +++ b/arch/mips/kernel/vdso.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -97,11 +98,12 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) return -EINTR; if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) { + unsigned long unused; + /* Map delay slot emulation page */ - base = mmap_region(NULL, STACK_TOP, PAGE_SIZE, - VM_READ | VM_EXEC | - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC, - 0, NULL); + base = do_mmap(NULL, STACK_TOP, PAGE_SIZE, PROT_READ | PROT_EXEC, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, 0, 0, &unused, + NULL); if (IS_ERR_VALUE(base)) { ret = base; goto out; From patchwork Thu Jan 2 12:10:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13924460 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 94B3EE77188 for ; Thu, 2 Jan 2025 12:12:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDD556B00BA; Thu, 2 Jan 2025 07:12:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E8BDB6B00BC; Thu, 2 Jan 2025 07:12:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B39BC6B00BD; Thu, 2 Jan 2025 07:12:15 -0500 (EST) 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 6E3776B00BC for ; Thu, 2 Jan 2025 07:12:15 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 142D116097A for ; Thu, 2 Jan 2025 12:12:15 +0000 (UTC) X-FDA: 82962397056.07.D339E6B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id B0E211C000A for ; Thu, 2 Jan 2025 12:11:19 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=BXdKqtPs; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CfFQnIc8; spf=pass (imf20.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735819909; 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=z15p6HFmxHvoiaIRhRsc4oMsT/fB/eYKW4sNfhR5geY=; b=U67usqQRjXpWQUGxsdDi993Vg/tUKPdCL1VPfacN4m1Geiv8vvhilQnQlIJh5902DOVwSD 03ToUmF2nBreJN4S/PVqte9fyqtP6KRIbp8fXmrPLkevknsiANPIMtMmEbjVPdXNgRxzor 2Kj7udjTQ7gm9+yy4Aru4lsJ8edQppc= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=BXdKqtPs; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CfFQnIc8; spf=pass (imf20.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1735819909; a=rsa-sha256; cv=pass; b=eVYcZQM3tukjmDKfPh8/evDw52endxNOfOpWE11VxrLUhzP9tesX3I7i1V2WArbKB65Bl1 3/hkZfbNHpi70rkf2k5vVvTWEXJXPKUl1kjiabI8padtm+fF3El6SN9h2gPGHtEo+oLSgu e316fTLxN9m85WD7i7YKZN+IdCux3yE= 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 5029g0Um023923; Thu, 2 Jan 2025 12:11:57 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=z15p6HFmxHvoiaIRhRsc4oMsT/fB/eYKW4sNfhR5geY=; b= BXdKqtPsm6QyBzfcuuM6JhO+VTWRKbh2pg4wn+Gs4IWRTlCB4SepGytzT4dVXJDs PPQVqUGJXjVQTi6hnnD03hzGymsNkcUd0SrCb4d5f7XwRR28MqFvIT1JFyr+FbS1 5H6KuURekfifD6BS1ZBe1xwyswE84UIo554tLX4ytxN9IRRzJiVfIq9wb2Bkhj5Q qscahM9epUh1vYCl19057NBYixfs4F3kY2l88L/Np/HmppbFlT8yzWOFFSTL5nHR D5A79JMf6YORPaTcKfd2/xCwTqVsHd12iZlltFfdcD3AFqb4vG/qZcSIey/79Qcn qZdaAxzHRBBDXPKtWdyEpw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t88a59cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 12:11:57 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 502BLexY009459; Thu, 2 Jan 2025 12:11:56 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2048.outbound.protection.outlook.com [104.47.51.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8fq32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 12:11:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=H/bDDo0sV8JfOnU5gwITJiy2v/CXw4Jk9AeaW+GWU2TMqZUXVh7C6Grpb+CDbPwS8FmW65XSgoau/vinFUkzLSESQS4nRTWlQmUmMniWKBTHlws/UZ6UXJ8zAxPjl7vIRW5BLPwU2Xum1b3ZQB6jpMBXzYscUbKNaBlFTKSTfLDJ39y+2gkeZ7k+oc/OzbkwPWmgUOh+m+lvTRNv0ebFBeMwo6w/aoi4ACw32kW87iz3c9XBp2SHRvpSongSlkj9vwe2wCW2m82kpDKXqWQt36Osc2Rym0wiXmKXaZ/trkiukwAJY39GORtB/lwkvUsPZ80Sml7th190li9LADWCIw== 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=z15p6HFmxHvoiaIRhRsc4oMsT/fB/eYKW4sNfhR5geY=; b=gwvygueJ1x7aXjMFPGa+90qOKPGDJz4qeLf+tohp5/42NySrDsqHtxZN5nyc7jGAP2lcdAosqwEF/AExwuPJ/v/AX6Vab3gByJUmxQVyjZRTEy6aHSraOnuhrG3DJEwgeDkVEHHclCcIlSZTnsnlE/ZCuMjx+/FTW9DvspkAJiFwY0AloIAVg1D8nxNeNP/IhZjGK6E5QA9BD1lVHyXYsDflI1ymiwf5DecRt8jq5oqnQ0DlKubJBWPB769qrFAhF4tSNNSM3z4Y+4n7KRaI6wCux+vG8Fv1zM0XEyQRXj4QWD8HFCHpZ73vXRtAPZQtMnCOb4QklTf6kLoXmhGxNA== 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=z15p6HFmxHvoiaIRhRsc4oMsT/fB/eYKW4sNfhR5geY=; b=CfFQnIc8IXTR0j1Dkfw667ORrbFuDBTrauq0Wraxrj6JpYnB4tSiDhB3F3XLWdHY72eKsQMm7+eRQSBWKvkO51WgLV1h3QY08AZIldAb0C2QCtqo0L9W9Kxi4n6/92MGKw0bShtuGB03mg6p9fcSRKnHHLLlhL3DdzzaIiY2aMY= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by CH2PR10MB4197.namprd10.prod.outlook.com (2603:10b6:610:7d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Thu, 2 Jan 2025 12:11:50 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%4]) with mapi id 15.20.8314.012; Thu, 2 Jan 2025 12:11:50 +0000 From: Lorenzo Stoakes To: Andrew Morton , "Liam R . Howlett" Cc: Thomas Bogendoerfer , Vlastimil Babka , Jann Horn , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH 2/2] mm: make mmap_region() internal Date: Thu, 2 Jan 2025 12:10:52 +0000 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0583.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:276::13) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|CH2PR10MB4197:EE_ X-MS-Office365-Filtering-Correlation-Id: 2dfccb49-5de6-4030-ddce-08dd2b26a341 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: +0FzitjbfeF8kt0cxwFdUofkpkID38ZzAUrsQqzq3yxBNjQAVzezo+bH4nOz6vEY4NL3y8M/DOV9exQZ6NagDUNeWt9UiMP6QlVdKu3E2wi4FRlw1J8Ww/i0OIOSUlpc/J+7SNQGTV8fWnXY0VptofqVelg1yn5al0N2oUBFBWdQYa/dza0UksvVuoI2bPcoeSPwX/pt5vcfcRiNaumCiN7uiIwhE3PRc+uwh3yDZGuNHoK3FN93cRxQRw5Uk1n+BO0fyeTVNJTE7ho2PYWJhCVuNMDBNGuJQyvcbPrm/h6Eu8TZSbiZLFOOUowBMyv09ajLp8rhuZkJ9PUVcj5MY4T6GgfQ28lZeON/bydgpQrHi+5d2lYDS35nGyoo29tpV0r7bUHuzFEMf2FePt9cgiAYHqKzZvLu2gBwQ5l7BeVsnOdGCkSY8Dspv0ZrTs2WNVSfoANRgYHxNiXDUR30UsQOd2QqfXxUo6tqWu6v0SkGm4fYOWa7+tX09c8jDGhBpsJSGArsDdhM11mKaUrn2zxGhSv3rTafmCjv6Fpo2ZrTRLLxORugjM1AlkaVG4iB65gGzIPjywnWZSgATXXUQFUTk+MT/CsEQsZQVoyaUKJK6qYrEbI9tTAgpg1W+b2TyRexbkea1e3yIfcN7R9DcNsseMKmZXN/pxgMlwbRKigvX+El4lg/T1RBvt92GXlgnoNzPm7CKw/AQIHzja6nVDhqPkSPr8c8EIP9LO538hTNjaxoKfnGZ4j/CyCy7kBkU48tukZkAiHUWZqGqOdMBSxmFmLquQzM2Da6UKh/ZX51pEJA7nCSYAZKq9sfS1bFQU88z7i5TrynFQMT+7srVQOVS4m2sVsPsPTBx+Oyou7jSF02b8se3o4V37c1m6SRA4wGWqUMGmtWQIvkSZEk3syR+Zo9oK8qvMPocIp9Bj+gHSVMkzKD26y4P/avmDluYeO70prN4FAH878wnuzN3xmctjQPClshI8Z8j09Ptb6kp+yDjHoK9q1Hnt1434L/klMGTdtQ8UbtkuQup/DJrY4i07E8vnKriR0bUEbViov/jpSKs6V9ogThUzhcMl8wGdEVu7Txu4pIzQoVqRMB/GmisYymVQMyFhYx5n3DbboBMnKzAmj492toBLRN+OI+d0kDPPRajwdlKwH+HocmZfga4Pctm91kzWkRkMiPH12ByVAcev5rHKK9ZUB0KAyrBoQi3mwM6iSna2VHQ1HancgvXX+zxDe428uatZEbBcKEQZz4lDMyhYmBwjDAVq+m5URjETKSsQPFnBvKO8ORbWwH8iMQobc3r/2SdMF4l2s+egUHgq8HHZfmIewQTk1QxVyzzcCYlUJlpiIYwVWzsL2dm2q5nZW2Sn6+uRg/ihjEby99bPFotjZ2baAI6v/i 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)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5xRaOL+o0tacnsjWZWoVHg/iYYrXwFXba1X/RqOL9n2vdoKf4oy3hFwDQAKEN96EHlZY/L+2sL5wGAdys5aIWPjVqaZ2nZP9HLxwujrUr/x0gMV1tOprH3zKgkCMvoXHHUZ7q1e3cjQr25GMdY9DXcc0NC+YXZAeGf/jxZV5gsJ64G3eOO09FgeL8vdrlgDJhX9d1Z8Z2t946aVAJyoGjo5MHU7t2mlnrTUOTEXf9s4OXqsZ0uMEGOpvFHwq75SsBZkwNN5AxN073pW68cEaYV7NgUWI6NosYVwy9ZLAlHzh4GlL5N/tEH3EeahgtxwdUP+LkASUchQ0FPAgSbn3Am+t99+ZlLDAVqXTpIn5l6b6MWjLsQyVjPuUwcqu+sxZNSwhUsop+f9cR27OxASvZmEggubZB5o0ISrb7CCYj3er4Y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PXyj8AqTXEu5bEfqYlSU/01nX4DedNo8BH8Li19DD0yXYGCSpiuKDUdzhmYA8oQbBVny0aZFLpx6x55gfjeUHFjQbjP9xOd1XG9s6Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VCmIWhtpxpZe/DsGIXzap7A7VV3ubwzTCzHghiB5qpN3aiN6ZxJklUd7eYen/ON+/9g4eWCRIObQH3wUm756FfAFfRYp3bkMu4fh49peXBkn3Wr8/yhrGXJ5RF5dBKdHp5iXuH3ErwRPRfbn2nXLch/+OyUteLb49AmO+P/n2S2K3DEM7b1DHP6b3Ah+DpoMxiRAOao1OCAriZ4btvLbtsIqpOGyHX2KvghyXTLNrBAkV/mYN2zmWkC32jzRnfPlYOoD72Z0oGH4TKu1X0pQmVQBkRuKVIW8SjbovYYGOmdguAKS02G1OsB0xKM5EJOOpUu6nqeclmIReqvFkxjMzNihU4OnQhtgl+PoICfNNSui12JGEmk2/t/xsOpIhCpRD36u/4IDVHSU7d5SAk8NvtrMkic37ZhPjgzKNBOJ0cN1AgTW99JJADAsu1o4+CY4Q/LijGoTQkS6s6qZnW3YIebi5qwKyQmijGaz76cfIJTzDuyN3DqNSIhope2A+1Hk6e447QQ3Z0NMnJcpMkvUEHE2pX/gMa0CmwO4QqgnCrAYgbwHWHNrEmtKH9cgFixhs+mhrEzhCONGIenSzYXZuR0TMKW58mY6D7+A0I2ogps= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2dfccb49-5de6-4030-ddce-08dd2b26a341 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 12:11:50.5278 (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: JqQYAz1+fKRv/hqFPXMZVWkGdkbbEWLFOBHIGKIE2OfOlXkF0mdtQUthdwxFIe06L36NoXV/CH5kFf/ZleNSKWQlJ/i5u/N/YgRjP/VIyZk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4197 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020106 X-Proofpoint-GUID: TthUL_ey0TavEYFS8IUrqYCJvnQoYwC_ X-Proofpoint-ORIG-GUID: TthUL_ey0TavEYFS8IUrqYCJvnQoYwC_ X-Rspamd-Queue-Id: B0E211C000A X-Stat-Signature: hg6yuf5brwgngx5myotayc6g1j5uew9g X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1735819879-163072 X-HE-Meta: U2FsdGVkX183jl9A0mUGtkfclGqnGJAX5hIqtzccelg8rWF6CREKujV7008yu9uNEzdhFW/YiLYzRyTQ8hATpjch4xCJkJylLZh3izgtcwqtanuBKq4LKVt6fq0xIWPaQAliZniKwrXuiDARCTaALqmIlmLy9decA+pWcNePRv1pVzAlDVuJMt7Pu1hf0xwVLLy7vM00Squ+l2/bsQXnC18RZfeJ4cvx+3VQVRBy7byz9XVrWzKSGqwNOZwKvkF3wYY81FLBUSQ0G2s6lhF93aqWHmNKQb6ahmkDbxjCIdLwPb0YP85bs+uTYWFwPaQg+R4/EeggwVb/O6rBigUpT97RRb5FJPCN0ah+9NBsQMY8xSW6ov1G6ah15lmkC27WFlkIAw5+yKTg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wMpgk+nN4Xulkb1JmrXP82K/EgkcYyv0V7zI7tatHMLm+LIsdcJZGwhSNxtl9acjPHPwh8vb7SlqffhdUvG1T92yj5F5265FtXxBLzUszH4Jit5yY8pybU= 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: Now that we have removed the one user of mmap_region() outside of mm, make it internal and add it to vma.c so it can be userland tested. This ensures that all external memory mappings are performed using the appropriate interfaces and allows us to modify memory mapping logic as we see fit. Additionally expand test stubs to allow for the mmap_region() code to compile and be userland testable. Signed-off-by: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- include/linux/mm.h | 3 -- mm/mmap.c | 59 ----------------------------- mm/vma.c | 61 +++++++++++++++++++++++++++++- mm/vma.h | 2 +- tools/testing/vma/vma_internal.h | 65 ++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 64 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6939c2a8d90f..1a11f9df5c2d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3446,9 +3446,6 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, return __get_unmapped_area(file, addr, len, pgoff, flags, 0); } -extern unsigned long mmap_region(struct file *file, unsigned long addr, - unsigned long len, vm_flags_t vm_flags, unsigned long pgoff, - struct list_head *uf); extern unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate, diff --git a/mm/mmap.c b/mm/mmap.c index 7fdc4207fe98..7aa36216ecc0 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1072,65 +1072,6 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len, return do_vmi_munmap(&vmi, mm, start, len, uf, false); } -/** - * mmap_region() - Actually perform the userland mapping of a VMA into - * current->mm with known, aligned and overflow-checked @addr and @len, and - * correctly determined VMA flags @vm_flags and page offset @pgoff. - * - * This is an internal memory management function, and should not be used - * directly. - * - * The caller must write-lock current->mm->mmap_lock. - * - * @file: If a file-backed mapping, a pointer to the struct file describing the - * file to be mapped, otherwise NULL. - * @addr: The page-aligned address at which to perform the mapping. - * @len: The page-aligned, non-zero, length of the mapping. - * @vm_flags: The VMA flags which should be applied to the mapping. - * @pgoff: If @file is specified, the page offset into the file, if not then - * the virtual page offset in memory of the anonymous mapping. - * @uf: Optionally, a pointer to a list head used for tracking userfaultfd unmap - * events. - * - * Returns: Either an error, or the address at which the requested mapping has - * been performed. - */ -unsigned long mmap_region(struct file *file, unsigned long addr, - unsigned long len, vm_flags_t vm_flags, unsigned long pgoff, - struct list_head *uf) -{ - unsigned long ret; - bool writable_file_mapping = false; - - mmap_assert_write_locked(current->mm); - - /* Check to see if MDWE is applicable. */ - if (map_deny_write_exec(vm_flags, vm_flags)) - return -EACCES; - - /* Allow architectures to sanity-check the vm_flags. */ - if (!arch_validate_flags(vm_flags)) - return -EINVAL; - - /* Map writable and ensure this isn't a sealed memfd. */ - if (file && is_shared_maywrite(vm_flags)) { - int error = mapping_map_writable(file->f_mapping); - - if (error) - return error; - writable_file_mapping = true; - } - - ret = __mmap_region(file, addr, len, vm_flags, pgoff, uf); - - /* Clear our write mapping regardless of error. */ - if (writable_file_mapping) - mapping_unmap_writable(file->f_mapping); - - validate_mm(current->mm); - return ret; -} - int vm_munmap(unsigned long start, size_t len) { return __vm_munmap(start, len, false); diff --git a/mm/vma.c b/mm/vma.c index e37eb384d118..4cf2acc378ba 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -2427,7 +2427,7 @@ static void __mmap_complete(struct mmap_state *map, struct vm_area_struct *vma) vma_set_page_prot(vma); } -unsigned long __mmap_region(struct file *file, unsigned long addr, +static unsigned long __mmap_region(struct file *file, unsigned long addr, unsigned long len, vm_flags_t vm_flags, unsigned long pgoff, struct list_head *uf) { @@ -2479,6 +2479,65 @@ unsigned long __mmap_region(struct file *file, unsigned long addr, return error; } +/** + * mmap_region() - Actually perform the userland mapping of a VMA into + * current->mm with known, aligned and overflow-checked @addr and @len, and + * correctly determined VMA flags @vm_flags and page offset @pgoff. + * + * This is an internal memory management function, and should not be used + * directly. + * + * The caller must write-lock current->mm->mmap_lock. + * + * @file: If a file-backed mapping, a pointer to the struct file describing the + * file to be mapped, otherwise NULL. + * @addr: The page-aligned address at which to perform the mapping. + * @len: The page-aligned, non-zero, length of the mapping. + * @vm_flags: The VMA flags which should be applied to the mapping. + * @pgoff: If @file is specified, the page offset into the file, if not then + * the virtual page offset in memory of the anonymous mapping. + * @uf: Optionally, a pointer to a list head used for tracking userfaultfd unmap + * events. + * + * Returns: Either an error, or the address at which the requested mapping has + * been performed. + */ +unsigned long mmap_region(struct file *file, unsigned long addr, + unsigned long len, vm_flags_t vm_flags, unsigned long pgoff, + struct list_head *uf) +{ + unsigned long ret; + bool writable_file_mapping = false; + + mmap_assert_write_locked(current->mm); + + /* Check to see if MDWE is applicable. */ + if (map_deny_write_exec(vm_flags, vm_flags)) + return -EACCES; + + /* Allow architectures to sanity-check the vm_flags. */ + if (!arch_validate_flags(vm_flags)) + return -EINVAL; + + /* Map writable and ensure this isn't a sealed memfd. */ + if (file && is_shared_maywrite(vm_flags)) { + int error = mapping_map_writable(file->f_mapping); + + if (error) + return error; + writable_file_mapping = true; + } + + ret = __mmap_region(file, addr, len, vm_flags, pgoff, uf); + + /* Clear our write mapping regardless of error. */ + if (writable_file_mapping) + mapping_unmap_writable(file->f_mapping); + + validate_mm(current->mm); + return ret; +} + /* * do_brk_flags() - Increase the brk vma if the flags match. * @vmi: The vma iterator diff --git a/mm/vma.h b/mm/vma.h index d6803626151d..41bb52594ffd 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -245,7 +245,7 @@ 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 __mmap_region(struct file *file, unsigned long addr, +unsigned long mmap_region(struct file *file, unsigned long addr, unsigned long len, vm_flags_t vm_flags, unsigned long pgoff, struct list_head *uf); diff --git a/tools/testing/vma/vma_internal.h b/tools/testing/vma/vma_internal.h index c7c580ec9a2d..49a85ce0d45a 100644 --- a/tools/testing/vma/vma_internal.h +++ b/tools/testing/vma/vma_internal.h @@ -41,6 +41,8 @@ extern unsigned long dac_mmap_min_addr; #define VM_BUG_ON(_expr) (BUG_ON(_expr)) #define VM_BUG_ON_VMA(_expr, _vma) (BUG_ON(_expr)) +#define MMF_HAS_MDWE 28 + #define VM_NONE 0x00000000 #define VM_READ 0x00000001 #define VM_WRITE 0x00000002 @@ -222,6 +224,8 @@ struct mm_struct { unsigned long stack_vm; /* VM_STACK */ unsigned long def_flags; + + unsigned long flags; /* Must use atomic bitops to access */ }; struct file { @@ -1176,4 +1180,65 @@ static inline void userfaultfd_unmap_complete(struct mm_struct *mm, { } +/* + * Denies creating a writable executable mapping or gaining executable permissions. + * + * This denies the following: + * + * a) mmap(PROT_WRITE | PROT_EXEC) + * + * b) mmap(PROT_WRITE) + * mprotect(PROT_EXEC) + * + * c) mmap(PROT_WRITE) + * mprotect(PROT_READ) + * mprotect(PROT_EXEC) + * + * But allows the following: + * + * d) mmap(PROT_READ | PROT_EXEC) + * mmap(PROT_READ | PROT_EXEC | PROT_BTI) + * + * This is only applicable if the user has set the Memory-Deny-Write-Execute + * (MDWE) protection mask for the current process. + * + * @old specifies the VMA flags the VMA originally possessed, and @new the ones + * we propose to set. + * + * Return: false if proposed change is OK, true if not ok and should be denied. + */ +static inline bool map_deny_write_exec(unsigned long old, unsigned long new) +{ + /* If MDWE is disabled, we have nothing to deny. */ + if (!test_bit(MMF_HAS_MDWE, ¤t->mm->flags)) + return false; + + /* If the new VMA is not executable, we have nothing to deny. */ + if (!(new & VM_EXEC)) + return false; + + /* Under MDWE we do not accept newly writably executable VMAs... */ + if (new & VM_WRITE) + return true; + + /* ...nor previously non-executable VMAs becoming executable. */ + if (!(old & VM_EXEC)) + return true; + + return false; +} + +static inline int mapping_map_writable(struct address_space *mapping) +{ + int c = atomic_read(&mapping->i_mmap_writable); + + /* Derived from the raw_atomic_inc_unless_negative() implementation. */ + do { + if (c < 0) + return -EPERM; + } while (!__sync_bool_compare_and_swap(&mapping->i_mmap_writable, c, c+1)); + + return 0; +} + #endif /* __MM_VMA_INTERNAL_H */