From patchwork Fri Dec 13 16:01:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13907411 Received: from outbound-ip168b.ess.barracuda.com (outbound-ip168b.ess.barracuda.com [209.222.82.102]) (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 0E7FC1DFDBE for ; Fri, 13 Dec 2024 16:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.102 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734105721; cv=fail; b=VtistoQSjedU83vzDel5qDiCHJBrcmGJOC6h8UsY9uC1COeDuUb1iq4YDNhshekQY5RLaeeoed1ysv/xS43aDldFqBk2SQTKUDEenqPX/HVTEQx5uni42qNxQ5dnZyTx7aMoHagVLVQ0EYxXj7mO2oxLAPVm0Fv6htmr4m75irY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734105721; c=relaxed/simple; bh=Y+jl8fICPjJPTBlBvriWveQNF5Y6GNKCsIMoskeilno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dtgilRu8m9Z2/ZhZY6y6yO+z60KSQNMfoQSw0Lumbm6F6E1k12gDlzIegMeHy7na5TSUIK+VdCxufM2AyLPzQleJ3n04FDyuPzU+zV5oih+/zDeIgX3ByaxldTrXxjPaptdIqqWi1zzuATt7M563QGOsGPyV3oPP92STbU5o9LU= 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=fNUU4ur4; arc=fail smtp.client-ip=209.222.82.102 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="fNUU4ur4" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2044.outbound.protection.outlook.com [104.47.70.44]) by mx-outbound41-19.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 13 Dec 2024 16:01:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UXo085mgGMsRD1IUpMXqVB7tlIgWcOb1svCg6JyCQ7KDO0pofJ2Lf3y5Y+7NZhnIotI0xxdFiufA1rII7NoCJs3B7Aob0Otzsw5n0oK4GKb+JffztlHiwQDOMAEXlYOlslBnB9kUErdQw5VRr+nUOS2+3a7ei3haWwk/PkC2AieFpVXhg6u5C8jK/zF34oDfa9b+CgQdhFqWhvsCCqk46CpusltOZ4g3lsLSvKuVzJ803+IWTeqNo+rIUPw2EazzqUOuGTKSfZ4CTg9k7orl+cZvRAYJHUCGhj8/T3RLN1/woTAyqCT/SFSod0jyttnXzsdBbzN5eCs2z0R9Xp7Qjw== 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=jaMIvL/a8THGd6Vq7M9JG+gDOTdEmPzugMd468faxVCMpr1k5uS5/TUqdPGclvk/fUDZ57rpdadY5CRK78Q384chH3h73iwJysma5DmFFtmRsOePKJae8GwdfIFYwOC5/y7h/vwrOtbihwocHBUVYkqa5aqdGptMA9PFszbZrLIT7YgnrMMhpdv1NrPOy+1tsxgQhWnd34f8SGLdedYQqrZPFZKL08VxRQQ2+wbP3aVWkqs1vvEgfNGmIzg+D0tR9USg/pmFq5ezMBBLhXyjR4I8Adl0HlvpLv41mZLXA1E4Qp1zSP71yE01pRE0xJ1YxQjePzYUMKgW1ZpHQahQjQ== 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=fNUU4ur47felVpZxz1N2ylUmO5mif5Y/n2sb5YjrBPAhyics5OWj1ruyHYLIEm6pJdHBcYR0SaLM+S6u3Nn3nISDfslChNZneSnFF4U7HTKkPf8235wCqWS/xJjBh/wacHllFDWZy3gFu6RpZWaAHGSHuorqkWbRdberdsl7D3w= Received: from SJ0PR13CA0009.namprd13.prod.outlook.com (2603:10b6:a03:2c0::14) by PH0PR19MB5575.namprd19.prod.outlook.com (2603:10b6:510:14c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Fri, 13 Dec 2024 16:01:43 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:a03:2c0:cafe::73) by SJ0PR13CA0009.outlook.office365.com (2603:10b6:a03:2c0::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.5 via Frontend Transport; Fri, 13 Dec 2024 16:01:43 +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 MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Fri, 13 Dec 2024 16:01:43 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 795B255; Fri, 13 Dec 2024 16:01:42 +0000 (UTC) From: Bernd Schubert Date: Fri, 13 Dec 2024 17:01:39 +0100 Subject: [PATCH v2 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: <20241213-fuse_name_max-limit-6-13-v2-1-39fec5253632@ddn.com> References: <20241213-fuse_name_max-limit-6-13-v2-0-39fec5253632@ddn.com> In-Reply-To: <20241213-fuse_name_max-limit-6-13-v2-0-39fec5253632@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=1734105701; l=2235; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=Y+jl8fICPjJPTBlBvriWveQNF5Y6GNKCsIMoskeilno=; b=PaVxn/u7zmEPCgyOMAai/xQJ0tMZGJ2BJXo0fRlpqr69KDvJZBXaRcFs/4hZz6lQvwXh2uDEg nacXGCjv7dPB4DfvDNlKKQTh01TxKLhgNHL0RJtpqLbghSi+AWcF60D X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|PH0PR19MB5575:EE_ X-MS-Office365-Filtering-Correlation-Id: 81ed9d4c-2199-4e18-8831-08dd1b8f7027 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HXAALQNe9EVjfmcNYBBLcV8wXRHouTQ?= =?utf-8?q?uSTXDx6ZhlG766Gw+BrAoy42IEdlXjKt4RALKzSJhaJZ0w0rSQ1POem/dCXsdkXkB?= =?utf-8?q?xqQb61l5kvylc2g0bcbt1spTowl1nVa8xDcZJ734lFcxPzNR6HXYVhvMZbV1RDN3G?= =?utf-8?q?NNNKwmWwe9CCAfD1ABTO/HlBwwKdLKamLDF5VwXiX0U2azBzfgUuYAOfcmnYriRAa?= =?utf-8?q?BpcWIf94l3reC1wUKuacHfZR2pFiyHNuQwiduQyfCRiOBh5hXceb769At1RtT4gGa?= =?utf-8?q?7S7QczdcDCPs9H33MMEcjNVEzLIS8WOMxHFGux40c5Wl4UEm2NR+eJ/pExkROnnCg?= =?utf-8?q?kIhnAm7ZKIom3DFwmOKyIFnYeEVg+azYq2oqctDkrc/s+39ZXf64VKX0tzBsDeyg0?= =?utf-8?q?2/O5VMJFdMHl/I5llTisDBr7ro0x1X1JnP2E4FZFC+ErxEPBxAiDxtr1Vo8jWehkq?= =?utf-8?q?3ZHMMFXLlvYPIa73KhyRd1PAc92q5gjX0mZC6RQeB+uJReMSgqw5rR7KojIIOzmI9?= =?utf-8?q?ZslqzEC0rRk8A5yBjdzm/F/PL04D7jc0vEgcn5mPUL6WGhUWFnNwS9QhYi8hqv/3k?= =?utf-8?q?Z+diEwy9TEglHivK9YvFsMWoWYPDu0uGfd+EWo20mgI9tuT2dh9hkCPGtsoLKViF3?= =?utf-8?q?hwQsoiFG/gefkBlBDp1uY98/nO7TQQgXp3XI4JULzRjeZvPDi7EAaa96P+Z84gGwA?= =?utf-8?q?5g55AWvnRrA3FKoYG4Nfh3tbkIFKgIVhHRMUUJAE6fDN+zdTnJvrAi+Wh0tGRMkEJ?= =?utf-8?q?9JjWhwCjeZRzQvOQZvG8LV7idD4SDl+8nhOG73PqoaVCYgpqwoDFnGkpt3R03jyIq?= =?utf-8?q?6S09SJonScgjJd/LHIEwMc6fSvHw4cTEq/gffuJRZFmZ2uyUjm7SERNTQMhHXEWKN?= =?utf-8?q?pt5w/cKmB2v7kh2KKpRMOo489GdtINbGsdtouZCjDnInfPz2gyHaA+PgXiRje2HbK?= =?utf-8?q?LFOay4sUflZ29y6CFeWoybIsoY9Jj6DrLFUaiRPzqM2Q1QBUbM+ColpxZEfaWcmkt?= =?utf-8?q?TVlbefBJ2UxkIJKrUNtWhlx1b28lbBDsUtVNzuDs6/YE9pJVatFM+jI2URXukqUCp?= =?utf-8?q?XI0Z+CaZrnwxdD7CfQJskMQaKg4/S8PoR6OoZtSRUJkdCVkVE49haygsfi+gFLjqy?= =?utf-8?q?e+V4UW6wRYp5GAk4NNpofSyIqoYveoLa9MvYaBRKaeIsejC9/3loDdQrr8nW6Yu36?= =?utf-8?q?0VB/o6OraOvnSu2xKW+r58uH3PhpdVL7FjvnVdjq59iLkFC9kTwCdLN8cRVRg05D6?= =?utf-8?q?J5f3Ob+ndGDG+62t7ykymisqmUw2JSHy4wFNzSJOfU1rSzbUYYqdsiDYzeA9kEl6W?= =?utf-8?q?Qk19uGAqYXhP6/cE58fSyMM3aCHH6pcoglnXagYV9QPQXj1XWaaLqyN/Y2vRfwG1r?= =?utf-8?q?wwH+ipi2EAG?= 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)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: d6EJiUqTyOdNbgvLQ0Ti2bAp2l+f4nqOiVYJoSAMv7l4O0jePsaOreUrFYUFBKt58a6GBvR9zutImI1C6FeWjvjt12FpxyLhOP7QWKnOtPpaCa7hZNYZd461YI9EXB5YqM0bYm87lvjm1G5J5879m+fPCSxxPuEjTwdnrKK5q4GQ/q9hqX+oXfC5HF4Oe8qj5Zg6WYSUFW+k1M4PPTDq2T8c4WREXUIJaBeWS+g8PV1N9yikYYx81Bz280Q2y63fBg6nBU3ahU/oK9vuRcHtthvKS8uAHQjYiGHl43chFBS4dXL32egAsGw0v21YPa760JzQt2Psi64+8ffgUYDd8RsjUlUL1BjD6Oq2JmuArR9TFUkKRN2YBdnfvOiofLD4wZgdNwr22BtJhP4FBlKG3KFIV4U/33flynYBvTDro6OPJMeceYNRctZhCYtFL4ZkKHcdXvbNzxkHszgwXNaTz80/O7LlaJ+zkqnNU3gh2dSW1MGj6URUZqFVbaxtDLobKZ5Ec+quzjk4k7l2l+jOPsEiv9vgEWvSABy8UI7Vds0i1aoMLag9QDkqUDb85p83GtTy8K/eNixqRGiWC5m2SUZdbBw4oDcxrZrLHJm7exrrHDSLzT1pKZt0uXPVZtXGE4WHm1DUNKNlYo/nfhUiqA== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 16:01:43.0671 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81ed9d4c-2199-4e18-8831-08dd1b8f7027 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: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR19MB5575 X-BESS-ID: 1734105706-110515-13346-27300-1 X-BESS-VER: 2019.1_20241205.2350 X-BESS-Apparent-Source-IP: 104.47.70.44 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.261086 [from cloudscan15-9.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);