From patchwork Tue Oct 29 13:03:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13854906 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 4A89ED2AB3C for ; Tue, 29 Oct 2024 13:04:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6A216B009C; Tue, 29 Oct 2024 09:04:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF2986B009D; Tue, 29 Oct 2024 09:04:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9829E6B009E; Tue, 29 Oct 2024 09:04:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7027B6B009C for ; Tue, 29 Oct 2024 09:04:24 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3BEA3413C6 for ; Tue, 29 Oct 2024 13:04:24 +0000 (UTC) X-FDA: 82726657104.09.07E9684 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf06.hostedemail.com (Postfix) with ESMTP id 5B339180014 for ; Tue, 29 Oct 2024 13:04:03 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hGR7SbAY; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VVw65DYo; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf06.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1730207006; a=rsa-sha256; cv=pass; b=TR0z0/4BVe0MsZxRSUef3rIoI9awvN2Rwu5MXSip6RD2EiTIqaDEBYFe4DOalLlPrLv7rH /neUHas79zMSfwmi6tJGQFgPwa9PNdYjU5NXd5xBZW3tl2qy7nADY6CN2i8K5LO+XzxmeC fLTDEacU4RP/7C5+2r3INk2t74BkRFo= ARC-Authentication-Results: i=2; imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hGR7SbAY; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VVw65DYo; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf06.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@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=1730207006; 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=gD3/8yFb/Fj1edTJvrvVzYBFOVmebuxOTpOZBoSXr+c=; b=NvvqQ6YZJF6ZkQf5mnvdcT/OmF48rbM3CarzpEKz0WNAJ/4rla5aJtpzFIqspoReBwKStg qp5QD8O2mrI0ogr0ohRqwRdXwf0j0piQ8szWQBs6MFzmeC9LwLUamARwpm+PySEpM1f55c 6+1Qa/KwfoS8dsDQWIC9eMXWIOT03Fk= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49TCcKNT008981; Tue, 29 Oct 2024 13:04:09 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=gD3/8yFb/Fj1edTJvrvVzYBFOVmebuxOTpOZBoSXr+c=; b= hGR7SbAYMxDh3M1qX8U0svAyjQcJZGsHZ+MjJqEkMjvoCw/ANiRT/icHDWZSzFiH Agla3FNwV8oA3T3wENHXm/HqE/l1py8mMEq1HBXq3mNGhjx0uffWFVvxJgKrNuom +2vPnvio9MK9UybP4J+oJhMEbl2GFBuDSCLIkqfCGel+O1mQK9SeoIFuV68NbNEU irdzJkWgwgrjVzncZxUMQ9OrWMHRRmo/6bDw7u8Y2WHrkUU0DMUwlk62LRMP2neU LaOLifB2HkkINRoXJAHK5g6fQEPwQWYzkV+L8uP7g3kUBl63YC0xXSNCLK2z8f2R 1mZHXBXUZgCcoThNTIstJw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grdqdaq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2024 13:04:06 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49TBxCZ4004774; Tue, 29 Oct 2024 13:04:05 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2042.outbound.protection.outlook.com [104.47.55.42]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42jb2u7hde-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2024 13:04:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VxOlTkGcF2Ms4OMTUeszaHUeUWyf/Zf21hfQo8iV+UhXQGGSBepkW0o6Vu8vNPwp5jbNeLalOMlQX0o5ZlZ9qJYZL4TzzSi6+m+n1K7UhXhSrWv8QVchCD69KSOKhRHDCkY5BUeIAHhKZ9lNR5a59J6+eqOVV7gUqFWaA1AZEPpqkEOrxqJiYa9H8C+yGbFS3/YJlIN03FbX0EJkppe9xNsSLFpaRzvWSrtMvPf1wUtW97m5KdD2cbUBgplhfeAN03CNyraZoXfCT8gtK89/PNOrT0PxlwKIt602sGOQ0tn+F4qzut263eJcAGRSyNe5x7NI2eraDbK1aviY0rix2g== 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=gD3/8yFb/Fj1edTJvrvVzYBFOVmebuxOTpOZBoSXr+c=; b=EQ3+RfQMDhompRNegaLk7cqmNCEIIg44uEhMTtd6FkiZV/EZ398wfdmtIwxXGNIE6o7idD0uE9fHH9n8Nzws38jb8bRGke69e/SSZCZ2zTShPEY1/3+3JFWNoXYwBPVNaWa5bHj4UdnRQ9DSTVJBJr4F03T3FpF2hGaxYu+F0vxkPEvPrS2i6KVvYo+UviM+Hs67qRGikuqCs0fkCNrMeIzAyNPdhvTUIXDrJjdxPVWWVp1F509sq7BhbxKjz121buq9F/MdbpW2TTmqb91lGHaGVbvFEPApCxx3ZVSGjGKaDXmDqINmRQiyXmWSYE5VbmRIZ6PssQgvtKCGf0xj7A== 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=gD3/8yFb/Fj1edTJvrvVzYBFOVmebuxOTpOZBoSXr+c=; b=VVw65DYoS6d8BRf6hvMiVktTZRrY2ROZE94t6TrvU+mFGMeAP04cF7+mv7uJ7AQXonZQ0NPVZLa38zvIvjV1G9Rj2we3n4Mb+O07Cje/LHQI07kwIg/Rh4LXEjHf6It+7X0HmJ5gVn5PAmufI4Ve36hsAgHDypytybsoUVzWlwA= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by MW4PR10MB6462.namprd10.prod.outlook.com (2603:10b6:303:213::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 13:04:02 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8093.027; Tue, 29 Oct 2024 13:04:02 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: "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 Subject: [PATCH hotfix 6.12 v3 3/5] mm: refactor map_deny_write_exec() Date: Tue, 29 Oct 2024 13:03:45 +0000 Message-ID: <6be8bb59cd7c68006ebb006eb9d8dc27104b1f70.1730206735.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO3P123CA0025.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:388::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_|MW4PR10MB6462:EE_ X-MS-Office365-Filtering-Correlation-Id: 49309bcf-0982-427e-5db4-08dcf81a2919 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: jP0e3JiIKN8e4TNSqJFA4A2PrXtfeBNV+mucPYORZMpaTdoSZKJODBxSc6EDREZSkOQOus64Xvz3Q043L1KY3kWEzgdq9qdeEkW/zutJLlruXMAWdR6XRuJhNSVlSGE4W+zk05dqJCamPfxZoGfRPb0h+nL6z8WnC8OpV/oKYiYMt9JryF89V64TtK0GyyYPecJGl07MeFa64BroA9OV05yb0E6HelzhOtvLt5G1/VQ4fyZurqP+oqtu1PdmT8hKppp3WKMnfw298CtH4ucVhl2/BNOqCc9L26CCEdBbamD5OaQFDrkaQ0m+vubuXaUFA6oFz0av4VD+iABxmgw7tRHxZgJ65PWwXYZkSROLZAw0X2kvm7RmDUel2rA9AE1GisEIdqTU4SIrW21TIzeowNQr97Ez4v1mFy3V8GWTwSmaVOpYpkT/1I6VDs7sm8Bp6uMEhEkumYmvY+awuXWv4meVZS+F19NLNSt7EGntBKKTX4cwe8RzmMUyY0ZMGAuiiFoQDa1mUJd6ySL4a3mWIbXpn7+mCUyVlS5Tk0rwA6GU9/+G4/yVVObpAMIut9TzK4d/X0GFdBAh5Cr1vFU437S2vo9uFw6UWBXEVRMMibc1x7+j2kbOhI/qPozxIdjro2rn56OM2p2USA/F5HT/p1eMqazqPIhDseL8D7vnu8pcq/gUG18EnVpdKNbHmCVZO9sT06Jr4OQSV4NNMwoWFn3BzxO4wb99FG2OJD1NepGPuZOkar2MOk/wFmLsCdmMVTjGNgPGB57Iu4JQUlbephcPBVSn+WkmRItOhmkez3tPvTOm+OBOIiJHyqYgXRagZ5uPFjxtl0p5zyXSIQ0Th1uT1sdoP4ywMbisp0prA/3dC4szvKMJwu/PlONUVxhVF1N23RzQ/TvqY3hIuevjOCt3WkSDtfJz6285g2YMN/JSUp3Ac10gGoCjw+CzBdD3G/2bCJkR8Zs108PDlyPY3xuVB8d8sjwCjMS7MavLqkfdf54Zl+96mUSTvsq7YwJX4xfV3QMVw3GpzYkRaIg6bAJ4ruMVgfZg3WuaXSnA1luUAGn+/45ZEhFFfzEt3piZXFX2Gb/D/Twmv50wnYNl6+wuwIG+P41M8F1LeUiEqnI9o1jHkcv7PT7mieKNH88N4Vw6NF4RU/Yi0ZxBCihD10PTBWo4fnIx9NGoHD82ON0CAAdAJqGtOIM63M23dWbVY4fp2tbhaOR9XbleJuIMaa7RVJcUq1AJfmyqkZQrR3f8kkBMg8d3BsxuP5GZL7z1Ah5ST4ehwQH0TJiSkOUqg3xcKV7DBmrpI0Z/b4StKl25KSCCsF4zmSbHpHIbiZFd 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)(7416014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FkY67PY9bnXC48FxNtWU+HmvhkTSmC1WtVoSxukFTFc/rVRbJNL+Q6xHzZh4WplpSHhiy5vApt3ihslfl+b9+ZaS7dzSGdfx73TZBWRExSJSHMqWlVdtZ09VxnlVCSwjz9M/udQB7En6fe4Y4HWux9me+Sd3WfyaBWG7vYqqyQ92sjQwNcUM9EHFK5PNtvJIQkBV29sIEbD36JQmdYul8Immz3Fa4uShlhen5L+8xHBJEGXs8T0vbgrjDew3HEu+VBEOwabttcJcRlVcL0ITtpiU236dq+UskfOpWGGNgAdeC7gjHkMHfuXwh0dk+l9IhHpqYTXx3X5FF3QEnupIInxFUL+t6CorQ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b6xRNNbkJpLe779G3J7Q4n717CJAF/bKC0kk2BY7+tHpLSUVVxlHNwSbtizMsAapOZjy6lSmUGIVFrLBvkvH7WZIGte866jUvWbPEtMfof3x7drj+QMW3EF16usPGVpiwDArRJFOiTwtD5O0yHoYRX28f/avVf9eV/Rq78z/+tgHt1LceKn1ihVjnuvw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YuRQhsa/yW+7s57V5zbDyoUmsbnSwgtiJyjjSoeCKhkkbEqDzNu3v+4Z0FmJGEanA/yP+cEohcT/I2t2vw00s/FTNxpFM46Tv1L7Zddio8vJoy/8JHRC9xvZnRxOBctMcu0zQskZGf28gC7kadS6Itp5+zIxiWvJZCWU1OslfZ3SXe1m4g9VG/cp7ssVlJIeQt3UfXPzO56QOk59RfDqXbp7rmT2iseqyNNauCtYYZ1WP+0sDAz6DoX5qcoT9U2gdtacEwyovNEPwroHX7nBu3RYihVdqb/KKOGO+CWQ3+g2OPGGAKYXFLRMuKMrvDO8sHG7ydcIwjp4wZdXii/kchgVc40eDmEMlhoErGG7u05Uuvc/JWtru9tal2tWcBu7k158sxc0q4BfS+ahcn+k60qejz97orbFTlmbHa0rHn/KTYIoWa7Io6Z04MbNTiYUriWBOgbeMJ5MFDV5W3tYQeuMBHFA0gjZXjwbzQ8v9Siy4gpOZgBl+cr+7l75WLkNvIGKBxB3XUBDIxj09xBlQz212/1ckWVAJ+8PUSngXWgzGhDtAzVR2Nx4yC3hS18UNTeFM+cCyojDycqx66iyuKuHhGGSLZrimG5fLmvWoks= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49309bcf-0982-427e-5db4-08dcf81a2919 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 13:04:02.5785 (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: 7Cr3qM2Xn03MM0wYqvQUbecOnPgxjS3APONPHefzKsx7NwdxqHN6ES0obWYn9elAlLqOSoBw4P8jGN/5cHjcxb90FKEbN2q+DmjkhaUknrI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6462 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-29_08,2024-10-29_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410290099 X-Proofpoint-GUID: yd--8GXVUFi8pe2mdqE4u1G8Y1cWvKSC X-Proofpoint-ORIG-GUID: yd--8GXVUFi8pe2mdqE4u1G8Y1cWvKSC X-Rspam-User: X-Rspamd-Queue-Id: 5B339180014 X-Rspamd-Server: rspam01 X-Stat-Signature: gmm5pokmmce9s64s88yc979rfpyqu3sr X-HE-Tag: 1730207043-289657 X-HE-Meta: U2FsdGVkX19NolUnK6bvsGLft8lJ3ZNLqwdRnT+YnPn9tDbmSfdL8YzmyZ5uYQCKrdh1ERszZnB0grUE8twhBV1HSTzRdPmWO8X4zaHvFHL9R5+86BVSp5wFEjZKLSkWJcT8MkNAA/je8YFT1hQr7SKaSJL+c8hPEQws6LuPX7Qz5TdqVk7YH+9kOQqtt7Vqm4XHEwwvpQIqYAEHXRWn10h8xAk7utb1ODZ7LsMMR1etX85yFkwEM3OkSkthNaAwzxxg1nFXD3ogKqEHZP5/4wLS53aYqWxVvKROWR6AFMEJP1Z9mAhr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veWvAMx+wmbjRJMNM/u5Q8pGqMUwgOC/xQXAyk4Ung8bhZH4O3QiKZkG2RlK3IueaShbS1w862eQcxIEMTsjelg3q9RR2OakILwpWbiisRbjr5h/b+47/YvRV/1Y3SG8p4eU5PZO2woKx/Zjw9f3w+Ru1+nY5Tbqb+vm9S/bQoUwAH5kzqcgwEe4G4/z1XpSVsot6NhDaWK0zF4iL2EFDBmxoKt375oO5Y= 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: 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. Reported-by: Jann Horn Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails") Cc: stable Reviewed-by: Liam R. Howlett Reviewed-by: Vlastimil Babka Reviewed-by: Jann Horn Signed-off-by: Lorenzo Stoakes --- include/linux/mman.h | 21 ++++++++++++++++++--- mm/mmap.c | 2 +- mm/mprotect.c | 2 +- mm/vma.h | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) -- 2.47.0 diff --git a/include/linux/mman.h b/include/linux/mman.h index bcb201ab7a41..8ddca62d6460 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -188,16 +188,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 ac0604f146f6..ab71d4c3464c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1505,7 +1505,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 0c5d6d06107d..6f450af3252e 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -810,7 +810,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; } diff --git a/mm/vma.h b/mm/vma.h index 75558b5e9c8c..d58068c0ff2e 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -42,7 +42,7 @@ struct vma_munmap_struct { int vma_count; /* Number of vmas that will be removed */ bool unlock; /* Unlock after the munmap */ bool clear_ptes; /* If there are outstanding PTE to be cleared */ - /* 1 byte hole */ + /* 2 byte hole */ unsigned long nr_pages; /* Number of pages being removed */ unsigned long locked_vm; /* Number of locked pages */ unsigned long nr_accounted; /* Number of VM_ACCOUNT pages */