From patchwork Tue Oct 22 20:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13846149 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 6F9A5CDD0F4 for ; Tue, 22 Oct 2024 20:41:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E02CD8D0003; Tue, 22 Oct 2024 16:41:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB0DE8D0001; Tue, 22 Oct 2024 16:41:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8E988D0003; Tue, 22 Oct 2024 16:41:25 -0400 (EDT) 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 994CF8D0001 for ; Tue, 22 Oct 2024 16:41:25 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3F50A1A04CF for ; Tue, 22 Oct 2024 20:40:55 +0000 (UTC) X-FDA: 82702408362.29.9E6E2D8 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf16.hostedemail.com (Postfix) with ESMTP id A4F2118000A for ; Tue, 22 Oct 2024 20:41:05 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=aB9G1H7O; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=u7QE0iUf; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf16.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=1729629515; 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=e34AEHAMhHEQASKV1R/2I3fLJ9/l6ehQMuhQiU5tCX8=; b=tyxd/gZN7zDEoK+d5EttWICk8EY8aGPVKTLrloIJ5fly2UpLvt6pJnZqMmqHYE6NswU0I5 Ryci/qP7CWECCDVf1X+sNcQwNV5mSSoR/tFO38Sxb9aBtZW2NKUjFaI+Y43LOtAFWwVykx WFLLRWWMfOA1bdT2To8pXA+05Nx0YKo= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1729629515; a=rsa-sha256; cv=pass; b=3I50zFdsiglksSraxQl6GlLrLBKMjvf79jwHP3LcJRZhIrSQxwowRdzov3zDHVlNC5Q95e Uz2zWq16boclZCFRYYHY1F7HCiyjtosK0u4aX4jfTfsxywfBwLwf0qL6iE5LVfsWZJsxji ajFGYM9Fbbtd9WeYIu7CovLjAw7iEUA= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=aB9G1H7O; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=u7QE0iUf; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf16.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") Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49MK3XG7025798; Tue, 22 Oct 2024 20:41:20 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=e34AEHAMhHEQASKV1R/2I3fLJ9/l6ehQMuhQiU5tCX8=; b= aB9G1H7OBEbDW8H01Vv8nphGJm1lsMifIVg9ELbFFvjeJ81a8wA4FEdx5jsnwgk1 PN2B1zSr5WUt4MBaMfHBvyfMbZEESNEbWofgra2aiVmBkFVMWbQOXZjygrewXmKf hK7pG53idv6m4aXl9lr+5mlgeUb1NU5FdzLLBCk+RGumJkbC4A3fvHpyAGMpMvrV aW/ZW5ZYtPA9Q2upEntenUirFdss7DxGSOiKgNw1pym+24fxkf4cHdfmshw6KEAu cEJxLmWT8ttIV0Asj/23H9VUV/vOn+18Ftps5cH/VdknCkmYJuTtgtKWc0tFn7z+ A01Yc8jPgutIWOAZlZFRYw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c57qendq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 20:41:19 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49MIoKGl022660; Tue, 22 Oct 2024 20:41:19 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42c8ew34a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2024 20:41:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F4WPXWYz03hWe3vlZnQ65HCuHk9NWxQ8CTaH+pO9j3n1C0HKu++MpXV9qshcDWvaWwvimB+lq5Xim/0ZQ7LtSZlNbNdheF9b80yBEeQ+TtDxHU+Lq4/RSMf0a3gceMslcbXdlnJ9YHp5DiB12ZamrLNzHrc7ogfnshRaijwSYllb/Wp8gt5fY/fio1L9CCRjkT/bHYqL6nz+lAEuVH3DzwICZESWKq0ku3H+ajDou7cTlPBgni6aZut3kx+1RHzud9cvKG5bTDMRQt6ChGvauRMgCcmt7t9B10aAHcGhmboslE5WiQV+U8LJOcVkJ48KSg8QFQG2VP010F3g2JZS+g== 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=e34AEHAMhHEQASKV1R/2I3fLJ9/l6ehQMuhQiU5tCX8=; b=nutyY0oz+Qqec4+zZcn1sOz/G7tJyONM4fRgPGw2ye34LMIKHFFn+5ok5m4C2392hZ9Q0hj1F09QHxZYqv8c7r1sqVaMGAliWGRpf1IRp+TtQua0pKl0OjvQuWJJKTlx1xpMfwRIjxk6oHVCMCOyzwSR8GrXbnJ28YfCYJGKqpkUT4cM4UT1I4c6O9+bqPdMD7q1GHq84tZj02AcyhrrWwLXhlVw+LGzjbo/OG2dpT0AoZlma03hoGfqKn2belfefywVmcmrgWW7NGhx2040tUL9+TpIbkqISgg5g5rM0Z6GP1imZjuXTWPTEoZJrRL5Pz+peLdbCrjaS/N7R3feig== 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=e34AEHAMhHEQASKV1R/2I3fLJ9/l6ehQMuhQiU5tCX8=; b=u7QE0iUf4/7EINHeCJQSJvz+rMV4tPGFkFZa8coisXNVjEV2iiCyf6Mt9wY3e3nmCKc9ypXOaNtd8GQBACrOjr+UFHZnMGSkA5CfKVXuoSk0ZF0pY0bx4dz72TCxc/9fNk6A+jxkj+TfZoCVBmp1DuY2uQ2QcRDH/m93+dPACrk= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by CH0PR10MB7437.namprd10.prod.outlook.com (2603:10b6:610:193::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 20:41:16 +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; Tue, 22 Oct 2024 20:41:16 +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 3/8] mm: refactor map_deny_write_exec() Date: Tue, 22 Oct 2024 21:40:54 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO6P123CA0042.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:2fe::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_|CH0PR10MB7437:EE_ X-MS-Office365-Filtering-Correlation-Id: 1694ec98-4a0b-46b6-4121-08dcf2d9dff8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: iNB1fbNOqFArCB/MHYwHXYvPo4K6+0FIBNdHXU3Odw2cSMfiSPp/jvIyW4JkUj+fp2OvXcubLIlxUctbDUlq/uAc0VA06WKBUGavp5HsjZlUSXGDyq5BCj2uwEJyAEbQX2xMK3GN5+bNk9inYjajPzsLJETpP12TjWNBeOGT+pC84NxZkEC0/0U0nUy34nik46GYb3AY1t5hERIx4e1k7nT+xQJrl+fyqwUj079K9lUM+WzeeuM/OYwyvRM0mstvSlNAEn9v+ScVKmO/QQrl7EQLt5+Vem+RopA6D8HX2Nw43FK9cvZ2JHkQlapM2Nn6egZxE4PDZTjf6NiRfq3CD44DNFEd5RP24bPjR5tU1xN46BrHYniaBHXuA7viWG8JDzj0r/RYxBQmdmX1tJnS3CQmbMp6S/Ide3CPJggyiZfTeNL9Gm5K5fTGnEjtPUv8Tu17gRxRUntN0op52pFMd/Y8LUbtGNBFFikR7a/04DsVrUKeUSUEWXH0s4wkZarHY5E5RXOeJTO6rMVFHMCWk1K+vNTxBABoz9tae6ZQ/+JSEdCP6m/0GOqDV3bluRPp4NulidqBL/PxunXdJaJyKVtRn9Kpm7DCDJo7qQX6g3xcFZWZ/nw6gmIseuhWPyakj6A+I36afIWyfJ0Umt09kljwoWJ2MLwfjHGBcDParrx3fLWBraSfODGGu9osnQ0wSZtldoShTmn5io3wHR0qooAaa6DkRPAtdrWkYVDiLPTFfYQg5J/X5uysZLf7P5aHGDTHeRuUqmX7DGyKZwbsSdHdvIBu2AK6gHnnFaqkBK6HGZ9XVuEIzivZIcOHUwS+sOf6Z9x1IzQj1D327SmPbsBPe8yWhRXEjJ+s7sqisKRzUXFtZDKJU8KqmeibDwPt60JJ00Lbi7woIENpJZFmXv9KdyY46TXIoSXVu6QRa8PbTFw4QUZZVO53wHFMn7mPFYGh/xpb8QVtBiJbJWUxZUGwgsKJiF18SZVqvLBSIxJud/tRZfdG/zA6DIOL0UMD/fwACaVbYFlbtiUvE+MhDxbpOVi5dH600cwe1/Adre4Wl/wgrn44lUPsF/7SlDD2DR2PuL81qDR2jlIA3N/Uqu8N4PN9LGGb6ssbaxShSobryQKcGzzV9bUNJ0ucaSVCtDWxi4pfMq7uHSImQJXHGBShCcPTwdk3apkFBHxXQ6uVdUlmQr+S6BXIC3Qw1Ze+vqQ4t/FckGroq0bpAFrdC2+thVeuXnxgQinHy1syQrj4wbvz88/S0WF+bVa6xwMW/XNbSh90K6nxjSuwDUmizYOpIZwJrpjwICgrKXDuhXHdZAD8w545shYPiaotec8n 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)(10070799003)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GAEs2oRJ9cb6A6wsNcJ/1ftn6B28ju7DBUXqGo6hzRMDIitM/5IM5SVQDTPNRqdzrBXebKXfytU1QIlwRgUiVHbreCIYitwWm+YFatCe01Tj1baCwrnUWkLrrQgESUOiCxmF3thGHk3/W1v/zgiXi7VInOX/vjYCo68WNnmIp97zoiuxsT+6h7Sx9YjmhMz7UvQyE0C7JoiY0FmYIODK9CBeY4dnExFn+M+T20S4XlEGoa1cLrQMYtms4Wn+Qvzx+AegOb3uvtqL0mGRZYVS3JMkQNGKM/Kk79/Uk7CWoghSQME3N7Fpk5hdyXCp9D3AW3XKVZbztmco7E770cwiZsl1fbSv/9C2icK4MJe/o/Qm2X4NmS7oJrhCjtiTpwVTKLh0GcYDwZN8aewlIM6w3BzUVsHeaDRVuXAaE+q1MnSbKrCUtuA9ekUBeZ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i9nEdDjrRqkPiRO2zvd1s/JHJmZodbrpCL4TdJkiiDAuNo1Aksly3ghcfSjdjwXUdX7uQvD0KQDxvZtY7t0I6IY+VEil4pKwSxTNpH1uxv0Krrs4cB+zYOikNZHWixSwN7F+A/BIvy2/e5pG9Gz/uPQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 53v0TyjhEQo5d7mfSguNh+Ln2v8xmOyuc034sCvZWD0xbfzMJaaB5zl1dlCfKHKFsWgUFdR+70MWzhv1GYcsL8Yh6Fin37tJu2fq+8f9Sij93DrA7oi54t1SBMAfnO0YHiR2uPW5A3mz8lia9Z0iUNS7JsC1hQalFcEn8PUaQBU+yVnVoqTmZ//ZymIzlubicf1wxwVbhpiagEbMJ0MR7lqJPXtnZ4Om++E58IE14+EZxAlfQIEvzFZ5CpAAYyhLtcj8exJUFCsUm2N4GVYEV2PapTCcFcls9cJ0M9sIeQWJ7MTtjlH4gL3Nl8dL9dQgnyq22B3JcSBSNPR/fR5DBtpuX2c2Mx+QIT82Ql+LXnA2Slo6WYHefmV8LWxCqmTpCz31gXq305YLLgyHu7JzO3nRfeLMSLMpunljgSPr2t7L5GmIZOwU2AW2/amLyQDpa7BNUWgnvu39FUV5i8RGM6ZfMD/nHlwpWoMCqq2gcrMdI3MyiDNj6M365PrBKecJJ9orjksMY4eOav4y2eznM/eQ+lSQI6E9Lz5oW+BH0Pn4gsGyYY1bAKiCmHuzsVlfKZ8KX06aDDDeSInuItOitKkfuqrSPOEY6gza/+/46Oc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1694ec98-4a0b-46b6-4121-08dcf2d9dff8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 20:41:16.2030 (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: /dIBKnR+sLk9fNlRTmE+b4te/3o03spUBU8Rd+p1qxmtdDhiLciTVDdIPAq1fXg97GrZrA/7FIfDM24n1gw0TmFb/1nTmoF1Jo50He/+SoI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7437 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-22_21,2024-10-22_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=979 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410220134 X-Proofpoint-ORIG-GUID: rZgmdcJBQiJr_qbbFFJtO5VJevnX5oaw X-Proofpoint-GUID: rZgmdcJBQiJr_qbbFFJtO5VJevnX5oaw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A4F2118000A X-Stat-Signature: rt654ccpy9ddrhjn6frzyrauugcxpaxs X-Rspam-User: X-HE-Tag: 1729629665-976114 X-HE-Meta: U2FsdGVkX18Q4eI9XvQ7Bd1kcFWtmLK533yXqsjJ3a9sXRFXuzhpq1KYZizrD/Yp3yp3TAtyBb3fB0GDzU8zFsoQylR6n3rJnrw5lOZkMqQ7Bq8oUCTnhw4OZPA4cQ5MUHPKNOGM3E9iEO9HDMv/S5/TXSFopGhxGLEWgsqeY9ItlxPCyrp6c0XZePyR9OYmjjCi5NVmB20PCcm/fFxkr0gu0kBIlKB2yujZfUGppE+U7E6qFxgtIS/Sd8U1Z9f00RQZY75z9QlIS/B4JIHM1nyxsaBtXLa7ifUxSRcJpyyZwAB7yoSGcafN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Ydp25YYLvDMQjjStk1y8fJyZ0xcgmU1hCRwDODvf4UQp4jTi4z4At/jW/QTyCZk4caL4kum4vrWLI6jMviBqaQYM4Rg7H3PbsfssdSiEcMnJ7p6IUMh/Ray2WxSFLibi2faciRXOd2ZLjCbx8tVZnvqSHuy8CHcpkU7pMF4nUPQ7Hvw6FymIvnod13ReR0UXh8k9XzhhILPt0Vg7Qy75uY5DLoTs5mrZm69tE3kk= 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 Signed-off-by: Lorenzo Stoakes Reviewed-by: Jann Horn Reviewed-by: Vlastimil Babka Reviewed-by: Liam R. Howlett --- include/linux/mman.h | 21 ++++++++++++++++++--- mm/mmap.c | 2 +- mm/mprotect.c | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) -- 2.47.0 diff --git a/include/linux/mman.h b/include/linux/mman.h index bcb201ab7a41..d71f83b821ef 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 absolutely do not accept writably executable... */ + if (new & VM_WRITE) return true; - if (!(vma->vm_flags & VM_EXEC) && (vm_flags & VM_EXEC)) + /* ...nor newly executable VMAs. */ + 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; }