From patchwork Thu Nov 28 15:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13888111 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 6F393D69115 for ; Thu, 28 Nov 2024 15:06:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33E486B008C; Thu, 28 Nov 2024 10:06:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CB5B6B0093; Thu, 28 Nov 2024 10:06:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A4316B0096; Thu, 28 Nov 2024 10:06:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C93C56B008C for ; Thu, 28 Nov 2024 10:06:49 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8CB53AE220 for ; Thu, 28 Nov 2024 15:06:49 +0000 (UTC) X-FDA: 82835830602.07.029D517 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf16.hostedemail.com (Postfix) with ESMTP id 51C9E180019 for ; Thu, 28 Nov 2024 15:06:38 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Foa8+6OT; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=yIyuBfjV; spf=pass (imf16.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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=1732806400; 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=fucP9TZcpv3nFaY0Gbv55QIlReHIn6dziNcoY5psffc=; b=6wmfZMsHx7ovBWMlXD/8gZAWGqCIrMnPMJpTphtea2uZV6Ors+BsGp31GoeCs3WoAjIjoB n0Dr907e+T4hG/9s5CgkymiWAPcpi0ZOWEz6AbrD5vYZmDXLCyfXooGxz0Scj/RM6XJlJs RBLB3lv6AMISAHUaRJDwqCSo3WPSh8M= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Foa8+6OT; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=yIyuBfjV; spf=pass (imf16.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1732806400; a=rsa-sha256; cv=pass; b=HjaRLHAtj0+bpjk9E/tsVqSQBC09QxgVmMwGuGWCcnzCQrIrFNXwXPcbZnr7sixzIBmS/7 xhdynMr96uL+Kbuu0hv5DhvD/7S7/PNjayHDGRhEy7KrYxda+VA+U9M/1cDqtktjX/yCE+ 2PgU6j7JOeFZrptlLJrEsAFDAkf9W/o= 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 4ASEHEF5029077; Thu, 28 Nov 2024 15:06:34 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=fucP9TZcpv3nFaY0Gbv55QIlReHIn6dziNcoY5psffc=; b= Foa8+6OTwHD6U+EEOxlH/kVEYbQAR3i1/2MLUs8ylyXtei9nwUCOTgbeRpfINquq 5Q6MNotOH0/yl6M0+ThH0I0t9W8bL1jmTImm7TzwIsTM1K2KdggJ5CRpOVCUgbiC eosytAgtYXZQdnHi4jLtBMgn66AwqwyONQSWUbpY/cXAvjL4sljQ8cYgceC0c/rq 3fa3Zc4CWaMmWvbsufWXN+6vKIlxOhnrrWDRrACRT0Q1tV5HrKypGDGcQDgwSYeA gUjf+5veYRebROOGSR6Gywpl0FIOIxHG+ONQxMapUsq2m5QcNN6qMoY0Y3GA72aG CUnxBy6hc5BCdI0Kv6F4qQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4366xya0dm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2024 15:06:33 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4ASCoAdJ039401; Thu, 28 Nov 2024 15:06:32 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2174.outbound.protection.outlook.com [104.47.73.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4367067rd6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2024 15:06:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UyimR1ypqav743DhnI5vxXzSEEDYWMZGoAaYWAbWed3CGnxo2EUsiPTSBfFtib64pw9k5KzVQe8wiCyCAbhisCyoYCiEKvNZnRURyVoEoVHLFiyDJefpG44FSbpFcAyfdINd+gu404ZTg3MX+6LOR1aMckQjInBO6YG0LyG7jGslgsIg7dU/3hpYCI1h6rVo01/5IKkIbJeEkeepeeCyvzuaqQAnGxzi/pv7xWthY7/p6/62FlrifWqhkGrJ/LyLLq4bstnFPdqAE4Kl4Osp8kUUIywWDYeOFO7QVb8uEqZV8ofOsZdkpma+bBYK8SuqWKjgIn6ptsCfQo6+SWvjNg== 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=fucP9TZcpv3nFaY0Gbv55QIlReHIn6dziNcoY5psffc=; b=J+qiue+g0UsRetMoS0zd2mCIM3fNtEmr0D7lCy7PWQG4eMU4w2cHRWzdQuuR0tPMNQVBtH2KoBG+qc0sVcn2amUOH4TvOW/hmA1HMsTJ/1O8c2U6RmFOMX46HfoDdQbZ5c/BbwR6y25d81YmQT8Ujym6pjlbX5t43lKri8bX7BZn/1a8PurMFtSMptD3nALyLJMx+OmWhzU4VO02NE+lyok69XH/zsNXho12LOn1LeqQvI/LLMz4DqQCJb6qpOTjeOmFmvVT34roeA8iLIkppdpy9nxtjbwWYXNLbCpO3I3FjhLRYJxC1jheFhAZ4KMUg8taHu5K4TBlTvjh7/mFGg== 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=fucP9TZcpv3nFaY0Gbv55QIlReHIn6dziNcoY5psffc=; b=yIyuBfjV/9d/t4RqsKxxb0stezM/8lan1AtYkVVUT47RQdekQNfCX7pqta9UM2GsQK788iMctiQK9Br9fg8pO3ZOGtSkVeVcjQv6Rgo2IzOTKW00Zu2duN5vatrW0bRnrJSkvrlL847GeL67TuzmhYCJIBcBwbr1UvmIa2VGGZA= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by CH3PR10MB7958.namprd10.prod.outlook.com (2603:10b6:610:1c9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Thu, 28 Nov 2024 15:06:28 +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.8207.010; Thu, 28 Nov 2024 15:06:28 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: "Liam R . Howlett" , Vlastimil Babka , Jann Horn , Shuah Khan , Julian Orth , Linus Torvalds , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: reinstate ability to map write-sealed memfd mappings read-only Date: Thu, 28 Nov 2024 15:06:17 +0000 Message-ID: <99fc35d2c62bd2e05571cf60d9f8b843c56069e0.1732804776.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0463.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::18) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|CH3PR10MB7958:EE_ X-MS-Office365-Filtering-Correlation-Id: 63b9bf99-9dd6-4af8-a7ef-08dd0fbe3c41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: AOnzsvPivvUwGSh5zDT91KSRhi363SQx/kMIYeLJai1lR3Z27B1gcGh/r9jTy7zUeZWNQk+DuJX/aGBa6D9xmLYOCH9DVzW6DZZkWV0vdCnZ+WYxtVfwFlkBFbq2YUQHfQYHFjt76IOl637i039msLCjaZyYPDpgVT+r8Pb/gHP6WG3JutMCZ4HtLvzOmp+wbzALgyzQ0iZn5h7MPehlp6aXfyYebmTK0deuuoDK3rMbHvCcmmlRVrfcKVhZ9G1IukOzFHS6NAsuvhrO+0FtJF4HSnWYEoq8zK+OBDPI3juh+1QIn1aYo6XbLXDuY5OzFeXYsjB9TDbOYW5G96o/ExpbxGjh2SeebNAPdHLif9q79vHzIfPZ+aOyblCUdzdskaoDUQye7TJs5uhxF1DEzL19OHA+PfTXIVtSguyk/tkf5pOm+xTxczxIQoUEVncd5jvGrSODSjrNTQlSR++r6kv6KIj9VzEnIyz1mgxl5LttTss4fbTtKSK5ytTQf296jG47FIzY2o3khjLPzSLL5KAZdsnnUqN6r7NmOj9k4wbXQVJoIw+zhQ+c0AyoD43PujclZTAnTLfLMwnlfYJ9qCCdvmsUnkScxOH1Ir91I9pC87gSzCEsIkLQqBt5GQCciXqE19wcyjG5ikt/rT7olnD4SiexCJ+RKuLsegL1VnDabSO5go8oDFfQpX3sk4DfmghgacyHR3oBusLz8muqPFlsmXmleGlabLuWLgDVwlDyH7ixZxjAXaTy4z2Fe3bMokV34vVHnNDsKqXuNGTtJjDvrcSe+1LDzfzykKEEziqfhKwNENmRBP77EP0tlPFq2NOB6JFTZcgxON6K+/Z7dybcWZd3OC5PsSrgX/pJjc26q3smN/21vFxUX2mF8RnyoEuXIEcOv0N8lO3iLYGOKeGEEc46GfEW9iYR/OQuQ1+xwe2MWtTXVVzYY6sNu5e2j9m7R90EuGAP19YfSYJtFPfrX0gjlIvC/FKGAXP12ISW4dRMu9xEQ4Ui2kpMb33jiEiYoqmpAbJboiB9eLoF1d2+7g6PQyEcKQqD72btzz+PRgJgR6EgU89R1ddmfv/p4dV1gRUZFoyVIrwW3oIysdj/2w//NmwSSgn1gg5UgXra+AeD7qp7e6g3FoucCe2Ujyp9M4bmN3mm+3Ajd7Jj176EZ1Ze64FhXSHIm0CEU57ltebYKfqr0ZIztcrxU7/GMpiK6ebGbDXEWltGMuAYLsMRbf184/xmCy+Z4kj1DYDjlBi9V0SX7LaruLaA35AlEb0MNCKyB21lNmYDEF0nk+5rOWZQ7YhIW5piiuJkIAFA4fL4ACqosfsWjOgdafONIyJl9Bkm9vAThmx7dVCR6YqBp5QhtPj7dSgKEpi1pKQ= 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ofavroy1XnfDc5AzfVEZfqKb6oIY9c6JTXFYRmkx0WZbEOx4PK1Pc90EUde+VyHz87aMmjpP2OeD/Jolk2pFoH3RP1kKc2YfF1sJZWVG4+cpMbvOVAa+95ESionnDckGntQKfbpP+1g7N4WgiLl+NetHAH0gFvAvz2J5YBw5meclqPfAtawVZgSqI+SBV8lCuCnIlDvGfa10Q8JqKDCbajfcZ0QL1CEl/HXpAcOeptArn/FyizTYGpo3ZjGSI8SUzhvIkF8uL6BsLO82gccfIOQ+HiLA45j+4dVqUgJtAUVzzcP7SjAOoBPwaVMJmnO/siXSXcVj1zpCrHv/nHc/OCukE0BrSUccqxoE4WcIXtuRJx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FPS+4Cl+R+JPVFyqjhm211OOEHHTVGEJNRddfc3J392pt0Se3iD5k+unwRSjV+bMp3SJhR196TIeMHltqYGjbkTtnyfBKMngc3vnHSaFfVfeUoPB/lUuEh4t+5bZnLldoQIcGOAaT1DXT0Nf3Mve8HiJXRmB5y5SDH/WnumDsNaP281CUKgRMxlQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XDEJufNTbQ3zdV1/73xl6NlJMfdjXc2abv6BNQUZsFJQSXJb4vsuzOgQR5FTLs0mpPjoUXzb2Is0iA/nq9c31ZwOrHeDVsb98p5dPyHq5aemr2IWy3XEkQANaMVZsTa1lQtaPa7bF36VfTAtfXmkkJM4MyYeC8D0Gy+INqR5dlf+lBdglq0aqTFg8osyu3VbduUpTljLi6X9RyCercyjb9wipB3dV/Fv5kJE1s4FEMHlcwW9kQtfEGPhrdksoY4u5EKXPt4NAAeOZpvg7bDqAI5PfivwlfOVpFT0KbGkPX2rTwd/GwpAth6m87jAvvFrzXuVrgiy7wbqazl63Pr2AERMe7XvNOf9pFgG0yADVW0ngikiPVvbuMkJjkY5uVcbzSrqs8veT1HHhrS07hYgq/EeRWjPoisN7AXcp1qMSwaoRuVlw5rY3NllKcjWj3t0Lu2g1FZnAlTVo8mQG9sAc7LMVrY2gd8gvfK66QbZlDSTxM8mqtLeuTCZGa0OmkzHOsLDnTNXsQL+MKCKobg4HAiu1I6JukOWadToMc1Lmr25B4Gs/mjz8ksBj1SYGDgI7D+QL27Bhx3d+HyeNdyIb3N2HEHv4tpxUBsAY15w/6k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63b9bf99-9dd6-4af8-a7ef-08dd0fbe3c41 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2024 15:06:28.8205 (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: t983o9dYim50ZWk7OFsBtBOIaiUj4dKTYjqsrcNK545CAzRUhrF5Y6uDVIanfipt44XBeXE46N7Us7UIzi0DJTnx/39vBwIXR4ZQddrr0zA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7958 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-11-28_13,2024-11-28_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2411280118 X-Proofpoint-ORIG-GUID: 25Myjd7UpdGfHX2JGNRCTFL9VbzoU8Cx X-Proofpoint-GUID: 25Myjd7UpdGfHX2JGNRCTFL9VbzoU8Cx X-Rspamd-Queue-Id: 51C9E180019 X-Rspamd-Server: rspam12 X-Stat-Signature: u8x4f3aam1fam4f8f65dupyn4jfpwzfx X-Rspam-User: X-HE-Tag: 1732806398-332414 X-HE-Meta: U2FsdGVkX1+C4uLAz+xJEt1lpjS7nU7WOVWgCLUI4V2dWjVHk9j2OqAAXOqT0tn0EH7AunQrYPMY0nTxUEGmr59zt2BP9wmz8nMH8Q5T6imD+pLVuW9TUzaELwsL/loOIYB7ddRlCf0cvokmJV0BFs8Q5ndQzaeD3d5ZXnqyUQZYSzLD2cV8gHW7X2p+C7g7ZpB/Qiuc1yOjGusRfw9MVIFM5WZgVJ9Av7wkhgGnzpNB9K7HqBkuSxJdCvGBpY7Lc2EXtciJupHJkRnqOWigDnqKCvV7fu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YMvCaQlqw2OVHETesocsQWm1fEEETUvU5lLdGFAKu9UfDXECmSr3FU85KkbCWMAQg3o54a1CH6Z0DSYCPSfFWOBrImcYsJA9AKWjPRdlfohmTfg4HmPB5khDww56A/3t0rSbj3DAMmnUTX6VX/ID+tx0aPUAYPhPrO5IZrjPSyoAvhVs/p3yDHip+OmlEymWdT4H+AfdT0SKwGu0Pug9x+G83Uh/Hcm2mD6nS3uviIQC+69mNagnCfQ+jNHubL8Dluj+E6mmieltRVdHoByXgiFdq/H/QUIB9t0ygk7E0DYZX9zqp8mVHnrwUJnnjBrohtDpQT3A56mjIqNxcXfPdN4UlQesSab4cCLzEThStf4tKvj0HVrqNYT4+g5zQg25o6NeXDm4= 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: In commit 158978945f31 ("mm: perform the mapping_map_writable() check after call_mmap()") (and preceding changes in the same series) it became possible to mmap() F_SEAL_WRITE sealed memfd mappings read-only. This was previously unnecessarily disallowed, despite the man page documentation indicating that it would be, thereby limiting the usefulness of F_SEAL_WRITE logic. We fixed this by adapting logic that existed for the F_SEAL_FUTURE_WRITE seal (one which disallows future writes to the memfd) to also be used for F_SEAL_WRITE. For background - the F_SEAL_FUTURE_WRITE seal clears VM_MAYWRITE for a read-only mapping to disallow mprotect() from overriding the seal - an operation performed by seal_check_write(), invoked from shmem_mmap(), the f_op->mmap() hook used by shmem mappings. By extending this to F_SEAL_WRITE and critically - checking mapping_map_writable() to determine if we may map the memfd AFTER we invoke shmem_mmap() - the desired logic becomes possible. This is because mapping_map_writable() explicitly checks for VM_MAYWRITE, which we will have cleared. Commit 5de195060b2e ("mm: resolve faulty mmap_region() error path behaviour") unintentionally undid this logic by moving the mapping_map_writable() check before the shmem_mmap() hook is invoked, thereby regressing this change. We reinstate this functionality by moving the check out of shmem_mmap() and instead performing it in do_mmap() at the point at which VMA flags are being determined, which seems in any case to be a more appropriate place in which to make this determination. In order to achieve this we rework memfd seal logic to allow us access to this information using existing logic and eliminate the clearing of VM_MAYWRITE from seal_check_write() which we are performing in do_mmap() instead. Reported-by: Julian Orth Closes: https://lore.kernel.org/all/CAHijbEUMhvJTN9Xw1GmbM266FXXv=U7s4L_Jem5x3AaPZxrYpQ@mail.gmail.com/ Fixes: 5de195060b2e ("mm: resolve faulty mmap_region() error path behaviour") Signed-off-by: Lorenzo Stoakes --- include/linux/memfd.h | 14 +++++++++++ include/linux/mm.h | 58 +++++++++++++++++++++++++++++-------------- mm/memfd.c | 2 +- mm/mmap.c | 4 +++ 4 files changed, 59 insertions(+), 19 deletions(-) -- 2.47.0 diff --git a/include/linux/memfd.h b/include/linux/memfd.h index 3f2cf339ceaf..d437e3070850 100644 --- a/include/linux/memfd.h +++ b/include/linux/memfd.h @@ -7,6 +7,7 @@ #ifdef CONFIG_MEMFD_CREATE extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg); struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx); +unsigned int *memfd_file_seals_ptr(struct file *file); #else static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a) { @@ -16,6 +17,19 @@ static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx) { return ERR_PTR(-EINVAL); } + +static inline unsigned int *memfd_file_seals_ptr(struct file *file) +{ + return NULL; +} #endif +/* Retrieve memfd seals associated with the file, if any. */ +static inline unsigned int memfd_file_seals(struct file *file) +{ + unsigned int *sealsp = memfd_file_seals_ptr(file); + + return sealsp ? *sealsp : 0; +} + #endif /* __LINUX_MEMFD_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 2bbf73eb53e7..043689a56e8d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4090,6 +4090,37 @@ void mem_dump_obj(void *object); static inline void mem_dump_obj(void *object) {} #endif +static inline bool is_write_sealed(int seals) +{ + return seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE); +} + +/** + * is_readonly_sealed - Checks whether write-sealed but mapped read-only, + * in which case writes should be disallowing moving + * forwards. + * @seals: the seals to check + * @vm_flags: the VMA flags to check + * + * Returns whether readonly sealed, in which case writess should be disallowed + * going forward. + */ +static inline bool is_readonly_sealed(int seals, vm_flags_t vm_flags) +{ + /* + * Since an F_SEAL_[FUTURE_]WRITE sealed memfd can be mapped as + * MAP_SHARED and read-only, take care to not allow mprotect to + * revert protections on such mappings. Do this only for shared + * mappings. For private mappings, don't need to mask + * VM_MAYWRITE as we still want them to be COW-writable. + */ + if (is_write_sealed(seals) && + ((vm_flags & (VM_SHARED | VM_WRITE)) == VM_SHARED)) + return true; + + return false; +} + /** * seal_check_write - Check for F_SEAL_WRITE or F_SEAL_FUTURE_WRITE flags and * handle them. @@ -4101,24 +4132,15 @@ static inline void mem_dump_obj(void *object) {} */ static inline int seal_check_write(int seals, struct vm_area_struct *vma) { - if (seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE)) { - /* - * New PROT_WRITE and MAP_SHARED mmaps are not allowed when - * write seals are active. - */ - if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE)) - return -EPERM; - - /* - * Since an F_SEAL_[FUTURE_]WRITE sealed memfd can be mapped as - * MAP_SHARED and read-only, take care to not allow mprotect to - * revert protections on such mappings. Do this only for shared - * mappings. For private mappings, don't need to mask - * VM_MAYWRITE as we still want them to be COW-writable. - */ - if (vma->vm_flags & VM_SHARED) - vm_flags_clear(vma, VM_MAYWRITE); - } + if (!is_write_sealed(seals)) + return 0; + + /* + * New PROT_WRITE and MAP_SHARED mmaps are not allowed when + * write seals are active. + */ + if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE)) + return -EPERM; return 0; } diff --git a/mm/memfd.c b/mm/memfd.c index c17c3ea701a1..35a370d75c9a 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -170,7 +170,7 @@ static int memfd_wait_for_pins(struct address_space *mapping) return error; } -static unsigned int *memfd_file_seals_ptr(struct file *file) +unsigned int *memfd_file_seals_ptr(struct file *file) { if (shmem_file(file)) return &SHMEM_I(file_inode(file))->seals; diff --git a/mm/mmap.c b/mm/mmap.c index 386429f7db5a..b1b2a24ef82e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -368,6 +369,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr, if (file) { struct inode *inode = file_inode(file); + unsigned int seals = memfd_file_seals(file); unsigned long flags_mask; if (!file_mmap_ok(file, inode, pgoff, len)) @@ -408,6 +410,8 @@ unsigned long do_mmap(struct file *file, unsigned long addr, vm_flags |= VM_SHARED | VM_MAYSHARE; if (!(file->f_mode & FMODE_WRITE)) vm_flags &= ~(VM_MAYWRITE | VM_SHARED); + else if (is_readonly_sealed(seals, vm_flags)) + vm_flags &= ~VM_MAYWRITE; fallthrough; case MAP_PRIVATE: if (!(file->f_mode & FMODE_READ)) From patchwork Thu Nov 28 15:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13888110 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 5F5E2D69114 for ; Thu, 28 Nov 2024 15:06:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8E5B6B0092; Thu, 28 Nov 2024 10:06:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E1D676B0095; Thu, 28 Nov 2024 10:06:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEF176B0093; Thu, 28 Nov 2024 10:06:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9AD296B008C for ; Thu, 28 Nov 2024 10:06:49 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3FA13160200 for ; Thu, 28 Nov 2024 15:06:49 +0000 (UTC) X-FDA: 82835830728.22.0800D11 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf21.hostedemail.com (Postfix) with ESMTP id 520281C0012 for ; Thu, 28 Nov 2024 15:06:32 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=L8ERYzde; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KUnt5r36; spf=pass (imf21.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=1732806401; 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=GqmS80LtTq4glj/r0JufhatLwW4dPy91kyJOpOlImGg=; b=oFrztLE5GGC310XizMbaA0xGSE9orObJgg3yqKnsWBNeGDp9GJUfNvQME02Qay2/v2XOI8 qKFfTOPXH6Lxa7gHZrINarRxQvpR9eboLvDL481jR9lnQkWQZCDIhkGDHN7yHoRJQ3t9xo 6cDtkgiDsejS8SHzWVARMXAWupvdIc0= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=L8ERYzde; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KUnt5r36; spf=pass (imf21.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=1732806401; a=rsa-sha256; cv=pass; b=ZucnvA1bcmtkVonKraLbSoBy3rb3vJ96m3FUnWI/Qx74upX1h9nQhpQ3jQA9JYOnXt3+aF 3CPNXr2Q519low7yzt4hT8lvuG6Qr4FOasANjh552L6+J7t7my48EydAxAvsEpsgfh35HW Gu0ZC7STszpdmaUws0vXlS2hC4rEQKU= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ASEM3dP006799; Thu, 28 Nov 2024 15:06:35 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=GqmS80LtTq4glj/r0JufhatLwW4dPy91kyJOpOlImGg=; b= L8ERYzdeEqLrsN0d9TA2K+9U1dqA7HeooXTfyGJQYWBtkUm2cSEmgMBpR2d4inA0 PhA+S8fDRDOJwxkNpgrPgdgUY+BZd/4SpZm7bZLWQlTh/0W8fBQJAH9W1ca3busr x/4DIX2u4872CAORx2ts3fJvgvFX98MZmVTwLewP7cpDxtGC6Dov6uuwWuqu37LG THvyq2BVo7wYLqr0hwvnRZie+IA5UPsn2FsrfaAZYLl/DwjvM3ITIQ2YvEoLn67Y 2v/bXGqXpTBjkqtgi/j/0K3VAr6p82duaJO7peMG+q6xStrBEtcTMzrG26cd1G3t iyl0pGiqmc+juaLP5ZZdbg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4366xya162-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2024 15:06:35 +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 4ASCaKw1014352; Thu, 28 Nov 2024 15:06:34 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2045.outbound.protection.outlook.com [104.47.74.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4366yyqb05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2024 15:06:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RgeL/zzze026byi7Ql2Jc81R93ODPZiQCM3XxrlMDG2JfO4r87vhfcZOj0d+VZ7MvWtC60V1Yp07JTUlKzX5xpYi+pK2jbw6JC4FN8kztXSh3+i5RxZ6dF3SluehZX38DKuc97DTk4fJYu4rfIaSuE8B8qe1pTR1HpEZrDJljowTZ3KlnYwCc4xC4y6B/e8HZG+mRaizJAQXyvm9SqWbegm3Ljmyy2L6k6nzkr5TGB1oit3HgGJZHAd5hxdu1SufV0st5c/bHC82uLesaQTYKCrNH0UQ1czfgU6tebly0lKPyOeqBSczkf/ccRnfQ1Ey7KHCnZWl0hldyAaDCfZ7ow== 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=GqmS80LtTq4glj/r0JufhatLwW4dPy91kyJOpOlImGg=; b=kDko3InPnLasq0rPbfQfrIgnNLhwVCddBGom5YWXpd4ZXA1J5tD5d+TCqxkcu9UtM0kZFyfAek57lNCoC5EBq8XLeQutrrMWtvXBeC3JPV7a21HaOSpeW2g+q5yEn4wSuncfUih1z2ud0R3fp7ObUXsYewEhW6ekEV5+LrGjMTAR2VfBXhRcpCZeB6to1nvKmhk1dgcW8zD6baIHA1L6GEWxVshLMJZ9Zd235TtxxtzIVWLzdsxBU9fp7DUDY7L454CrOo22GPfbWnhyFVmNBwfuMDCIYpA7cPuesusrDWHQDdFZRCDlMI3refSrs9eCqJLG6o8MQr5i/Gv7IeYxzQ== 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=GqmS80LtTq4glj/r0JufhatLwW4dPy91kyJOpOlImGg=; b=KUnt5r36ULVkeZpPT4ELd+UVjBKOr+uzbEeTyJll25Tw0HNNpZfR9IuHSAWI0/hidX/xRXwOb5GTJgfzt1aDVfsFsGrd8M+mkTHoODsT4l1Geok18J7qHuRRQpZvS11mQCM6ZwoWmcfGsAcj59SJ53Ow+jupsa3EN/nUWoXxfB4= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by CH3PR10MB7958.namprd10.prod.outlook.com (2603:10b6:610:1c9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Thu, 28 Nov 2024 15:06:31 +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.8207.010; Thu, 28 Nov 2024 15:06:31 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: "Liam R . Howlett" , Vlastimil Babka , Jann Horn , Shuah Khan , Julian Orth , Linus Torvalds , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] selftests/memfd: add test for mapping write-sealed memfd read-only Date: Thu, 28 Nov 2024 15:06:18 +0000 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0455.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::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_|CH3PR10MB7958:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bce3790-9d90-433c-405a-08dd0fbe3e13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: iPxt8gzAGiobHLjsilAd0QyuzF4lGPHuRPEIZxBXUUv0xzVg3CLAW7lhnL2SfV7bMHdigYcVpMBBIoQ0+2foNmHmLtX5y5RwJCC4kdghCjKFVkvje9O0no128dJHBxxJOfROTrKEzdxu8uwgtn//sXK4rNAkujsIbbGvAt0r/IepsyF6jH2FxrWDe78WI+CblUASI4/ntgvB0kb74ESn+X89bOwRO4DKY6t5jEft4BSVFWqMuvJclLvEjDT2ye4bl3QwtRR+6maZKCQgaP6bpII+m+xLSAdGma/wTh5GdgD8NZGsT5gluL0f/62qccOYikNoytD7C9PhqQ3C6tDmDVa8y4ah8Ku0/Tv8ucMPz7KZGpEMWl5jF5okXSlFEYYP97vcZFqzh6JqM1PywYqeaMg68RsZwSbY+b0yMzNnqKEuF4J0QmL3XrwopXuebxsmmLs7ZVwXq7zoafdMj2zt4QmCXUbsVrxM57fYCp3wKmFpiv7hRYi5YiKudFuf7S6mocBnAyPGSzdx/i4kj1khxgxXIfnzjs2kY0Bz1vNn0st91pC1IVtJ9mE4eb2mzm7zfVTKjxZHd7oHCHw/HDnkfylh80vj5sxjr0c9jdbxLurxAi1BQsLRIglG0IBibuX4a4aflLiRciRe4J7djf0CdUwGOtGUJiaNbZOkyGccRZ6g31tdJEW+WfAtZFyDe2SGPeqPgQ6K9x+z1Q+kGHpzWNcXXoyEbe87cgroIvGwaPsBEBJUbWtdtS11gxey/XPTn9pHLloUR6iD8wFmBezy/651mC96k43M47/kVQ1/gc0GkmDFf+Lp5+snKOzyG7EynOeLCaRXhyvep1KZc9PX/u2rBQX7sIO/N9ABP1rcpPMu6MdExCdg8pBciqB6Ni7t/k3c9S/Cizk6p8MhFOYL2AQLLEnLr0u00C1RW0tqmNtIcYUfIcJvNs/wcYJzS5mCm9DlFmMiQNulfDXj7g4r5C9ZEHtQGtnDXm9NIL01RX9TrWJz6SR/+pUo6/dni5NIFtJyRjiBBhqeHo2pADopUaXfmWCYukQEw6sgcgSpAgcKjtd2Ccjq4c9RVQA/bQKEX7NMUzBz34bhpxf7PM6PYUCGlSBLI8xJAGGitctbpsmzHPe5MV6J2l3Dp/yZqhqHkJso1FhP45LQQdYEwdU3B0A2NdEXFqyeCtTXA9Hkk5mq2oC6nDjdDAme3g9RqN7bc0WS+Sw9p2Q1GYK2RZpMeQIybVjiExkvl2viWgfcOQumuxGco4NOEbKSp3cqmtUdpbl3Xm9ghK/FpQdwbsQJkJxVb9VIAfHlxfoRusvWDqUA5FdH3ag14pyyICkZqC2GrMzau7LkhNqeHZrcanInHQ== 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)(366016)(1800799024);DIR:OUT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nTuaWkTCgXTBRNsksLoui4ngRs1adkldq/E1lBNtdlYLaqQVOCjCIJ9tMZMVfoiZtOv7MpxN9ngq42kiVCkVcGjyI28vHnHS2QRwnjiko2PsZKjkmGMwZFJSybxep7s0f7W8kQOl/od2NaLSCW2Lpj23+BrbdOWIboYLckIVo/IxCURDNCwsaq0kRWGXfzw3wfhZL1FVwEbF4M78rE8ZuuRdwOvAx4ITVt/dTGC/niG6phf6ApQI1JZ6syEB2/7lO5rw8MHpkJzuAWkZICKk9dZ0lHW2z15kr5HeeN2FW/v9UKe6EWVYlxnqhOAGqaooE56dn2StS1Haz5ElMjEQ2kuAdQTPbCA1raZnQMKuQCj62NKVtgRWud2+T9FpVNW/hw+KvMgPvd8Kk99MkNabOWfUDZURagaHShHSuNbVSPToyqioPul2Ca26A/0lAicIl2o12j5UxN62LQSfYZuqsvZdU5a1QB9aKqI8MzQyHmSPrzvOOi35VP8AETmadA17I/cwplDGWsa7qoHdajBRZuvhmHckdAX7NtsUq6avhQv68duf63mtUugSmmXfeq5POAuPvcou+VCMUqVdfV9Ex/XFmxK/HhE/22Or4xTA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: cm1TJ4yaPlooZUDlEKU792ytBoKPvqNGLSahuINg4NWs6L0Tno9yfQ1ojkFO5qbl+/ut4Yx06ABCH9PkR5oNQQN9omj1NuQJHBMy5epeOOLZjXqvkK2GUk9jmvOWrOdC0N9ACO8SneXZfYXDpVQ31eB1j7SK2DdcQDbSEOBFr+rpbwwEelIXblTxv+czbIaHeLfPSBOAG/ouYi6a81WxYqjJFqRuNjHzTtxriArqJBL4pYKvKeu+lsblDHLlxDsn8Ygvz14YE2EmnUEFDtglm3lWmnqTm/miq09pxW53wv4WiXEUUxYpGKAPRs6Z8zSkMxHKlSqXDxkfd2b29ZeMj2h28cTiQwpy3KGORTi0U6537eh/+b5jkJueppzqCaAsiIOb7A7/pomwL5O3dffWGK/9cTMXjOQ72UP+sKD71xH2F4mqYnPeNShqH0Mp8bMWBBz9evsQqEOEBSOTVr1BTPybl/qTk7Lk97tGCBi1aF6CedyrRtWrGbxGRP1ITJVZsyQz88A75EO7Zu/bFMCCuzTPqEffK58mUTKiHuIhZGScuiUibyrg/WIvTmliA+LPAnJxbBO4CNoA5WTlEogQoLBX1JjanTra4DDJEkEmVKA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bce3790-9d90-433c-405a-08dd0fbe3e13 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2024 15:06:31.7141 (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: X9pdsK+AU9zT4NeCTdxkLDpP1dPfNEFEAVyX2r0pPS2tL6It21iezs3pyPfdPrvTGck1hs13UR0vNWhLipqBkfU/90hD4aOVz8tKv62pooI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7958 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-11-28_13,2024-11-28_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2411280118 X-Proofpoint-GUID: U7vXqVuU5gvZvMtBV-plRLKHIawJiz4S X-Proofpoint-ORIG-GUID: U7vXqVuU5gvZvMtBV-plRLKHIawJiz4S X-Rspamd-Server: rspam05 X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PlV tCjRYYYN kXTRek9IxRHRgP/7E1q9PUgFArlabdaIuTYha+jux5UaAnmWQE9mFbpB0XE4cThZ7dArFUAphmBhHf80h3nZYGu6oHGbJjRotxpWBwxxaYLGGm5Wur2BTN76XPe2ss5TS+sOB7h1ZiIfRLCi7WDCAxaRE6/MPrYnUVDt4SkLEtIN5bwrJaCfFGN3aqxsDRqPAaVtgaUjmArvAE1iG4vC+oKIoHOFycHnisab674XX6WMdtRB6k0tcWo8TjRHcUV5iMWHyuQ9+o7KwBMsNOOpy5y3l4MxfQbaESisMdAri3cPRzTequn6LYlLoEdcNPg6Ip6g1EbkQNGZG92xI4sj5Q6UPW2wDbyppITgwi1U5Xk0oN4TnrhKLIbT3a/UV6PpGkZWZoHIV0TDC9dzJ/+F2dIWqDBaAZ2tOpicsdvA87kWArihchoIrSTy+fz/sXcI6QNXZ6MMWw8DICWWJUUpbrhbGGodBbp6lN/+lkBCpUjit1qOlfrkbhlXCR4lIVAeE2Tz09Mh/fbOrFWP/kSKVm1yg0Iq5GUWzlEzSwF1grSz61HaVSg8Rw/P+3xr4NJHNKq7+V1EaRHEqvqRslnBWHN/nFS5RkgXTuv/S3bGAUS431c3WeOgUKWi81uOsUwHyM+o+ 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: Now we have reinstated the ability to map F_SEAL_WRITE mappings read-only, assert that we are able to do this in a test to ensure that we do not regress this again. Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/memfd/memfd_test.c | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 95af2d78fd31..46027c889e74 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -281,6 +281,24 @@ static void *mfd_assert_mmap_shared(int fd) return p; } +static void *mfd_assert_mmap_read_shared(int fd) +{ + void *p; + + p = mmap(NULL, + mfd_def_size, + PROT_READ, + MAP_SHARED, + fd, + 0); + if (p == MAP_FAILED) { + printf("mmap() failed: %m\n"); + abort(); + } + + return p; +} + static void *mfd_assert_mmap_private(int fd) { void *p; @@ -979,6 +997,30 @@ static void test_seal_future_write(void) close(fd); } +static void test_seal_write_map_read_shared(void) +{ + int fd; + void *p; + + printf("%s SEAL-WRITE-MAP-READ\n", memfd_str); + + fd = mfd_assert_new("kern_memfd_seal_write_map_read", + mfd_def_size, + MFD_CLOEXEC | MFD_ALLOW_SEALING); + + mfd_assert_add_seals(fd, F_SEAL_WRITE); + mfd_assert_has_seals(fd, F_SEAL_WRITE); + + p = mfd_assert_mmap_read_shared(fd); + + mfd_assert_read(fd); + mfd_assert_read_shared(fd); + mfd_fail_write(fd); + + munmap(p, mfd_def_size); + close(fd); +} + /* * Test SEAL_SHRINK * Test whether SEAL_SHRINK actually prevents shrinking @@ -1587,6 +1629,7 @@ int main(int argc, char **argv) test_seal_write(); test_seal_future_write(); + test_seal_write_map_read_shared(); test_seal_shrink(); test_seal_grow(); test_seal_resize();