From patchwork Mon Dec 16 21:14:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13910582 Received: from outbound-ip191a.ess.barracuda.com (outbound-ip191a.ess.barracuda.com [209.222.82.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E43301D0F61 for ; Mon, 16 Dec 2024 21:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734383672; cv=fail; b=g2K2gEsdEeXBW3u1ujgtpfSst0eijdPlpq5Nz+vBeV1S/fBav/VxrC+q4swl/Quh2nqkrJgVwjGDnGmbaWVotHSYQi60TTbvhwLpxjShR2PHRxUfQcxcREiZ3LYuZHndr5o59G6ejmt8U7lew61Tw0jSau5pa6hBJ2iYn3dMYbM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734383672; c=relaxed/simple; bh=Y+jl8fICPjJPTBlBvriWveQNF5Y6GNKCsIMoskeilno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U1UPJo10lfl1RNxdJPC1r5LBCFTNwBzGSuzl47DHvVT9mTd1si6Hjpd0KttA1tnUekuKiF7FhrGOUaH79cjsWIchPFr8LJ5G2T6b6XCiZ+OC3o7xktxuhpCJ4iqoJBSMAWnvyvuyzRKoTZ5sV4SDIDnQLDb5XeY61LZaWcdiTdE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b=QzIL1Gat; arc=fail smtp.client-ip=209.222.82.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b="QzIL1Gat" Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by mx-outbound44-94.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 16 Dec 2024 21:14:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L27Le/izyTaq6nlGmByD1/yn0TDZQofvh7Fh7DnisL3vRZ3pd8hJnYeoQnwanOeGQo8DENK/wiC/KnduqKM4rPHwszG3yXEKWj2xwOsWE2l4Wn+ZKxTZaiPekVB9YR5PYfI0ip6e52Mrtcba8yjTUyGj0F4lMWcsmU+EDDWfLwl2LYmRyxfbcaa8swHCBzO+HOY2GX6di/q111RFfmDREkYKORCtWA1DAHbVi8H34x6RRFcYfOd/5zeE+bd6Wa9tE1evhPf/A2yBTC31JMgFBffxwh+Klhky574oCkJ7EuizAv5p9spZPo7SndaK3oiLdbS0pIuwn5aMqvImjw5diQ== 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=ZdSps3YBtV07uS+VoI+vP2dxi49kD12z1ukJ6D+LLZM=; b=hRfvQttVW/pd3G/sACmRhCicCY3vTFakwYTgOglhvzVSLXqTGK7kcHtbXdNMKJDPQFkVihkl0Q64mopz3vXxGyTYlaQvuUP0OTeCi1oIIGgrbLm+nKik+PoU8zTp41uscUulsl3wB4ORVQNVI7uuEAa9kJr4kqvDXDCCWTwlxZUULomXGkqgmY5qc3VL+XAKuZRJ/eTxGJbxsaVqIWMF48/zGlJowp2k8tBhvrjqpy7Z59lJZouVYnMTE8TAwnCxQ/79Y8lV8yMAdI/1Evx2zwMN4wAFrsJX7EGKDlQe42mEngHTX4FCdrTzrW+GUM0mcSdjnqrla4PRdbvMroxU1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZdSps3YBtV07uS+VoI+vP2dxi49kD12z1ukJ6D+LLZM=; b=QzIL1GatPy8uqiXCPAzlQpLr+Y3p9AaPQ4pNubYzhbI5T8JCZTXvUqlOqZqpky/COPNnS9+BmcsHNSApcYI1xnu1+bviASBaFQFdnjssZ4IDoHRisp9fUBuOAk9MeSzwSRcjboJriw0OiICkSv0heSvHe8yhGFed5fUOIRK8T/I= Received: from MW2PR16CA0062.namprd16.prod.outlook.com (2603:10b6:907:1::39) by PH8PR19MB6976.namprd19.prod.outlook.com (2603:10b6:510:228::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Mon, 16 Dec 2024 21:14:13 +0000 Received: from SJ5PEPF000001D4.namprd05.prod.outlook.com (2603:10b6:907:1:cafe::5f) by MW2PR16CA0062.outlook.office365.com (2603:10b6:907:1::39) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Mon, 16 Dec 2024 21:14:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mrp-01.datadirectnet.com; pr=C Received: from uww-mrp-01.datadirectnet.com (50.222.100.11) by SJ5PEPF000001D4.mail.protection.outlook.com (10.167.242.56) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Mon, 16 Dec 2024 21:14:12 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 8F48A4A; Mon, 16 Dec 2024 21:14:11 +0000 (UTC) From: Bernd Schubert Date: Mon, 16 Dec 2024 22:14:06 +0100 Subject: [PATCH v3 1/2] fuse: Allocate only namelen buf memory in fuse_notify_ Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-fuse_name_max-limit-6-13-v3-1-b4b04966ecea@ddn.com> References: <20241216-fuse_name_max-limit-6-13-v3-0-b4b04966ecea@ddn.com> In-Reply-To: <20241216-fuse_name_max-limit-6-13-v3-0-b4b04966ecea@ddn.com> To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, Shachar Sharon , Jingbo Xu , Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734383650; l=2235; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=Y+jl8fICPjJPTBlBvriWveQNF5Y6GNKCsIMoskeilno=; b=fheJ52aKEMXDrTMC/tlz/BJNO8fTP7i0b8vZMJXYCKPKahBG+UdhzeBJG0jEBBuxFYfInzurQ WIHH/M6sdbBCP1IoUQtGCKN1VQMUeePg8/lfV1s+DK+PrAI79TWpHh3 X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D4:EE_|PH8PR19MB6976:EE_ X-MS-Office365-Filtering-Correlation-Id: 4fb126ac-9457-4d18-0d09-08dd1e1696e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?eSz7rcvKLl7lbuV5KGW3rE4ALElqyX8?= =?utf-8?q?MYuck5V1tfSBi/zAN/oRT+KJcwo8LTUKZnEcl4m3XbLErFQAO9H8l9Rpi9EFI+bjT?= =?utf-8?q?baufGzWQeicKkUWgVXQFKvrbUw8Crbv+bjzK8YBPRvLswKBSpvFAUzmNtTyCS3GmI?= =?utf-8?q?tHWA5C7dSOFAReokTZdJjSC8/55Y2EAW31jO3pebL8egEae3zEjD3ICAgUZLXlfe+?= =?utf-8?q?XAJ/fOv621QGZUutz8htp7/cIs0dSw4Z8rUmUvj/19bckqp2cXUTJ8RJAOd74tpew?= =?utf-8?q?pKK8EVlqYCIlRoGESisHXGqjy8/6eZ2Pgr+7OVsAxh+cVFcQTeBvPSZdK7E0Iv9Mt?= =?utf-8?q?5Ul2jK2l4YD21KfifrNMhQWoKF39zXsQneQDOza8rmVm7dK9yCcNV/yrO/EOS2xGO?= =?utf-8?q?QGYzEaDuBHodpS4U69H5lzLT5NO9xs3uOezHeMogqM+DQnIMnW5RRZOIJc4XIhkgF?= =?utf-8?q?4vjGApK79nKep9ykHJ+Yc74+th5YR4llbI0EgjQWP4qdjcZXna7K3Ifm8wLDibrW/?= =?utf-8?q?bHtEQDaMiFHaTuAjR478lM89vN7dicBtGyKK425g8uKEbPQ31dgtPeuPufLIPHNbd?= =?utf-8?q?snRYAJBVo+LlZoW3hPjYkPM1mOm2xy7K5oGN9DnAuxJC63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H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Wn06UK26fSS8cZLnSPNdAxyn5OOUSFXy+ygOnGWae28l7K9G64Ek1YJeuRzmx1S3HEqr6ExFM3yLpt4zaGH3e2MbLQBpjHsOzieYmpB4CHTTBjQV7l4ZE9QbYtz7I9s8PNaLofaOMSHXT6qbATHLJVHkXAeYo/e5YILAQgZIeQotwqBt+xzHkuq5T1EYUqMmcqnac49v0cq64r2nlnLGxziyl/Pemm7xychICjf69COZK9dC080qlIrcZN8aYSSJMQdYPUsRZ84zyA5swnBnose1VWM2YStLGV8wa/XxTdJzmmWyHTBIjeqShrlVBcwbo06dbcDQJerm3rDiOY3Dd9m95kqH+NuQbSi1Tf3EEvhFR7nVA+B5TPrhbXcDgImaUkNboCp2Munl2+pf9WSSQsMQoBVAI0HjfEN73qK94rfnVWokkU4vhod+L1Ndr/Lf1zu2QhGybIYXfX3y0y/5dJRUi3jbWUw4s7JXhVAae8ObBPhNGmYy+ZcbUAQ+SM+22vw/duHyVi6rbexz5Owv3GECHN4PjVhXUO8KK2MblQJF40gHtb+NX5BU/jQxrADCKV3lSwXWikSto08I8xmf4K9C5G5zt2mh4Y76gPxt6QDyjpe1GxqZWXOn36g+TEV+KQYjXhPL3uGBRngIFGSnXQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 21:14:12.4920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fb126ac-9457-4d18-0d09-08dd1e1696e0 X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=753b6e26-6fd3-43e6-8248-3f1735d59bb4;Ip=[50.222.100.11];Helo=[uww-mrp-01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001D4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB6976 X-BESS-ID: 1734383658-111358-8094-8412-1 X-BESS-VER: 2019.1_20241212.2019 X-BESS-Apparent-Source-IP: 104.47.73.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkaGZgZAVgZQMM3U2CQxycLSMC kxMcnE1CA12dggNdEoJdksJcUkKSlZqTYWAOjb6fxBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.261160 [from cloudscan9-188.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 fuse_notify_inval_entry and fuse_notify_delete were using fixed allocations of FUSE_NAME_MAX to hold the file name. Often that large buffers are not needed as file names might be smaller, so this uses the actual file name size to do the allocation. Signed-off-by: Bernd Schubert Reviewed-by: Jingbo Xu --- fs/fuse/dev.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 27ccae63495d14ea339aa6c8da63d0ac44fc8885..c979ce93685f8338301a094ac513c607f44ba572 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1525,14 +1525,10 @@ static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size, struct fuse_copy_state *cs) { struct fuse_notify_inval_entry_out outarg; - int err = -ENOMEM; - char *buf; + int err; + char *buf = NULL; struct qstr name; - buf = kzalloc(FUSE_NAME_MAX + 1, GFP_KERNEL); - if (!buf) - goto err; - err = -EINVAL; if (size < sizeof(outarg)) goto err; @@ -1549,6 +1545,11 @@ static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size, if (size != sizeof(outarg) + outarg.namelen + 1) goto err; + err = -ENOMEM; + buf = kzalloc(outarg.namelen + 1, GFP_KERNEL); + if (!buf) + goto err; + name.name = buf; name.len = outarg.namelen; err = fuse_copy_one(cs, buf, outarg.namelen + 1); @@ -1573,14 +1574,10 @@ static int fuse_notify_delete(struct fuse_conn *fc, unsigned int size, struct fuse_copy_state *cs) { struct fuse_notify_delete_out outarg; - int err = -ENOMEM; - char *buf; + int err; + char *buf = NULL; struct qstr name; - buf = kzalloc(FUSE_NAME_MAX + 1, GFP_KERNEL); - if (!buf) - goto err; - err = -EINVAL; if (size < sizeof(outarg)) goto err; @@ -1597,6 +1594,11 @@ static int fuse_notify_delete(struct fuse_conn *fc, unsigned int size, if (size != sizeof(outarg) + outarg.namelen + 1) goto err; + err = -ENOMEM; + buf = kzalloc(outarg.namelen + 1, GFP_KERNEL); + if (!buf) + goto err; + name.name = buf; name.len = outarg.namelen; err = fuse_copy_one(cs, buf, outarg.namelen + 1); From patchwork Mon Dec 16 21:14:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13910581 Received: from outbound-ip191a.ess.barracuda.com (outbound-ip191a.ess.barracuda.com [209.222.82.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E42DE1CEADD for ; Mon, 16 Dec 2024 21:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734383671; cv=fail; b=jrx0yvJ9OhjbEp4hzvQabZV2N/HdZsEFSqPZyU7x/vl4ceiCgOj9aLUSt63RzZu+LMjDnd3IRLv62I836I0QlZduSofjYItnyR1jvZkBF4QL8m/m0XIqW6rnjgK29LLOgllM1wQmZMsG8hKpKbeV+Q7Ll3BcRfEx5bviO6jqkpY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734383671; c=relaxed/simple; bh=+g/1Dx0SW50nuo8vH+HhLcRdENQtTJ1dYpIuOife0rg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M6ZXYKtD5dInEKbasHX5tvZxPQZmsitQqqBNG63NkL68bZ8CrULW/R1XdQxowAU8qkYjd/kJSv9CTZIy1jKCDxrM1bVeuGxTMkU8aJQEpXGPEeB70+QyQXdMWtkWkNuAG5ZvKf0DZvi85dLJdOSLVszjzfQdD7am3w9tIMdRuQE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b=DiQw0Gtm; arc=fail smtp.client-ip=209.222.82.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b="DiQw0Gtm" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by mx-outbound11-114.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 16 Dec 2024 21:14:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u3NSOupT+Tm4O7DvYGT+LGCXW1l6iCHqgoJhmhtVdQ5diIR9T3g4utiUJvN841u2RdnDiLO4V0a1NL2Jdr6xzn1+H3uhY3//Ei+GtDziBTWowmfzNKN4oGJ6rtCaqS8uywkoL3ZCu6KySfgCM1tbibOUOkl2t9AXqG7YHvW+KNO9tIBEq0ZOEMGuNDfmwAx5jKGmMwc35WugQsCkQDN7/S7/s1qaSG3DzcHIjobhTnnYgM/QuQrJjnFLNBQ6WpkCo540Fpumtim1l8Fqgp+Dcg9KH0QqRyAdYpYrA5tFQFmdnEyN1slIt4TRNLU3S5N379p7dAUhhfoKK/8i9zmfYA== 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=cmOBH6iKqQO4OdA78C0LdGCaUZLawz9LwMEYVmyY0UE=; b=aNw3w/Fl6G7Zu8+j4cO520bj+Q/cAfR2T5UkqlWdHUclE8T3PSvY5XOG1rlVZdS+i3Rrd06WSaUnYKW2hyR9oiGCjnOfY3UXdkZfDVgvKcnmH3fPtOGxoAnue/yJ4pKDSxwnlGg3jxB82MVWYUxMyCvf3quXpmJ/emVOps2Mu4TecM30mhn6AACAvpCZx5HGSv0ay373mUBmMP+UQ1z2bp4FbsMI4Ou5wkEWgITLP9UFx9sONY0C8lGYM+t7rQMNcBPSsJU7/+SZHeg4MDV2d+CesMgGyL/koi/7a05WanLDK5ymOZsuvh2jEOhQ8FGa20+jqi2KTQej75t2SxQkJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cmOBH6iKqQO4OdA78C0LdGCaUZLawz9LwMEYVmyY0UE=; b=DiQw0GtmFc740uj+EDAiyfOR2auwS8J4UpyXDKjnAQ29h/33DO/02rYJGGGF/dBiNsf0vajZpAEqhAt7CC0QAItSSmTxX3bsFauJC75dCfSy6xPZC3DkV4lBj6V/uCQ1wpFlFwgDr44IgI76bWgOp3Ghej+FygLHmGmbkSh1yxM= Received: from BN9PR03CA0183.namprd03.prod.outlook.com (2603:10b6:408:f9::8) by DS0PR19MB7224.namprd19.prod.outlook.com (2603:10b6:8:133::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.20; Mon, 16 Dec 2024 21:14:14 +0000 Received: from BN2PEPF00004FC1.namprd04.prod.outlook.com (2603:10b6:408:f9:cafe::e8) by BN9PR03CA0183.outlook.office365.com (2603:10b6:408:f9::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.20 via Frontend Transport; Mon, 16 Dec 2024 21:14:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mrp-01.datadirectnet.com; pr=C Received: from uww-mrp-01.datadirectnet.com (50.222.100.11) by BN2PEPF00004FC1.mail.protection.outlook.com (10.167.243.187) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Mon, 16 Dec 2024 21:14:13 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 88A4B55; Mon, 16 Dec 2024 21:14:12 +0000 (UTC) From: Bernd Schubert Date: Mon, 16 Dec 2024 22:14:07 +0100 Subject: [PATCH v3 2/2] fuse: Increase FUSE_NAME_MAX to PATH_MAX Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-fuse_name_max-limit-6-13-v3-2-b4b04966ecea@ddn.com> References: <20241216-fuse_name_max-limit-6-13-v3-0-b4b04966ecea@ddn.com> In-Reply-To: <20241216-fuse_name_max-limit-6-13-v3-0-b4b04966ecea@ddn.com> To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, Shachar Sharon , Jingbo Xu , Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734383650; l=4423; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=+g/1Dx0SW50nuo8vH+HhLcRdENQtTJ1dYpIuOife0rg=; b=eydZoKGARj0DSPQeHwgcPoLVfJtXYXhup2e2RnqRneSdAo4CaNrs9/Pw701vUrUcN132AJRMW wnBAs2zKKrNClilK6Nb9IabndDBVdQOZ67DuQXVAZnb6YyYAztu0TGq X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FC1:EE_|DS0PR19MB7224:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fe93142-3af1-40bf-3e3f-08dd1e169796 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?mwKQ7nAxYoIipq1AJgfRn9+7jbIPop0?= =?utf-8?q?RX2FadhIEozlgTQE3hMm1gepyjuTT/Q54sSt0yJMJd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wYTsmRMJnJKNZLHPw92rKWmU6Kk?= =?utf-8?q?xyK2uBlt2ZHFsOVVeYvp+eURUKgU7OIpTZA1JP8iZCiyZcfhYOj7fC5gsB2tpvhgA?= =?utf-8?q?WVDHmQHFZNEMLSChBKeKJNL8L8fcxMUQFTYJsFESAnUhN3fo7qmgR2cSSN+hGJidE?= =?utf-8?q?rGqzTbe7GD+pRlboautEeJWwiBh70/qUgw5WNpukPSxSqR6jIGVAxFjvF8lud+Sxl?= =?utf-8?q?SrFXLJ/K4KHxgHgoqlvkjqX/wEj50x7gWM95RXTKHH5uozYD5Wvbgbdg3iKdLzfEW?= =?utf-8?q?83r2M6RXZpupk7sxbLx/wyCS0+nt8mdwa/gSAy8w6f+GEDvVfH9uSVWqulCn+LHwE?= =?utf-8?q?ElNvzmRDX/cYX/upiWB9X1vN7Hgr6R2Z/x1t96WPrKCr1q4xUjIvwAZsBbeMnPqYv?= =?utf-8?q?BPLwEW4JnG/BrwxaLLlaNvhKNvY/B+Xt6BuIwi3CgWFKyjR+Z55/vCHGqiwmBNPtz?= =?utf-8?q?RYTzysWiafpWbtc/UXJT9JnXSRH3M5UmVUGF/Yy1rMR9SIGbN33dfw=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mrSfaqXPnsbnO8PMeUjiQjHGgIoBtayrzxK+SWe+aiac4KjQmsYioedFhkxDn5Cb/RgqD0cmAsXtnKy0/yVEGWQprqW66fiopqorZT08U+5R+sJgMkw2RPP1wDSN9BWlhm7+bFkhlIKZVnfeafexSm57BxAb1nt023qFFg+VRD4+7DYjmpFwLL+oxnQuu95Sbof2wlaRFyua6J4ELHRnOo13S8PH8oHp2dqeYPzNhzEoYj25ucv2fsge8+85pHEqgY5iPGu2Rgukp1cUnE9A0vElAG7M3NUnHs9Ghc+ygvaezuRZCYRt5A6Lt+6a6mdVbI48cXj1OrRH4D+nyb0EZRWS3urSMXwObj5scb+nnhHDJgFeT52Xj4hwmESzpj5g311Jv7LgqqYDqGIgKH3uHxcOY/a5InEzjfE40I1H+zCO74yV61GiNxmf10OaEkzjoJjbNi1OiaTdAwR6lP5DjECJJDClpjWky+QTb904A8dFcESDRrVi7ZWKisRd3l+e1PC4Lxx3cyOdxpcm2sExZODDtJZFacDJ0MMl7IzKB1z5cILvmcIeR/WtaDSfaxd83gCPG/rSm2VUsd7R+F9TU23e130gen4WfXiqlH/Ievs/Fs2Di2IaBEwDO6w5grP8pcVLPxuXzln6O4eQGC4K8w== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 21:14:13.6079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fe93142-3af1-40bf-3e3f-08dd1e169796 X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=753b6e26-6fd3-43e6-8248-3f1735d59bb4;Ip=[50.222.100.11];Helo=[uww-mrp-01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF00004FC1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR19MB7224 X-BESS-ID: 1734383656-102930-17820-8818-1 X-BESS-VER: 2019.1_20241212.2019 X-BESS-Apparent-Source-IP: 104.47.66.47 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibGBoZAVgZQMCU10cI00SAxzc TI1NgszTLVJC010dzcNNXMzDTVPNVYqTYWADfEZ0RBAAAA X-BESS-Outbound-Spam-Score: 1.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.261160 [from cloudscan19-230.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.50 BSF_RULE_7582B META: Custom Rule 7582B 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=1.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_RULE_7582B, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Our file system has a translation capability for S3-to-posix. The current value of 1kiB is enough to cover S3 keys, but does not allow encoding of %xx escape characters. The limit is increased to (PATH_MAX - 1), as we need 3 x 1024 and that is close to PATH_MAX (4kB) already. -1 is used as the terminating null is not included in the length calculation. Testing large file names was hard with libfuse/example file systems, so I created a new memfs that does not have a 255 file name length limitation. https://github.com/libfuse/libfuse/pull/1077 The connection is initialized with FUSE_NAME_LOW_MAX, which is set to the previous value of FUSE_NAME_MAX of 1024. With FUSE_MIN_READ_BUFFER of 8192 that is enough for two file names + fuse headers. When FUSE_INIT reply sets max_pages to a value > 1 we know that fuse daemon supports request buffers of at least 2 pages (+ header) and can therefore hold 2 x PATH_MAX file names - operations like rename or link that need two file names are no issue then. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 4 ++-- fs/fuse/dir.c | 2 +- fs/fuse/fuse_i.h | 11 +++++++++-- fs/fuse/inode.c | 8 ++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index c979ce93685f8338301a094ac513c607f44ba572..3b4bdff84e534be8b1ce4a970e841b6a362ef176 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1538,7 +1538,7 @@ static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size, goto err; err = -ENAMETOOLONG; - if (outarg.namelen > FUSE_NAME_MAX) + if (outarg.namelen > fc->name_max) goto err; err = -EINVAL; @@ -1587,7 +1587,7 @@ static int fuse_notify_delete(struct fuse_conn *fc, unsigned int size, goto err; err = -ENAMETOOLONG; - if (outarg.namelen > FUSE_NAME_MAX) + if (outarg.namelen > fc->name_max) goto err; err = -EINVAL; diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 494ac372ace07ab4ea06c13a404ecc1d2ccb4f23..42db112e052f0c26d1ba9973b033b1c7cd822359 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -371,7 +371,7 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name *inode = NULL; err = -ENAMETOOLONG; - if (name->len > FUSE_NAME_MAX) + if (name->len > fm->fc->name_max) goto out; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 74744c6f286003251564d1235f4d2ca8654d661b..5ce19bc6871291eeaa4c4af4ea935d4de80e8a00 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -38,8 +38,12 @@ /** Bias for fi->writectr, meaning new writepages must not be sent */ #define FUSE_NOWRITE INT_MIN -/** It could be as large as PATH_MAX, but would that have any uses? */ -#define FUSE_NAME_MAX 1024 +/** Maximum length of a filename, not including terminating null */ + +/* maximum, small enough for FUSE_MIN_READ_BUFFER*/ +#define FUSE_NAME_LOW_MAX 1024 +/* maximum, but needs a request buffer > FUSE_MIN_READ_BUFFER */ +#define FUSE_NAME_MAX (PATH_MAX - 1) /** Number of dentries for each connection in the control filesystem */ #define FUSE_CTL_NUM_DENTRIES 5 @@ -893,6 +897,9 @@ struct fuse_conn { /** Version counter for evict inode */ atomic64_t evict_ctr; + /* maximum file name length */ + u32 name_max; + /** Called on final put */ void (*release)(struct fuse_conn *); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3ce4f4e81d09e867c3a7db7b1dbb819f88ed34ef..4d61dacedf6a1684eb5dc39a6f56ded0ca4c1fe4 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -978,6 +978,7 @@ void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm, fc->user_ns = get_user_ns(user_ns); fc->max_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; fc->max_pages_limit = fuse_max_pages_limit; + fc->name_max = FUSE_NAME_LOW_MAX; if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_backing_files_init(fc); @@ -1335,6 +1336,13 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, fc->max_pages = min_t(unsigned int, fc->max_pages_limit, max_t(unsigned int, arg->max_pages, 1)); + + /* + * PATH_MAX file names might need two pages for + * ops like rename + */ + if (fc->max_pages > 1) + fc->name_max = FUSE_NAME_MAX; } if (IS_ENABLED(CONFIG_FUSE_DAX)) { if (flags & FUSE_MAP_ALIGNMENT &&