From patchwork Tue Oct 29 18:11:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13855277 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 EADA0D3A678 for ; Tue, 29 Oct 2024 18:12:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73B1F6B009E; Tue, 29 Oct 2024 14:12:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C6BE6B009F; Tue, 29 Oct 2024 14:12:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4058B6B00A1; Tue, 29 Oct 2024 14:12:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 18DEC6B009E for ; Tue, 29 Oct 2024 14:12:41 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D28501403C6 for ; Tue, 29 Oct 2024 18:12:40 +0000 (UTC) X-FDA: 82727434566.30.46293E4 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf13.hostedemail.com (Postfix) with ESMTP id 9FA0120026 for ; Tue, 29 Oct 2024 18:12:11 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ncXCmrn8; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WlmeFrJF; spf=pass (imf13.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=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=1730225345; 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=Q3ZOlhuD9c0nXHh9tbGPEuiBzPsDGb420tWtzIN/Ex3WL+tswmUTWMIRNQ6DZkxPjHNc69 m6ETXtrtlDHvaBWpUHMvzRkAcle9CpJe3VC2JX8lHD+zoTB55RYwpMrYZ83tAByqDXfNoG Gn+MvbzqE32jIg7NqReWeNOQkjwkHV0= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ncXCmrn8; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WlmeFrJF; spf=pass (imf13.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=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1730225345; a=rsa-sha256; cv=pass; b=eldNzhbgtBeQVtpWvPpWoLXwGui7fHbz12YE17hqetKLoM0wPhUMTPNamjG55ziRveaFqa 7BjIVPATKPPOIsPvNd/qsPKH4WQHqWxFiCT/1IAtGq2O2/U4GY3dpoCCuuhIz8adJt6xd0 QeavPGbmwUAWT8Z14AhyLdVmEEVWlW8= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49TGfdn3003433; Tue, 29 Oct 2024 18:12:21 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= ncXCmrn8C/XAWKaT5GpUg8c4Aj5WFb3G6K1ms0Y8iqfm0Qru/HwBxz9OF2XRF85j aAYhniVK6CumoP6ZCT+e5B0+x47OPQ6iKyZBsLTu1Sl+pQFVzzchSPrYRTHvgyGU 9SLpJB6f0Cj05qnd4OKyBjydbv6t7UjAlTDzw3dgwqqT7i5KY5BxjOfrPsEZI40m CRclVIj9TuDu4pVvKLy4oefflI7VMuotyExL/oNbbt27PmsTF/2A+okpeFmeHpKQ CtMTVyIgUR6ZO64YDzff7cNbJ9YqkOfjXq4u/IZ4N/qNFKDpZDKK1on3pq1JksjW czdh4nqrGThW4p33I2Bc2A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc8x83j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2024 18:12:21 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49TH0i3e010118; Tue, 29 Oct 2024 18:12:20 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42hn8x8ww3-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2024 18:12:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M0I8h/buFrWBydFKRy4LuNnJpGdXY1nZJx9nCeYmn+hJJKZrwDzQ9Jyd0aUZga8oNT8snZh61aOPI/LE/52WLjMiE9MGIV/YgriLVaB47QMBZVC0iTLfu6GJDdNrsJXZ9bJGbmLzRpPGr73/Edcf/Z4nkXTM2BAzA0uvHImuc0eLg5W7ziEO6YHVv7rjgkZMu0wJIU1LKhN2gUHxIX01ctleCRyH/Nbb5I8i7yS1ZDLR8zJxo0303FsSONhbIlRu/2H4emBaSLGst3m28ZRitiPxrHH0pX57oyLDH9paduZWTtWrE/I7iJ7ULlE7cC5U+gvbLAJav98EhBBtK4YTiw== 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=UdBouwznFwC+ngpzbvRR3xtNKbBrTI1cmPw5/m3ZgqYMwlJAxzr6yk6zL7eGMt0sESevW7y/N3uDBt3IDg9kzvSY2dhmA/na5HC+gBQdZB1Bj+PnbA8QYs6HrVYCTOx8SzPZ19NrXgwADiao6sWOL5M/2pVkrboRnl4hbPrip+jGSZwITYIqs2iZKh9BjZsXLUwVqMm/7kc2jdkZKiY6JIaP2/icZX8rq69w+bPz8qIFUata90f73nQRFNFTxqHh3QaBclykujGVzRBwt+YDaz+nGuzd3PEP6QlOGjht8HZeS6qrw4CT6Nt9rX+g7YWgI1csMWo9K7vGIM4tP6pIWg== 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=WlmeFrJFcri1phHg9WLUMt4sYlc+pRmZXLXt4+EZDUhKTVzfXtCV7sOhBL2yk4AgrmBUt9xufTIamvoiQv/VEqmlkRZFrMReSCICLTGHAYhZsIgyGYxYmqkwlqXgvsUDvEe594SJ/pb8u2dSAz0nYNmm5oWYQiOsihhzSwNUw6A= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by PH7PR10MB6966.namprd10.prod.outlook.com (2603:10b6:510:277::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 29 Oct 2024 18:12:15 +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 18:12:15 +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 , "James E . J . Bottomley" , Helge Deller Subject: [PATCH hotfix 6.12 v4 3/5] mm: refactor map_deny_write_exec() Date: Tue, 29 Oct 2024 18:11:46 +0000 Message-ID: <6be8bb59cd7c68006ebb006eb9d8dc27104b1f70.1730224667.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO2P123CA0072.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::36) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|PH7PR10MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 8edb01d7-b2ea-42f1-d4ee-08dcf845378e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: Ozz6nisSp2OI2Iyq5RrJInjUVdUcqD5Hg5zC1pYn7cpQ8qJ9nRZ85wtt9sB4FEdq1rSKfqZ6Wom6Oj2aWZkxcCYLSczZtMQ2UICdKJbdJD90F7wFUu53wbHD/DN7n/YXCEl97ajQr8QcSHCSq4kMBFKWIlux/6mfl+7jI0+MAsswSsezNh/rL8uwdbzR69V2wToVMLErokpZrUMV8Xx7PFDtWzjRvRaZxauO2SWDuZkjLBBe88aYA2+EI89eXjPs3Qj4y/ssDFeDyHZPC480GNEfDmLHoD5RWUMyWh31IjR1Moqtryhet4gZQ9xcKpJHYtu7JjqU+HDunOQXA71syQ95eJRJse2aTfyA2TRqxeljTzzrswvnDYV7CFcYPsBMtHKIuCxrfO5qEX05kY/PQ2RDwDnWurHxPOEE66+xI9sVetvmNtkuA1ybK581zgULjkZk3V+/8DjrgQ1IXDcxAFPhfl4SL61fP9U3a0dX2ABUR214VGvY1aUL0xo5lGr+xPNO+Pm9mPmU3JuientyBIC1ogjpt5Y6Xc9Vf9q5zeRjRqneB2BymTeQYARRvUIJutO1X9vUAvJpDyx1zSJwjtDPjy9bMIRe/DehBqSCT/yD0dCWGSnqw2vGFm5ax6CBBqSJ/lriB9Owt70kwqyyUSiuI8NeB2qV+V92v0+CMuwl/k1JrRR54TnZ/vWHxGyevpa5cBwXASl0QyYMm21LfSTtwdY0PBUNYoCyVPZhjZeimHosA1cDqaPeTerwxvdHTWrWxlSINLiopPuC6w4SP3Og/MSxIJHzNS0BdSakBPSEuuKiokc40uFjJJ/81zSzDnb8GCzwNa4O0elHh/vHvFIqBBZofuYOU9sKMnlIyYpW5EUAruSrkjd6MA+G0Dp2QkY4H4vnfgyd216jqBPyUGN2liN/BdviDamZ0HZSZUStHWJZxnoO0yiCcwALSVcDlTVWs5BsFVTr1eLZDPj9cDBx74G24Yx5NPZbS0rDymkDimD1jZhtIX02+etajrhlBBhOKTSp0gSUJ1GRvxfivhVeiJ+BLbEqsWe8k54UJxtW4U81dTf8TbNhOzFXd5Ko110ypqu6oxf2Dssx/UjR4GXx9zKFcSh3ltaYux+Qg1hHyh7GQO3RQFZfgqLIAC5sitXDUAkWstV6m+orcke0G4cZPScJWEcdk0RvIyY1U2bSxRi1WxZel3QCtQpiOo5iyWANfHulm0Ll7e2MUDWO03h1m9ypxb2/Hb3zbKP4f2+0iCbXa3lNM++Jvi0T3KExOkQs8NSXUZiBNP0oqPYtOnGNu0elHxBh2s3tG4aAC8pPx6etxmyUNzfKzV78L4Pt 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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sLc5jIUeuf/mv48876dOaYoqEvrUsLE85BrZC2Po1U0MJJNkv3fmI+l5FeR7ifyKet81d6AYe+HcBxWUAc+ZnSaq4GqpfiMD9l8jjm6p2k2re5Zzd6n0cMWwS/AH0mJvloC8SlWqSILdn5M8C9zYETutK7Su7sx0GXCUqv0kQuifloxpdwnRHT5r3P7O/t/DiAPwDnxgsfkGCvtGmWPefAFVwkksmbTprIAwIp+PFFxWJEWcS5pGqtXmAMoJ0k+f7MIrhh4xhimcEcfQcEkfI4BZ2frvhC0w2fkD1oeSn8mPVEcCtw5GLJaf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kgnu6mPb/iigtOPGZiX0JZ4DrL2hilwNzqVs8TYHDLLkHJJwDJSjJGaqimYXaVPh5H158w1MI+IEEzDZcpfjJaSwvQKrMWXHXWgeNTAYgFKD3KCnI4S4v8yYD45awwziNhiBOhr0MWxZ3FpKhUG/lfMbiWPOSsqAG04U2vH1YvwxR6fqYt+vlB3VaRW9HoZBcuK0r38haTwDFuQzwUdhvkxpcUGQA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: vk49IzcWjbgHVXL9sXMeFlB1G5v2z2EW3tgnwEkob+TmIjzNKSKZ7XwH733jZ9IuBbncL1rJxIbzaDyETZuRIafeSfFyscCMnnE/7WCNvcBhfxiAlJNP5McIxARWlFFw913dDjI6NjCdXrxk2B6XZ/st5enaAu1JA6ZskuBnwAkmWxIuTMsmurZc/wCSQYiV3UhYthd7oCRMO8fYCQWPb1Zyc1yEPEiLbJnir98rxBiUMLc77HMoLYlDjbCA5MkWsyZeCOPIWsMZlH2LWQYLS7BaSxF4czQk6BQjonL114hlXZSxQsSk/hIdzFC0VEkmB+EZwlAfRqjAU2pGrY+E/BSJ0ukKTReIcaiErmUCQih+p4eZX2ffeYD0j5lQduc82+YA63GgaQtV56a0uvFilQyol1ReG7nMJbtG6zhN1C8pJ8DL/Q6Wd4wn7FD4+h4uHkIWqNiDkrD1/y470U0yFWrc5BO03PxPy+qlewApyBvBjnRePqi8k7/vW/lebj9dlbFesWgxdlbkoExDvz41DA6liMzK2mfuD2oswWqfGYXi/0NSympW5JsqAaixHDZI8BUh15ZsodzMse8UzmPhV65cc1Um38FI40hnu4ULzw4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8edb01d7-b2ea-42f1-d4ee-08dcf845378e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 18:12:15.1038 (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: lTKoRECnVPFzNOJmnuBPYsiA56//lpY14uLHNsttg0K8IeCj07G2mqGXDOpsFq/wuPTtOOgRD39qa9fJxxRuItz2O+O4Z96L466N1j19e6o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6966 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_13,2024-10-29_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410290136 X-Proofpoint-GUID: X6SHYljO0tOm8muJZfY4ssgyH0KkU9P8 X-Proofpoint-ORIG-GUID: X6SHYljO0tOm8muJZfY4ssgyH0KkU9P8 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9FA0120026 X-Stat-Signature: 8yg8dkdeznft4e5xumsyys5g5k8p4amu X-Rspam-User: X-HE-Tag: 1730225531-435010 X-HE-Meta: U2FsdGVkX18vE+Fg8vDfUdaeHQsxEPGQldD7+SLuuZFa+6dO+puDfxGiCRhF3MGSvbHczMpeEyW52g5PJLtW64w1kBkX74tQ6n4Ev96tMutYVQSAfAleSq3CeOAT9ZxsKUu7/ffrIPl9HoYRouorjTeTgQydAeCnvyZWcy3poDsg6kItwIwUwBq3U0PiXgQwefJbTZyDX/0n8KhL8W78FUZtIxq+1S8KAOKnReyFZl/JVmgUlXcRUlXYTrdufN38cEd4tHnms0MP2GmiKTSL1lPxKWPFh+P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27he4rzEIcOYGO6MES94Akvxe5T9prDKsieVmTXO2WA4HXz1yc3JL2b/A8WJNlnC9SXIBharssx7Eaet0JvFiBaDVnAnHs1nQE+q1dpL4DYVSYNEqHUUkLFU0y/e+OhmB6cb6UbbGmdDy0kLtOyy6Rrb1jaN9ShUcZek8H6mUJbpzKka3IT4q7LSIcoGa8NSEcpiUFm5E4zz6o6OXkoT9+ivIPGLy6A2NlgpekcTt/VrDFS4fZ6Y7Q7GznEKdJ02fMR0UY= 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 */