From patchwork Wed Oct 23 20:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13847895 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 D3FF8CFA46A for ; Wed, 23 Oct 2024 20:39:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BA0B6B00AB; Wed, 23 Oct 2024 16:39:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5672B6B00AC; Wed, 23 Oct 2024 16:39:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 392D16B00AD; Wed, 23 Oct 2024 16:39:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 13E646B00AB for ; Wed, 23 Oct 2024 16:39:11 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8127D1C687B for ; Wed, 23 Oct 2024 20:38:50 +0000 (UTC) X-FDA: 82706030820.03.83BD241 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf01.hostedemail.com (Postfix) with ESMTP id 60E5E40022 for ; Wed, 23 Oct 2024 20:38:53 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="g/Noy20H"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="P7GtL/xO"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf01.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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729715796; 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=0rDE1LjjLhK0evyvP5sZKz477C4Wubbi+LdXiNbsMzY=; b=iFVv5AqsQZnvSKYGwl+HNJfdxefjMrshtEeprj9Q7/RhaXNcFPnUKB8FeEA4Z+c1OCNeli qnh3nZ9/Wuqpe/kk39ZkFjUAMr3bHrJbzbxsw+MVz6TdM2DCmCvvNnYPzcObnRVceKo+Iy O+HKSEXxIfGqEag8iPLpUDpWF0jlpDk= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1729715796; a=rsa-sha256; cv=pass; b=cDeByD+oL5swRq/mnKksfmNCPYf8CTf2InTC/4qKtHLJM59QrUvEau8IAFNrpuc7rcVCQT /J959lgB75rsmNzu7PfOwkRedjbAd9xXGbQkHqFNRx5jeFYnm9zmD4Y6a/VGov2VSBh8ds nXvqrl0iZg6BtIga5govZlijwKFmdZs= ARC-Authentication-Results: i=2; imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="g/Noy20H"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="P7GtL/xO"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf01.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 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 49NKd40K032473; Wed, 23 Oct 2024 20:39:04 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=0rDE1LjjLhK0evyvP5sZKz477C4Wubbi+LdXiNbsMzY=; b= g/Noy20HV5Dd8HzkCO2gi2P98GR09+Nti773nFRj0swO5hRJEEkl0SICGDuR1yjN x/usyNE+3+l+7NEcGAyW3WTxUYkbTxRyxxKngGPVWWB3l5hgvon9PjQRID0MjbUo xSHT1qcTGY8BfiIwYe7s3AfeF4XfJji1qydmljWleGKqNrpyn9bMte0I1JY5Idyj Dr1Oo0TikhDPax6Wvf8V03xJ1Nf+pBxczlKyn/51oE3gdMlJYUew/Y0J/pdKvc+H 2H2WCXUyTJf3r43N43a8h9C7lGxdgK/osAd0diCn/I3AfAktW2LxUBuHT++5TDiY wnbw26zHdUfUfYMxoPCxYg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c53us4cs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2024 20:39:04 +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 49NJk0V1025440; Wed, 23 Oct 2024 20:39:03 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2045.outbound.protection.outlook.com [104.47.74.45]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42emha1aka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2024 20:39:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ukZhib82aRZmQFL9/FpnX8fp81MEqcz9CbalGwf7886y12xhvVJvcpSHdUed1wD9ciTeCtRIZqNWb1vhxpVEDzZqCZBuwEYNU1/+5gvXXwJWSGeztD+nrDqkC6kjhWmp2JpuqDpciKDv/ZZjNY3z7l4UThhJF42xreW4qik19ewin18LRVqle6xY95CtJc3Zo6vCmzWSGlPPWMCM5qrfiM2GrTdfqyEuATs94sceLFvZOGeqHfPfRFkHX6pQtGGoiVfANsVzQ2y2AgWtlMhkaTFPpolKOobK7GuhNouZBtMrhEtbO8+ALQDB1b4xeMDBSmwxJzR1//p3KpSfJokBlQ== 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=0rDE1LjjLhK0evyvP5sZKz477C4Wubbi+LdXiNbsMzY=; b=o1Ae8zZ0NQ/8Z49B3jS29y0ofG6GPNoy8MH6dFi+pIW8PwByde3ZdEq9qLymOJnMcu9t8aXEA3oLtJHXQY3G29pXNKsufZEnl6QmJgOOu81c/S2BI6BMyb9MQnSagsCqShCYJKH5Ifv9CdyRHQooDY+9MlbjTm23Qzwmi9fRZIMMv1h0e7SyA+nIka+E3Tt2YgwvMHgvSmDQ/1/c76jTQV/Jgq22rU6u6CXGleTAu4wfPrbsUi76l72/T2DoHnvdedR1nK/d2vy/gNuyZ/yPVPY8apxtzO6KGY/C0MvIGisHm4MsCFlYPvqRAqrxAQtjXwV5+hbv+Cs8VbmKJmJdqg== 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=0rDE1LjjLhK0evyvP5sZKz477C4Wubbi+LdXiNbsMzY=; b=P7GtL/xOOyVCLqxowaVBS/nPBC2Fm5xAwRfacJaMVA60zd3mnd2DPFRomMh0QyN1sz7HwaMegoOuWjpcHaZPp+UR7fChpbHuSWyQ15MZodZUjA8Xxn9nMXlMk1Bvj8999hQRGgS/OP1+zyjaHao8JyOeoUXAWK77LSPolCws73s= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SJ0PR10MB5833.namprd10.prod.outlook.com (2603:10b6:a03:3ed::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Wed, 23 Oct 2024 20:39:00 +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.8069.024; Wed, 23 Oct 2024 20:39:00 +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 Subject: [PATCH hotfix 6.12 v2 3/8] mm: refactor map_deny_write_exec() Date: Wed, 23 Oct 2024 21:38:28 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO0P265CA0006.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:355::17) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SJ0PR10MB5833:EE_ X-MS-Office365-Filtering-Correlation-Id: b00151d5-ffde-4ec8-a869-08dcf3a2b989 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|10070799003; X-Microsoft-Antispam-Message-Info: 3KII73MuJfN9qT1zp5XFQbPmvQVTagMFSElgtq9NteCNqzfw1sA/KE4MpILEWNo3DMdYQL6t1xfu4W4GJCWTp6pDWuaLG7OBOw/yIiQJSuzrT0LV+QjB1k78s80bjeJ9awBfmgmg6XdAd/5xiw0ah/IwB2wUgj7Kjz0P//MmyCO9JtQJ5Xj7N9tJjrwK5CmEIDfPOF5ZEOvbTvvP1wwNa3IMhXDy4XxRRyudlSey0idNxx+t5e9l0A4juf4ewwzezC3PNYGpLStP5jGvWoglXgBd+Nld/Gz+8ZYv0Kli1yXmPdJi5aCPv6nQNOgH7+fcLqpuBaYb6kThdVAmlBMabJxZTTXEiYz9gKWW8eMnpDY7Okn2VZK6V7791JdAz8PJnTaPUzHvQOks5rRmKg/iy/5Nie/8cw4kO0wsnSyp+tiiUVpiPMygQ6VwyyCFt3tDLjKq5vK6ALY9wx9/v691ZxsS/X5O5kPXV/reaPNs4drsZqnNfbL4adPlMGc2zE01Hjjo6vM1pEQYorMY6Glb27uON3sdSvIGm41Q0/K9358qp+4nXmllyharE6JF/SmTXsZGaWsP0DLky7FJyLjvu5vw9XWkuJjAlBgRrPgRCzbFB3ykzskl1lotGwFf4BF7P/kHSnyU1piiLa45GGYn1lHHNDa2qjF/NEugmjZ3Yt7igWSUazqn7oD3IFze6IsOY+u5gjE22f4UQeMnRDQ7s1OaGId8nTaJYAz2nbspv4FZFy8U9+6Ku+utI+LWp5KSIwCPk3U4nyQ+tXkT6d3hG4pLL7boixPGzE7yRj+4aAwdCjPpoaWpfwt1f/Jznv6v8KDp47N08lDZyBgOynEutU0iufm0NKhUByriF40OGpCAtIQVbOkpsseINT7DYnKB/wedASLsbLhqhypholQ8BxpaB7cHFWymubXDFWizLFZBJblHsj9XaNS+0PWZLY3BkLoV/Hppbay5U5LoSunAyPYX3tOu+MPoQuHetktVDsbTi6u93c7z6CU01STi190n/9+8uTYeAe/WM6Z9fBA5Gg9+84zsmApLkXqgguZ2YYtrdXK0nhHj4x4PgRX8ZkyRyy5Oh9h+Twcy0OQKutkP6QnhBnaxHFzgtMH0OVRAcoD/1JsH1SpB1MMayQLtnxB+j/UT/32UKAiZxmvEzUMUFpOjYWZ+QkdJWA0xmTu1VofNqoWCStiSva4jk5reu9ZiWBJQV48hVg1lzxnDRPVg0EXq5Pc+wiUxx5RTIUC0q/FioSGELkW3qYOZ828pWSwTuBB6etQa8mxcLNsUA3v1OYwbq0PgjTxwFuyNo5rooZ2SEExvLyzawxlGRllHhJKZ 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)(366016)(1800799024)(376014)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Zdr+XzLVmwsicy+us10ugEYhiO8in6ZhBsuapSYtVC4/6QEKzFCbBG9maceT4qfs+oHXHAgiISlqUJS6KRpbCA40tAbAqqJ4dHiDPzV0/BaAKn+mLRmi6XC4y7YIqPdX15AvI1bBGc+hqBio5ZgBV7+naYrvFzsWt7uoWUvRLOA9VpV7xhxaq7e1qjpGcC0U2bdHzvfR7o/QpJtypUDhFTBU27ZpWHTUkSK+BvNZtUmsvQ01gF3rFyh7WhHHLDWCk2Vlp8HTsHFYopJGYdcv8+Cm47b/0dn2Evy0oVQS8dtvTE3QGTaid+OP2OQdduQ+HK5Ys9p8wmahXQ2H4zEa24gmrUqY8HtI57RcQBdWWZr1kXgfNb6M0snEfINVoL/SuXATpbfWV6/FdY0oLda+ggkoMBWhBLs1/XBmeNt8TgoJYneSVETOsi9svLsnQU4gBKCBKMQ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TJo7+IMvlCkZW8dshjJVgncKsI3UeyiMm0FuJi4IU4+uER0go75bfqkOSCi20AssNR0nTcApnWbPY+/ZmE14P5Xw9OWJEYvMaQ2vZU0mDEQCNMSgDPUBZiNCrRGsOnA3sT6M1n57vPJcaFtfk5RTDv0Spff4Uw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ur3x4okU2WYLZJyUQ2s5URPO5LYOc5/m15FdUdQJkqpUSb4zMYH2ZkgiuZbQrghSy6qw+cDUAzv4OBu9NIX1kY6tCLl8YR+EwQZgRA3002rDxymZzlyYkKJGy0i5n76bap4fC2Lw3XSyDpbY8toXt89p9LjoaC4hg6UeeRt2yQy1AjuGTEAhBj+lBMicbdyXU3D3sFnuUhOIdFNsyxOSf1rp0MsgtcO7mgJwKAvS1z4pwRbh2r/S3ZAcxv+T9MMj+AwWedns0obFi37jUgblElq+Sb18cvriz35k24UFHPUBD6fqj3rDgzEyAcYBm9TQkGdYh+AFdxQZ9jqZ5n4tIG6RLL50hHk3lHhuKBphYsNKUz99SGTpnU69/8OhArb17upMFSipedV6Tn5umwfe8hg2/6OQLM19yFU4BYVm6pRHbCiKAnAGaVfi3o4ihLOA/h/A4rujEvpdqoa+dqAmPyQmNPW5/P5T+5cZ1ra2TTnSbYLRj08bRgayq75aVfjrvRQ+/D2nTm5fmhLWJbx4V5UbQUEkDXcYZM5IWPq2bnlH3SRY0QUXPXP8fSoapX06PVrI2BTNi10NjxuXDvTin/R8OHm0Rc/1NfMSZb6RGyg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b00151d5-ffde-4ec8-a869-08dcf3a2b989 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 20:39:00.3846 (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: xF6uWvu602bfRFdFB2BKx9MRQ/tLrwtBFrcx+TWAECQqV7oYMd3ivopAVSPiBSRYFiA3dmfQjp+BSnowM5Q2MbPF7/Ol3kBD3ii2InxYBRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5833 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-23_16,2024-10-23_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxscore=0 bulkscore=0 mlxlogscore=927 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410230132 X-Proofpoint-GUID: zAz0mEDJK1N6tTkXJSG4x5pi-wPazSyK X-Proofpoint-ORIG-GUID: zAz0mEDJK1N6tTkXJSG4x5pi-wPazSyK X-Rspamd-Queue-Id: 60E5E40022 X-Stat-Signature: cuy6scs3yk5s7jgnfbii1ytoss1r6qgz X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729715933-275159 X-HE-Meta: U2FsdGVkX1/ZIINZG+NYzl7WaECxppO40i5nCSJHBt1sCVKi0ILhZa6YTvhR8HR1MD/uPmF4/TAGOZiEhcgMsibYPQCeI/xpTKA6TQ+hn4q89KNc9LAACuFH0kejJo3ZG0Z0Sd2bK5Ab+qabNTSumrMqbn3DpY/PC7bfmbDqXo7hR06vd4cd7SGt4FiwY4Xg+y2dRO89UFw9pJdJmVY0YfnCzgf9yeYz05EqkUY/NGAJ+dB5RaPD4P2kE5irsJe2jbJn5pifoMQdk0NR8DpHyL4XAu54gUgQJkyM41zdQnf1c4I1fgQLmF5ozbS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bIRoLhVBQIIRTOVf6+DQ923m2PxVqM+3lMn6GI268ocUUTFv3rUzE2kUHsCvf3Tu/FalWZBLA372Y/dJhT0f7KlwbsS6kzuCrAqNwVCcaglmvTriIYE2MN817SirLXGYBqVfFaiaBHO2Id646I15Q/wRuY3e4nadjV4AxzNs5B2AR/HwtWK/0wTs6EeI3pB6dqDjwUDtx02g6jL9qRL+eg= 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 d55c58e99a54..66edf0ebba94 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1508,7 +1508,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 */