From patchwork Fri Nov 15 12:41:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13876186 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 C72EDD6DDF7 for ; Fri, 15 Nov 2024 12:42:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A8626B00AE; Fri, 15 Nov 2024 07:42:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5573A6B00AF; Fri, 15 Nov 2024 07:42:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383B16B00B0; Fri, 15 Nov 2024 07:42:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0F00A6B00AE for ; Fri, 15 Nov 2024 07:42:32 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BFFEBC15C8 for ; Fri, 15 Nov 2024 12:42:31 +0000 (UTC) X-FDA: 82788291852.05.06844BB Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf19.hostedemail.com (Postfix) with ESMTP id 981191A0008 for ; Fri, 15 Nov 2024 12:41:31 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=eHeNEwDy; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tn2zave8; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf19.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1731674369; a=rsa-sha256; cv=pass; b=jDHd19COilKsglAP9S+kx64hbTAB84kEdWwAlLXgtviI1TjO/cvhPimpFHs3MR8AhNkfzt GWS6K7ZSIhzrTGak38B/h+uUZRuuhmvlh4vr/MD9rRAnVRggGP8ZGNzP9IiRofTj/ZEljf DthWuB8ziFCoYY2H/Cd6bQf8M3glbrw= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=eHeNEwDy; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tn2zave8; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf19.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731674369; 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=g4lhvb8C2OfyVjOD4h8GKh1wFOBJ6R0iZcQUPnrOE70=; b=AXb5uPzJouP8zQUUy/Vxr2ZaFFU0tvpTiccVwOHdeIG5x0kWFCjpgufqsl6V1FxDHCyt4x Vrxb4IL8Vfxxyz+aOlC8OUkruxDqwLGbbIKAT6jV6c7A6nNFf67CQyL2pu0nIcjrAwbg7V 9sffGF+b0GLJvQuO/2Tu46wLtwdxOdc= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFAHGhv026024; Fri, 15 Nov 2024 12:42:17 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=g4lhvb8C2OfyVjOD4h8GKh1wFOBJ6R0iZcQUPnrOE70=; b= eHeNEwDyHA1FnAh+7g30wMpTzIVgdYl86Meq4pYUnKNVffC/gAxRaTiA0/0VwogP hHHR3ancXaWDs1b49m4r0BqabSz9BbkSu6rhYQIV0OFeTwn/JTbSoJE8EW8e/9+m lh19PUFllyDikXIOFNoKKg1+aN5FCd+doT9FTXIEeGtSQ0Ew3n/idmKj7qAoDNIs I0MYUs6l/Y00WzDi+v2UdrCjk8BgrL4WVAuFeo9uUfDYfexnfDVIh12INiwa74Q7 Gy3TW3I6BDF0Im4IM6E/PlZEZMDEFr6OAwN5Ra1j7fwqB5p7dcuInnB71d6o6sX7 JyGM5SF9vT8JL8m6y7iwCQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0heu6hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:42:16 +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 4AFCXkje035901; Fri, 15 Nov 2024 12:42:16 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6c564r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:42:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WKM5cc4BHUimTlsO2Vistlhqcvx1h8AgDf904X/v7HW1Hrbzl72b42TlMUPFuB5MaaFo1N+j0sUsAjzkNNHFidtVPc/GE8KX1panlfoySf/wRqxaf/A/1kdRmOXwFIt30egLQlqXIB1TzwY4z1w6rjsN7nBmgcK1EDJzD8CMG9CCU25enlH9mHhQJFRO3RL6dUhR5j4TJFVFk2L0n54T9O7e8JeA5Y7lxEsCe+pMNXW+pAZ7+ELxIOj6pjrJxrKLHmpWe1EoAXEHJonuJpVFy0ujK3cLQ7rz+yTFp+Nysz6Zmw7uEAOr3fg9xNjmv9lI+Q/zEwa+bH3pEqwcwlWSog== 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=g4lhvb8C2OfyVjOD4h8GKh1wFOBJ6R0iZcQUPnrOE70=; b=KonPrnKZ/9ZWQs0AVCfjkC8pb/gFoZYQxvbxv4lpNK30SC5Mdd+DUJZUEgiJap2C4eyymPcum3sO+5gnWTXhrxSvXaolMs+6jqVjrU2qSykwdLnwp/ph1JsWwvSHi85IT9yTCFEeRDNJIOI3Au/3LcLOHCRo0RR9hAF40RoQixogheq/w4i1YTBU9yDX/0gm/c+KOQ5XwQ9oXsZsOVSK98sotVByVDYR+/wyxEay1vkTgcuAMs47oJfd3RML4G58TWfUK01adNPBkBegwsKsPw9xiqxg4NCyMojyvd1fHFUfvjtU0yfkOAQoenzRH2FCA/GWkHY0TpRkLch+112dGQ== 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=g4lhvb8C2OfyVjOD4h8GKh1wFOBJ6R0iZcQUPnrOE70=; b=tn2zave8udvICg63kGbBz5vOGKx7lVN23lfumr1EgXHi9utGkrp65CpByt5ednavMT8B1jbGNn2ngn/xuFq6xewuY9+V0iKfYt6cgzlK118jJ4rvaOZZDDMGl52wUuPEauXd1G23PfGH5ivyYJTDGhqEuNMbiL+nfEGqHr4MoiI= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by DM6PR10MB4201.namprd10.prod.outlook.com (2603:10b6:5:216::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Fri, 15 Nov 2024 12:42:13 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%7]) with mapi id 15.20.8137.027; Fri, 15 Nov 2024 12:42:13 +0000 From: Lorenzo Stoakes To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller Subject: [PATCH 6.6.y 3/5] mm: refactor map_deny_write_exec() Date: Fri, 15 Nov 2024 12:41:56 +0000 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0025.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ae::10) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|DM6PR10MB4201:EE_ X-MS-Office365-Filtering-Correlation-Id: 3907286c-3672-44f6-e2cd-08dd0572ed94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: SVg6jZPGWE+h/y74Q112aSiDJoUx5mcdcKRWuTLOibK5X2NCndx9lrtkEdm8g2N1Axf8I8OjetHITHNXLNxuNEo6AaOrHHmwvT73uPVqEW9sVPjrnh496WfwVWjjD3H94DXy2XWbcBRUOxwXOumHXegywJm1yKGKe1J+H0gmDNeERku4jSNFzxqY1WS6F2SpyImFb4Gh4dH5tu/mMIR97pdW4IauO3+i94YgNbMyLF5tcKpITgaQrmQ4np7sCRxc9TZIMv1iaFPsS9Pri794p7c/KwU3ZbQQDwpxr3axupymxeePQUunDizUQvIq2xq+uC7DyNFXKfPcqkNYcXXIrbx9a9DBeFHFr2UbIxIg6/PqYA2I7iKj3pJ3xLr0uGfrhhNtqm3phEVWkcYyJWs7LZlHTzl+JOWrn4+ZNWWwQGXcCuUW8j72Euo4MDvZxLC3X18MgoJoMNrRA1GK2FpOuaPc46uJpLF5AwhPhnzMsKCLyshL7YC0eyy1kh51TLDtwA8rBP0URgaPB0I9TeYG8v0FHjUe1QXo/V9j9jt6sWShoPRFoJW458Z5Nh/XyxcmHC7FxfFqgK/qX3pqyy1a0v7YPSZjBX4G0nO2CCsCCPat/Fn8j28oNr9WnYjvLt4pw3JHKRZ9askoVba+CIuph7NGsHW+3w03qzbA07Omg30UnJzmzdg9fGvxKWrz6odUAKJqaVb/aE3mi/+nqU9xVDn3UvtmnxovPU3wxK/63gK/3jH0LLcgD19paCWzL8O05E7RAT0Cw2JzdVKGR2WXq+OswCcGVFO0AMueX1FhI2ceh5YazNOxCwt1ox1p07AbvNqtxHAyGnfOupWZUS6TDmQz5XCut8pk9oglz34/MHrzNwppJ7Y8L7SyYJL534hyDQ6fYmAZUrznPDge0xcOUpNoiKjLohGIeUjb1FKnbT+1fUxqLdaiUm7brQA4h9mo7pzpHT8LimPYHyyOwN1kEP3Gl7g0vluPPEdUC4cz/hGpnVLrrznKWPpt1YnKE90XUaiV6WUW3gOX2jR3zkQDmuP59y2MS7qo7dOYaj3dLD2mob79TuPUPjgueg7mxiBkHoljjqYpitsjXibSkl1CYGVU2P0lOjJeuLYZLP41Y7k/yM27/fS/oRIOBKWeSLf7R/C6YZI0A7G68lKiJqzsc2o/KCS+L+NIypNWeqbrTy79cjIDaM/iTUf4OxaMiXMBnaDicD020lXI8IkUm6kOSvzRmKMkGVzpVC7890VmbNKXn5ZsLr9tWG9s8n38kVeW5AuQye+wYku6MA3giL/9bQNkNT1DgpX8c8bVGviSZNl2OK/VrB818E9f8ROFAAT7 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 04qYkFAIkscjJsrbWSRYQBOZ+ou+38D1jCxxM0m+VCbdxmBnvfFpPSmJEUw60m9Z1XnyNTMwJtoYLo8QAfaMsQerIKLSqx+3F8Pxn4KWwmrHExCobNv2gQhM2cWYAyMCOOnwhzedN80TVKEPugtEdNqmg8EsSdu/OchrTy8wXXKhLZvATg8yzU/ooa40PKQL2eWX0qRQdmM+0IPcIGnFImN2MZLXh1yEpZnTAwFbVRnvkJFeqK2keN2yxQMSoqP6QzfJZ0OGxncuXkaOa1hwQT3d4KWa1oqOp5dd85GnxixJefN1V5iCdiFc2YLfxs1Ny+XGOPa+cqn4yODBVX3m4+4Fh/UpdU6XX8CVVnnTjYMSVjF0VF8GOewVCtxQ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cCHBC2p5cvZ2wJ1QdM8CwLVAPOZsOP7cRRPaOos2O/2okJWTWe+olGfWIdIrUiu+5RWNDNPPs/nbEViAU8l+6Hl3gUYRHjP6UP+opgcbEncx9m8Vftuls3Ul5ESKw5a/dD0YmqXEqBacKxNpPVwAAWuKAv6dQR+a6iVNQtf1704Xx9g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rNkA7EFuysRf/8MsF3LgfNc/yhctiIdQ+qdU3ndOUlJsHEGgDvQjBa1X1KfamlZezCshfZLkZO/XRAwTfPDEbVa+gsL6GuK9bVExFEk3PWP1J5lk94pXsVn3gXt7kTZJbkTEpXsewRYB5wwkYEbCShHxOu1Fgop9ISMF4t88ApHFNJ8ccvLpytW6CV1FHdCnE3iCzjER2ig9CVvFWXjKXM8DjTDG54kvMV5XNkmGI71uuD+2aRdeNQBdybypX4PIP90CPbahR3SpHJb5tci68EDBomjBwiUU1CKZWHRs8bwIv/Fc9pSgDiEtBznsY6MmN+MmXyOVT/fsG6LzRCCYU/LmvE+sAWuOEOliYRkaEV5wTMLBysYXlTlfiXXP5BeYidVibvMVLyjQOwMaASUQqot8YLjveDJ1Ew/2mI5fTnQykfRsa0Qt2pkOGkzEyFc6vtFeU4dmeUbLwNx+lxHaDB334RYZv00qBORPpTg4mpxDWPUDdkNwjoHmy3xWq7oP2zvQTQZYO13zYL0mrATcUt2qGx+QBWdjuwX9CgzWTtyV+ZSj6CRa+Ak7W1W2Rs6Uh2+jXdpUOXrPP8A59k56pTHguuLcsKrsZNr3yc95fWM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3907286c-3672-44f6-e2cd-08dd0572ed94 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 12:42:12.9396 (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: W1eetwGaqOXKQ+UyOlevgfW3NYlK212Zys3177vU/jbfs7Fhv1ZaV4poBOqN9AEUgqc9f2+wTmKP4+MoPuiMTRtw0VqGExsLYdUeKrNObcU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-14_05,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411150108 X-Proofpoint-ORIG-GUID: DsbnIAcLJnyFsgQ79_RAcNtzr-Zl73-N X-Proofpoint-GUID: DsbnIAcLJnyFsgQ79_RAcNtzr-Zl73-N X-Stat-Signature: rpcefaye8ckwrs9knwq1q39ae7iin6ku X-Rspamd-Queue-Id: 981191A0008 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1731674491-529217 X-HE-Meta: U2FsdGVkX18aFM42Gw2vCn/S6Dsk4HPzw5V8coYKe1f0pcmslFCfjvJGnsy5oeInssLKNae/29tSTQRaBIX2S0r7/u6IGWUNN5y28jB3mTKD3Li9oBWkr88AonULIUXk5bNjDT4/C/+bEPA04bQYew2jV55g5iBbCE9oesP2+B65K1CA6xQDfo65scDxNCnY8sdYt8B2ssad/SWz4yESRVub6mYASerFk/cPddq4RwexzALdHnfbfCZ/ILvxtWpBwJYj1k7SFQQMmuEZxGjDcBplP+uPofgE0JKrFPK0iP5FAQUsX/Fj1+B8S3L7VyI+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We4z2BHq2Vvy//mvqenJ6zxp4gva4Fw62YzdrmHvmTX+b6VKIzJbsIibuFS9HU4lR0RgcbYlsulHVHjOX+++eHwIh7VjQ8FPn3sY3esl3fitOX5I5zKbanL2rcThiMBnO7VbTUr781cOP7FsZeU0eUXlypc+JaZQP0sB9+GwgMmlo7oFJUU1Is48Ea+EALVOFQux3EeVWwyqnlsw92y1ESZTzzlF6HDP7uTJVeS/CXyxjLexbkNBHHS+wTk9/HefJcLEmavEEXx+j52s588PfhkwbZ4QQAUJe1naWN7tdO9WZHs0Gsq/TeGXbvFjLqpPDLVm2eqXTMwQQC9OLw6doV8B8gAYgEp7bGMMbLb92DfmktkF2HCGea2aMPwXy8recxlSD1QugXQuOF7ghP2ggGy3Yel7Xv1QccQZSXoZ1qpoxY1ifiTG5FgaY0y9ygWLRWsbFy2xml1ke5flZMnHvcPIMjCyri6CpApc0hyR0lurldtly+13vmQSA/1IuwDuQ3yFa7w3R6vqrIDHFdu2vBi0T/k3aWxHnIqT9DBCTtqlV7HhiaRKFVmBX6+WLRPMKL9qsK7ZQlivJ s2irszg4 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: [ Upstream commit 0fb4a7ad270b3b209e510eb9dc5b07bf02b7edaf ] Refactor the map_deny_write_exec() to not unnecessarily require a VMA parameter but rather to accept VMA flags parameters, which allows us to use this function early in mmap_region() in a subsequent commit. While we're here, we refactor the function to be more readable and add some additional documentation. Link: https://lkml.kernel.org/r/6be8bb59cd7c68006ebb006eb9d8dc27104b1f70.1730224667.git.lorenzo.stoakes@oracle.com Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails") Signed-off-by: Lorenzo Stoakes Reported-by: Jann Horn Reviewed-by: Liam R. Howlett Reviewed-by: Vlastimil Babka Reviewed-by: Jann Horn Cc: Andreas Larsson Cc: Catalin Marinas Cc: David S. Miller Cc: Helge Deller Cc: James E.J. Bottomley Cc: Linus Torvalds Cc: Mark Brown Cc: Peter Xu Cc: Will Deacon Cc: Signed-off-by: Andrew Morton Signed-off-by: Lorenzo Stoakes --- include/linux/mman.h | 21 ++++++++++++++++++--- mm/mmap.c | 2 +- mm/mprotect.c | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/linux/mman.h b/include/linux/mman.h index db4741007bef..651705c2bf47 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -187,16 +187,31 @@ static inline bool arch_memory_deny_write_exec_supported(void) * * 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(struct vm_area_struct *vma, unsigned long vm_flags) +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 ((vm_flags & VM_EXEC) && (vm_flags & VM_WRITE)) + /* 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; - if (!(vma->vm_flags & VM_EXEC) && (vm_flags & VM_EXEC)) + /* ...nor previously non-executable VMAs becoming executable. */ + if (!(old & VM_EXEC)) return true; return false; diff --git a/mm/mmap.c b/mm/mmap.c index 9fefd13640d1..d71ac65563b2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2826,7 +2826,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vma_set_anonymous(vma); } - if (map_deny_write_exec(vma, vma->vm_flags)) { + if (map_deny_write_exec(vma->vm_flags, vma->vm_flags)) { error = -EACCES; goto close_and_free_vma; } diff --git a/mm/mprotect.c b/mm/mprotect.c index b94fbb45d5c7..7e870a8c9402 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -791,7 +791,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, break; } - if (map_deny_write_exec(vma, newflags)) { + if (map_deny_write_exec(vma->vm_flags, newflags)) { error = -EACCES; break; }