From mboxrd@z Thu Jan 1 00:00:00 1970 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 55C29C71159 for ; Thu, 19 Jun 2025 07:32:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC2F46B007B; Thu, 19 Jun 2025 03:32:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D99F96B0088; Thu, 19 Jun 2025 03:32:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C88F46B0089; Thu, 19 Jun 2025 03:32:32 -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 B54456B007B for ; Thu, 19 Jun 2025 03:32:32 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1440E100BA8 for ; Thu, 19 Jun 2025 07:32:32 +0000 (UTC) X-FDA: 83571332544.06.B8C6E44 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2088.outbound.protection.outlook.com [40.107.92.88]) by imf24.hostedemail.com (Postfix) with ESMTP id F1F5E18000F for ; Thu, 19 Jun 2025 07:32:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=DmHaTI5j; spf=pass (imf24.hostedemail.com: domain of shivankg@amd.com designates 40.107.92.88 as permitted sender) smtp.mailfrom=shivankg@amd.com; dmarc=pass (policy=quarantine) header.from=amd.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=1750318349; 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: references:dkim-signature; bh=DyAu5QLsuT5D7J4WeL4pZ2R/Mfd55tZpEG2h/AxJN3w=; b=iuw7vOamDIosSu+/rLd9ylFIxqO0oln1sNGvVpe2tFGzFPdhLgUS6Y2AcPBRJZSOuZ0u3+ evMhbxzs/JBwln+a8gtQAyDnuyyVc5E9SeEjgObjPSIbsOZi6NcqrpK7iuoOqylqCUuozL yKvnLQ7sGg78GEPbJjV+YlN9K9RGwFA= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=DmHaTI5j; spf=pass (imf24.hostedemail.com: domain of shivankg@amd.com designates 40.107.92.88 as permitted sender) smtp.mailfrom=shivankg@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1750318349; a=rsa-sha256; cv=pass; b=S9yHm0faZFbawDzWO3iJ2wGbq2DdcruCcbB9tcktGUk5THT9nteSPQLosGk4SBTN6Zm02g 0g1hAOf2n88PM9ipQtWCVRIwnyxymK3S49DBOqUVHuqRJ7tpoJ3NNaxQNWE7GKdXurmXy8 zV/l+G0vuZA7LevBIvgSaPDtAOywvxI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OMJKDkrPgRoaO68OZeiDsqqLMHPRfGUXfyXqlOj0+7fm4efPAw2GFdP2VJdxhA2dVtlhHkY5ajX5I8H7q5k7MfqwmgS+D+hS2d5TpBC9g78I7QBRFYdqpHOHrD5v2vId4Yek79VilDduSNme9ff7OS8aYlAbIdCoZQ9YhgD63T+HoQT8j+yLd6Xdi7kMMHQhkT7Lds6Wq1rO2iqmyL1QPZTOQmqcPXgSIazYCziSvrthSEW4cU1CW02qoe9JqDi+skq7+Lcp7TAWKnGj/CqIylicXdjTmlyYkhVCxRmH9geVvz7egCzhIH4ZaHxNXcRmz7wExvWT4UpFpM3bnglQnQ== 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=DyAu5QLsuT5D7J4WeL4pZ2R/Mfd55tZpEG2h/AxJN3w=; b=XhlTAk13vthC+T3tYamE97Cll4ZKBS1MR3FAcAmufphBnd7VYFLYqnaVgj2RMbL9CpyRCdnqLkxrZkJekxDSLoz8U5aU1NtJaZ8v2fUzt9pX/J8r07vUvW6Y6CVZ1c90Mmh1eW1WrnxRklYTYdB1h5OVCJkIa5Rc9rDX52a02ZlBz1aL4Rad6E07/28G0e+YLKiK8QxgEphRWzP09LOXv9w9ziqzcGLJGFEiOZrZ5XnSV9q1MFn+4vftod0Rap8MTbcIt9mUunvFvdd51jh/5SvtAIqobLljtgRew/cB95Vsu1vonkngBfa5udzS5NZhMrmXh8Mxknq4xEO938jr3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DyAu5QLsuT5D7J4WeL4pZ2R/Mfd55tZpEG2h/AxJN3w=; b=DmHaTI5jJSdPZw/qgwLEm/6wS0QMQ5W9+Vbd6kIsYQgj+f+CPnyA+Mtmkzj5G4PojyfGF3bCVcNHe2OqkRhe4mPoiroflhXhnRe4UNWmFw95X0tJTZ6O++YDncF6pCT1lRer8kAd+BTbQwqFzJDHCehyF1+90JFs5xbTkdcczc0= Received: from CH5PR03CA0001.namprd03.prod.outlook.com (2603:10b6:610:1f1::29) by SJ1PR12MB6051.namprd12.prod.outlook.com (2603:10b6:a03:48a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.28; Thu, 19 Jun 2025 07:32:24 +0000 Received: from CH1PEPF0000A347.namprd04.prod.outlook.com (2603:10b6:610:1f1:cafe::f9) by CH5PR03CA0001.outlook.office365.com (2603:10b6:610:1f1::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8835.35 via Frontend Transport; Thu, 19 Jun 2025 07:32:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A347.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8857.21 via Frontend Transport; Thu, 19 Jun 2025 07:32:23 +0000 Received: from kaveri.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Jun 2025 02:32:17 -0500 From: Shivank Garg To: , , , , , CC: , , , , , , , , , , , , , , , , Subject: [PATCH] fs: export anon_inode_make_secure_inode() and fix secretmem LSM bypass Date: Thu, 19 Jun 2025 07:31:37 +0000 Message-ID: <20250619073136.506022-2-shivankg@amd.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A347:EE_|SJ1PR12MB6051:EE_ X-MS-Office365-Filtering-Correlation-Id: 83113392-21d2-45ab-3bcc-08ddaf036ee5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|7416014|7053199007|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NM0Kow1mtt2rVtSQlJj5W14WK/TjMdoJDJw9GayznIFlB0FqVtHH9vQfGdqE?= =?us-ascii?Q?xNbhLIsLCgdTx9CmZVqCLwzvjWM1FMfHyYUrBtUMM3drZHfIqsaMJmsiriyb?= =?us-ascii?Q?cyIFLUGcuDi3j7EyaoDBZi1JU4dYHrkgG8ycTK+H/hhazTqTPRdl/U1pIJfw?= =?us-ascii?Q?3AfkiKNqsHzdLdclisZ1YRHzHzfTwdvTfMk6w19KVZjGXm0TzHVYsUagiO+D?= =?us-ascii?Q?Q6mdFzywI71qgqIz55W+yp7W9zK8CxkzxeXJxiGkmaLbVYyP5CTpLr8Mrjx2?= =?us-ascii?Q?Zqze6zJtrlvuNMGG9aJBxgCkFNg6sttfzunNb+ra0KP+WH8UZdgGx4fnUvhd?= =?us-ascii?Q?2eeQZXrRug1eYhN3FuESk2j1EfhMxgs1kHSmtwfk+6f8LXEfIdaLDHL1UG7c?= =?us-ascii?Q?MFQfhatn7dg2Nzqp5FGiAN8tzCqohrvN/pXU/BMaVPKXQKLEZJ4Yzayp3rnB?= =?us-ascii?Q?2m4iHGEZ3m8woHcoONKoANumkVjpL6neBq+oky+1INTzHDHklDq2xw+/IZ9z?= =?us-ascii?Q?DOiJv72u7vrkmucysT61dJA6uTE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oMz3RCpaVLwiB00fpxXhwpxdimMArClo9E2r3zkSm1mHZmCcm?= =?us-ascii?Q?sSP4pxdWgjJH2IRDUDrT2KFk//D4Y21sU3cMOdqForhmF6hIAYSzd9g1XQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014)(7416014)(7053199007)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2025 07:32:23.6224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83113392-21d2-45ab-3bcc-08ddaf036ee5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A347.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6051 X-Rspamd-Queue-Id: F1F5E18000F X-Stat-Signature: 8be7ghe5xeahajskobrbj4qsgam7zniu X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1750318348-244661 X-HE-Meta: U2FsdGVkX1+4lfQOCg6j035L6QsqDtOEzYAINJ+f5XHOYvTCnsebt+rJoXwgLx0U/br7f5tUFXiBgp59wcqeOGykaM5JTtL5KQlm2XawFObMhMk5NRv0andBHYl5ADBwy0CYb+BYJOfAHBdGnGQ4uDurE21pMI9pZ3XHvKBZ6XxNqqTIuiJ74CiDXgDckX9qP9Y0ENLlV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MG6zOQa65XBJkptUvernnaa4G2713bFxVlmWyFrc9YsoAl67cgRGj3xcnvfCs1qGEPvM9wgZMC7TX5bbufRnWRkNTyAAk0EqG0mjZfiAUHr2b/Y7bnkcpZV3K/qx3pyCO1cFCB2i/A8h0IN4ROEcw/0Rrip1dT1NUAlNlwXaU7K0+OPEGqsMR8D/3M/lAf8iWd6KfVx4/hMZ264gHwE+rnN4bCH8Wkz1L5BmsjMWset2/SwfjdqqWL1e/Hid/TFB2k5gaWSsgirVqn828InZLhM8uQN+EF2wmCb8JMdsYDpk2JQfTxoSdrVJA+sj9Qbd4D69lLxT8mzeuoeq7SPLnxoFNJFL6XjMUcS8LJn6HhkYrch4XeoVboprY3ddSQfTr9raKtGT90szYYNgc1yz9G2o39kkTF4/ZHbCrm3nmO9cxVJUqw= 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: Export anon_inode_make_secure_inode() to allow KVM guest_memfd to create anonymous inodes with proper security context. This replaces the current pattern of calling alloc_anon_inode() followed by inode_init_security_anon() for creating security context manually. This change also fixes a security regression in secretmem where the S_PRIVATE flag was not cleared after alloc_anon_inode(), causing LSM/SELinux checks to be bypassed for secretmem file descriptors. As guest_memfd currently resides in the KVM module, we need to export this symbol for use outside the core kernel. In the future, guest_memfd might be moved to core-mm, at which point the symbols no longer would have to be exported. When/if that happens is still unclear. Fixes: 2bfe15c52612 ("mm: create security context for memfd_secret inodes") Suggested-by: David Hildenbrand Suggested-by: Mike Rapoport Signed-off-by: Shivank Garg --- The handling of the S_PRIVATE flag for these inodes was discussed extensively ([1], [2], [3]). As per discussion [3] with Mike and Paul, KVM guest_memfd and secretmem results in user-visible file descriptors, so they should be subject to LSM/SELinux security policies rather than bypassing them with S_PRIVATE. [1] https://lore.kernel.org/all/b9e5fa41-62fd-4b3d-bb2d-24ae9d3c33da@redhat.com [2] https://lore.kernel.org/all/cover.1748890962.git.ackerleytng@google.com [3] https://lore.kernel.org/all/aFOh8N_rRdSi_Fbc@kernel.org fs/anon_inodes.c | 23 ++++++++++++++++++----- include/linux/fs.h | 2 ++ mm/secretmem.c | 9 +-------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index e51e7d88980a..ca6cfb1cd496 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c @@ -98,14 +98,25 @@ static struct file_system_type anon_inode_fs_type = { .kill_sb = kill_anon_super, }; -static struct inode *anon_inode_make_secure_inode( - const char *name, - const struct inode *context_inode) +/** + * anon_inode_make_secure_inode - allocate an anonymous inode with security context + * @sb: [in] Superblock to allocate from + * @name: [in] Name of the class of the newfile (e.g., "secretmem") + * @context_inode: + * [in] Optional parent inode for security inheritance + * + * The function ensures proper security initialization through the LSM hook + * security_inode_init_security_anon(). + * + * Return: Pointer to new inode on success, ERR_PTR on failure. + */ +struct inode *anon_inode_make_secure_inode(struct super_block *sb, const char *name, + const struct inode *context_inode) { struct inode *inode; int error; - inode = alloc_anon_inode(anon_inode_mnt->mnt_sb); + inode = alloc_anon_inode(sb); if (IS_ERR(inode)) return inode; inode->i_flags &= ~S_PRIVATE; @@ -118,6 +129,7 @@ static struct inode *anon_inode_make_secure_inode( } return inode; } +EXPORT_SYMBOL_GPL(anon_inode_make_secure_inode); static struct file *__anon_inode_getfile(const char *name, const struct file_operations *fops, @@ -132,7 +144,8 @@ static struct file *__anon_inode_getfile(const char *name, return ERR_PTR(-ENOENT); if (make_inode) { - inode = anon_inode_make_secure_inode(name, context_inode); + inode = anon_inode_make_secure_inode(anon_inode_mnt->mnt_sb, + name, context_inode); if (IS_ERR(inode)) { file = ERR_CAST(inode); goto err; diff --git a/include/linux/fs.h b/include/linux/fs.h index b085f161ed22..040c0036320f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3608,6 +3608,8 @@ extern int simple_write_begin(struct file *file, struct address_space *mapping, extern const struct address_space_operations ram_aops; extern int always_delete_dentry(const struct dentry *); extern struct inode *alloc_anon_inode(struct super_block *); +struct inode *anon_inode_make_secure_inode(struct super_block *sb, const char *name, + const struct inode *context_inode); extern int simple_nosetlease(struct file *, int, struct file_lease **, void **); extern const struct dentry_operations simple_dentry_operations; diff --git a/mm/secretmem.c b/mm/secretmem.c index 589b26c2d553..9a11a38a6770 100644 --- a/mm/secretmem.c +++ b/mm/secretmem.c @@ -195,18 +195,11 @@ static struct file *secretmem_file_create(unsigned long flags) struct file *file; struct inode *inode; const char *anon_name = "[secretmem]"; - int err; - inode = alloc_anon_inode(secretmem_mnt->mnt_sb); + inode = anon_inode_make_secure_inode(secretmem_mnt->mnt_sb, anon_name, NULL); if (IS_ERR(inode)) return ERR_CAST(inode); - err = security_inode_init_security_anon(inode, &QSTR(anon_name), NULL); - if (err) { - file = ERR_PTR(err); - goto err_free_inode; - } - file = alloc_file_pseudo(inode, secretmem_mnt, "secretmem", O_RDWR, &secretmem_fops); if (IS_ERR(file)) -- 2.43.0