From patchwork Tue Oct 29 13:03: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: 13854907 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 22806D2AB3B for ; Tue, 29 Oct 2024 13:04:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F6E06B009D; Tue, 29 Oct 2024 09:04:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25BD46B009E; Tue, 29 Oct 2024 09:04:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00E026B009F; Tue, 29 Oct 2024 09:04: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 C1EF16B009D for ; Tue, 29 Oct 2024 09:04:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6FFB21A1550 for ; Tue, 29 Oct 2024 13:04:25 +0000 (UTC) X-FDA: 82726657398.19.E296A34 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id C7CCE14001A for ; Tue, 29 Oct 2024 13:04:04 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ShPfYuJj; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CEF0+pmb; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf09.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.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=1730206904; 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=AiDQwp5SppPm6ae4dVe9eq+4O2yzoe4v2pgxvOajGxE=; b=0WDl9oBh1tlqsfvWPmiPhziuJW5UXqDPk7KxtFHsUjVACJpxFIksWWGydkCHyorGNTLXgH YVAPnOC9FlmV5kDgEJhtqpdLR9irPat8BHR2hzSnHd5LULBXMjH22EPHH97zB7q+1L5OeG QpdC1l+NHTT9yk/iFEd4cPTQXpYm6B8= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1730206904; a=rsa-sha256; cv=pass; b=tFBDia17nFzw/vC/yaX1uyTSql93ldqSShzRIBGi7vixK7BsWNqPF1DYPZzP8sjiMasnTz D5+nV8Plbz3A1ZsLyVH4p+bYQ7rQoe2WtcxWkCS5dDZwwxVbFDw5x/URgn4f8aI7U6isce +HLsJ4JXXNGLJWHhsBYB30j+omKJM1M= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ShPfYuJj; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CEF0+pmb; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf09.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com 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 49TCbnQA032685; Tue, 29 Oct 2024 13:04:11 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=AiDQwp5SppPm6ae4dVe9eq+4O2yzoe4v2pgxvOajGxE=; b= ShPfYuJjQQc7WECx2KsnX7eNv1dDKbqhJmyiA2jwRzRIl6qaHgkDZXORkxl49Xu2 u2B8PgShcnugaIrC1U1S9TXEnRsLDuSJnfqxBjfX2z/ZTJutwJiFiKYUoKGwkGx8 SQJibC5UnMCqdJB5dtyXYBDnwxCbnxXchyjUQaWn00Z+Iw4HGr4KfzcxKqUvg+4i xaXy0qzTjtP2caOhhLji/dvMTuzZMZFQBR0vBYXVFa+l7OEakUj8LWzGHjifwrdp mnTg7F2b7V9i7TBFU1JvOcV9jT27w37Rz/0FTsluiUnsqx0RvPFPjm9pzwXbY1gx 847ptjH9lx5qEa0M2MhRlA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grdp5bvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2024 13:04:11 +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 49TCqEjM011986; Tue, 29 Oct 2024 13:04:10 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2048.outbound.protection.outlook.com [104.47.55.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnacfnea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2024 13:04:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XDrbqWCOl9s07wpdWRb/fQjy9yQml6BrZt0liHkUItNSJOIFVYrki91CiZcYdCRQANNW086sE9tjjZz06DOVsa6yzkyK986s1vfKLdqH3TObuW98bzJ/1DOd2KDsNHm7l9Knqc6D2XWlR+Ta9U4Dk8B144JSPdRW/QE/ZFMu5rR8GiCdP3rsg3o9Sr0OboHVt3o6vQ4gNNoXdrsnmJ16D9/xiKc36nQ7OrPzPcsro4Z//inYDWm2bc7Qha43dZAXDGrCzbOx76fS36JtnTuq8GwDnhIyleIC/m+YnUD8gzsq7Zkel+621FJa4a5PTPyHMt/7QgZe3G5wvzy1Yozs6g== 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=AiDQwp5SppPm6ae4dVe9eq+4O2yzoe4v2pgxvOajGxE=; b=h5Nnwt2rhBA+gBPlb/mgr6QOxCcFVb9rLKidS5j+8ZkxgWxyGA4mBBCUCBstteGjx5q2v6Hz+fbvMDBmhDrWYkaEznWVgF13OGjiXhNJhfJgbt8I0TK90Di+cjyoNSNaoPX5ECg77PKPY6A0ZmIYgNyylf+dTjgHt3GeCCQYLyAc6M8Fmi3cOv6CgpZD74uYJgYKSMxyPjR6B2qWpb5h08homfaaQKq+yL00vnv9P+bCygWXjIdldc+b2sAfMD7Cvuyor27FsYSo3n0q28xvsW20/Fy1UOwLtCr5mhnyx/3ukepFUOXdgfEJ4TnThTMofxH2EfZhkhu6qleEBtzk0g== 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=AiDQwp5SppPm6ae4dVe9eq+4O2yzoe4v2pgxvOajGxE=; b=CEF0+pmbYMaEStGSe01CcQ3BS8mCNWSiPMXseXX3WajFRrcgI5soWOiQ7Y06Ebksx0FwYyTD2J9PnOegZ1chgdWoNRA1mkdI4IMgFko2hqysCkGaDuVh3rRjklSn4m1AOA0nLe7n1uXuA+f399kj0KgRiEeUTvVl1YbmW6hcYdI= 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:07 +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:06 +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 4/5] mm: refactor arch_validate_flags() and arm64 MTE handling Date: Tue, 29 Oct 2024 13:03:46 +0000 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0235.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::6) 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: 6ed47963-c553-4172-5dde-08dcf81a2bc6 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: tLzbKiM8lyGUyAxl0nyiINik8iicflG1G2OzRuz64vvC1b8Ui4VbT2W4OhTecLa35EFRYxJZ63bDb1rEHIebALbPGiyDGIar6ArpPq8u90lveqW3dVplbr78iBQJlNQw8FEK9SK/GJvTt7u/nlv//EO9ZTgCFlf40rD/s33r8lOjMqM6z4G6hMH0+0W8+YrIq0SsV7k4+IKpXjXfBsY9WsNnrvd/6bEWa6/G+407xWzTCgYNrjGgtB76qt1rdDys8cI73NRQJ3dei18k4R4NJtjIV2Sm6EpAuNI+2lInxi0FfmTAUVbsSkJ5L5A50anUutzdhWtUSw14B7/IG4OmVQA/yK+NhT34m5NhW3ywQU1OAENYe0NyUSwJrD6Zl67HDAZydOFyimJOrAaNhQ4MN0Jbw5bB3G+jsIPiYZgLOSS3hz6teZb7oEFtxzx9L4ZQsSH64WetcwbhkXhNGkNH3/VqkIzyHAVjOfFf7+UXTL0WsMmg5rsjNPwxstKB3dhgzebc0+YKsM4wsddnFTkV6C0J2GHecKMtlPqMYzeL6rPmY4nw9DV3frq9nbv458SH04PdzG25QqAkqKwSak+cLWlkXJnRgszE8FUZS0DUlpfno1Idq+ny9AMAKJ7IGiXpb/NINSAVqkGnjclqEl2b9995b5Tqqa95MuNcBvnUWiqU6gv6V8STZW8R4Rugp0K6K/X7UBWaBDjOqw27075K8Rnp2UI6CnvpNaqziGSlxFoiEPDDTmkXyxQqBk8faqdhVuq/jfkFdiECJyWSNNjvrNEDJwU0RwowBsQzmZt+MF4Lcaz7OCy6Wy0CCam4ZYwxtre18M+9OTE5MSOoJ2fk1V9dZg7VuaMTjy4HzKm3VLV7fbK2E43D/0mfT32Lp/T7aGKI/7oMm5Wo3sxhv/PCSYJuxbcDBi/FUE0tXfaSMHiM4fPYZraAWNVdROmX7jbMBsFnHOfS7Z+nrvrOo0rEWZXe2kBuguQRW6lCrC4OiSeqAy712VBcEmOqjleE8Y2kDYPwjEGVx9Rawro/4DPclXgS6M72mey/+PzH7cL9bXqqP0UNNi4L2WWzuLdKWzRg0Fx8/YEYxRKBKkv9gl4pGdTgECDRxcYqedyJH8vXzzLbNW2uDwTptaQCwcmsndcOIb89yRk/I3CoR8aNcO1ObnSmObHYb4FBU1mLnb/e6fqeOChN/dUw4Zsv2CpXA1gXaIL5HvOGQ1pxGtN1u0lOsxotxaU1yALaXYwLrsZrE0xy1ZtjczffV6qfkHiw0CbHDM0hMEQI2aY8zngbRkyFnSAOmAm/fHGEQyy2F76iqHmOqjJ2L1x/Xi2eOB5YvMP0 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: kujRqwb4gQD9PKlmVcqK6vkAUol5EgoUWFg3HRBAw2wvWFEi3Ji482t6oiB0NrcyoILyX7ypP9o/MmvANuPDCbVlhIEPecxAHNrY1kh0XMoAJ9fDngeV+A8YIqVZ0Dl99EwPLpjzrtJjkw7epWA8YExQU3SMB+BWHz44FiGUogZQ/1gXzvCIoYFaY4WY9ktAbNWxZFzrcoCyzi2L7AvlvycOgy9az+pu1A/kZEysDc3II81EVB3JIFDy/Jsz9DlCbBfp9+qyW5gkySyLOLYctaJvxdTF7539VOtv2bkAVeI9m3YMXONQrei1o9vlxpNAwQnVcTSh+E9LMMJ1bqKiZfzEMyXVRWI0SbqNFuWy+7Uubi1es0p93Dlu5FyRGZ9xCRK9q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ZzAjwJt0umRsw/FwXXa0WjtB0o2JWu8xPTM/5sP+2m9N68QE0Wh34fXTl6u1cTbhPljRp059kFuZ3NPsusBVLS314ST/KIQSp6IgONVAqmp5g2J+aagWDSHpoYFJMyODKpEo3Nf4w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: tRFTRBErwd/8zhbD6tEqEMUiBGWovUnOSpvtI9D0Tq8YxNMaa0OSGJRxr+4jxyJjm0jQSf2VA8/wteFpf+rp/Nyc3NKCJsi4p1Q0l9hEPjJFq7dFj+VZUTrOs5tP/Ty1T1dJ6mFQOD83bpe9FHeqkLJWSXGyF3GVZKkFaOI375J+Fqx4QiUA4ZeY5iRDIgMii2UX+m3YRIXJ3gdXFLVlS1Mb7jyFcgiSXlyIqnqwJtLX+CR+8gq4LFDJZBsk/c/RFMP3Fc6WewE92oA1I3U8hZY/fJOItlZHA9C9Pk9ZPpVkE1t8LNXZ5/z6iT8ZBg5v3HuWRaf2LdtPHEeOXD3yEUYNLqICUfVBLZL1SA98HGbjoMtwR55Yg6yGD3Zty05wgEJUh5osQLhmdX571xz0LfBv2ytBi0+6XHXPZUVA2rSo4yXWNXL9xI9li3k8IJhv8JyMGMLwxOpJZeU8DkzuLUk1cvW7azeZeGLqqEV0GY9KFK2CRcqS0DzuD7dvCKCZbMk+K7+K23TuwkAaUSamzZHmBazL7qx2qp7nVVgYBU4K7u7SaTk6liBp9TlvptObVSYM6Y/m8r/iHDhO5rTkuDdGv+fbgA2YakpKVpbC7EA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ed47963-c553-4172-5dde-08dcf81a2bc6 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:06.9387 (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: f6LKW9BeY39ISY5eLn54WkxA5+uK2qWk1oFp6d9f2dj6w0P+lYMW/KiRoq74Q3syhpGNJb4tGMXwc/KsnBgapal84MvnHDtYOtYbI5Gc+48= 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 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410290099 X-Proofpoint-ORIG-GUID: eWpePnnw00gVN1KUmcU6rvKUO-Q043Vm X-Proofpoint-GUID: eWpePnnw00gVN1KUmcU6rvKUO-Q043Vm X-Rspamd-Queue-Id: C7CCE14001A X-Stat-Signature: jn5kmim9da6q9rhueyededokesfbef8x X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1730207044-797212 X-HE-Meta: U2FsdGVkX18z49Ou4l7Ij2f2RSfODWhLUYoiGVi409f3PuCovgyL4l6YObDe8cfqHiQHoqhoPM8Zqo76GmBA+FTxkH8fCtoJNmebus8+FTlplV/lwfIgUt3oM0I9dBY8eqvgyUlRK7snI3ve2fcwzm9LdZk0tASwsFsXIAz8QQvGIY2C2lPI6XiLqoj2mSv8SiDnyR39j14BuYcKQWAc3z4GZD8D7JvZfW1cqzbF9HnsWOlyXLg4Gf/SnSIluvGXrZJUZgAY2C2//1HLnb3IrbkVmGCdAMfTpCsQaepCTkHiEwdK7n5N07NRQD+0lyrcNOCQ17+ulimhoMCcVHv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L8sLk/dkt8AN3PHU1mjagUFHPc/fxzZ8ZEWPItha4UnsoKEaD4mAP3N5NHii2Iz3QIEt4bi1yRu77ROoE0CZ+uXfjsfiB14E33YkYmEMHe4KIODNtYsFpw0yAxqm144DQdItkf0vGh4EyJadV2GfrLhmy3XKK9ybYwADVtUOJQsJcr4MX3OxM6kuP1k2gaGQ== 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: Currently MTE is permitted in two circumstances (desiring to use MTE having been specified by the VM_MTE flag) - where MAP_ANONYMOUS is specified, as checked by arch_calc_vm_flag_bits() and actualised by setting the VM_MTE_ALLOWED flag, or if the file backing the mapping is shmem, in which case we set VM_MTE_ALLOWED in shmem_mmap() when the mmap hook is activated in mmap_region(). The function that checks that, if VM_MTE is set, VM_MTE_ALLOWED is also set is the arm64 implementation of arch_validate_flags(). Unfortunately, we intend to refactor mmap_region() to perform this check earlier, meaning that in the case of a shmem backing we will not have invoked shmem_mmap() yet, causing the mapping to fail spuriously. It is inappropriate to set this architecture-specific flag in general mm code anyway, so a sensible resolution of this issue is to instead move the check to arch_validate_flags() itself. This requires a modification to the arch_validate_flags() signature to pass in a pointer to the struct file associated with the mapping, however this is not too egregious as this is only used by two architectures anyway - arm64 and sparc. So this patch performs this adjustment and moves the check to arch_validate_flags() which resolves the issue. We'd ideally like to have eliminated the arch_calc_vm_flag_bits() case, but we risk inadvertently changing behaviour as we do not have mmap() flags available at the point of the arch_validate_flags() check and a MAP_ANON | MAP_HUGETLB case would be accepted for MTE currently, but a MAP_SHARED | MAP_HUGETLB would not. This is likely an oversight but we want to try to keep behaviour identical to before in this patch. So continue to check VM_MTE_ALLOWED which arch_calc_vm_flag_bits() sets if MAP_ANON. Reported-by: Jann Horn Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails") Cc: stable Acked-by: Vlastimil Babka Tested-by: Mark Brown Signed-off-by: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- arch/arm64/include/asm/mman.h | 29 +++++++++++++++++++++++++---- arch/sparc/include/asm/mman.h | 5 +++-- include/linux/mman.h | 2 +- mm/mmap.c | 2 +- mm/mprotect.c | 2 +- mm/shmem.c | 3 --- 6 files changed, 31 insertions(+), 12 deletions(-) -- 2.47.0 diff --git a/arch/arm64/include/asm/mman.h b/arch/arm64/include/asm/mman.h index 9e39217b4afb..94925a0482e3 100644 --- a/arch/arm64/include/asm/mman.h +++ b/arch/arm64/include/asm/mman.h @@ -6,7 +6,9 @@ #ifndef BUILD_VDSO #include +#include #include +#include static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, unsigned long pkey) @@ -60,15 +62,34 @@ static inline bool arch_validate_prot(unsigned long prot, } #define arch_validate_prot(prot, addr) arch_validate_prot(prot, addr) -static inline bool arch_validate_flags(unsigned long vm_flags) +static inline bool arch_validate_flags(struct file *file, unsigned long vm_flags) { if (!system_supports_mte()) return true; - /* only allow VM_MTE if VM_MTE_ALLOWED has been set previously */ - return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED); + if (!(vm_flags & VM_MTE)) + return true; + + /* + * We explicitly permit MAP_ANONYMOUS and shmem backed mappings to use + * MTE. We check for shmem explicitly here. + * + * The MAP_ANONYMOUS case is handled by arch_calc_vm_flag_bits() which + * explicitly sets VM_MTE_ALLOWED which we check for here also. + * + * Ideally we'd perform both checks here but existing semantics support + * hugetlb in MAP_ANONYMOUS mode but not a MAP_SHARED mapping, which is + * likely unintended but we maintain identical behaviour for + * consistency. + */ + if (vm_flags & VM_MTE_ALLOWED) + return true; + if (shmem_file(file)) + return true; + + return false; } -#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags) +#define arch_validate_flags(file, vm_flags) arch_validate_flags(file, vm_flags) #endif /* !BUILD_VDSO */ diff --git a/arch/sparc/include/asm/mman.h b/arch/sparc/include/asm/mman.h index af9c10c83dc5..d426e1f7c2c1 100644 --- a/arch/sparc/include/asm/mman.h +++ b/arch/sparc/include/asm/mman.h @@ -10,6 +10,7 @@ int sparc_mmap_check(unsigned long addr, unsigned long len); #ifdef CONFIG_SPARC64 #include +#include static inline void ipi_set_tstate_mcde(void *arg) { @@ -54,11 +55,11 @@ static inline int sparc_validate_prot(unsigned long prot, unsigned long addr) return 1; } -#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags) +#define arch_validate_flags(file, vm_flags) arch_validate_flags(file, vm_flags) /* arch_validate_flags() - Ensure combination of flags is valid for a * VMA. */ -static inline bool arch_validate_flags(unsigned long vm_flags) +static inline bool arch_validate_flags(struct file *file, unsigned long vm_flags) { /* If ADI is being enabled on this VMA, check for ADI * capability on the platform and ensure VMA is suitable diff --git a/include/linux/mman.h b/include/linux/mman.h index 8ddca62d6460..82e6488026b7 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -117,7 +117,7 @@ static inline bool arch_validate_prot(unsigned long prot, unsigned long addr) * * Returns true if the VM_* flags are valid. */ -static inline bool arch_validate_flags(unsigned long flags) +static inline bool arch_validate_flags(struct file *file, unsigned long flags) { return true; } diff --git a/mm/mmap.c b/mm/mmap.c index ab71d4c3464c..40b5858ae875 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1511,7 +1511,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, } /* Allow architectures to sanity-check the vm_flags */ - if (!arch_validate_flags(vma->vm_flags)) { + if (!arch_validate_flags(file, vma->vm_flags)) { error = -EINVAL; goto close_and_free_vma; } diff --git a/mm/mprotect.c b/mm/mprotect.c index 6f450af3252e..c6db98b893fc 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -816,7 +816,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, } /* Allow architectures to sanity-check the new flags */ - if (!arch_validate_flags(newflags)) { + if (!arch_validate_flags(vma->vm_file, newflags)) { error = -EINVAL; break; } diff --git a/mm/shmem.c b/mm/shmem.c index 4ba1d00fabda..e87f5d6799a7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2733,9 +2733,6 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma) if (ret) return ret; - /* arm64 - allow memory tagging on RAM-based files */ - vm_flags_set(vma, VM_MTE_ALLOWED); - file_accessed(file); /* This is anonymous shared memory if it is unlinked at the time of mmap */ if (inode->i_nlink)