From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62A133254AD for ; Tue, 25 Nov 2025 15:11:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764083506; cv=none; b=Y3KpjSEsB8JvSxOovQm81lnGp0rOA2yfZcWolM8kLeJU6wGj8ySlgDbsIJ6X3yi1Ie7RvzsyZjpCyQIw7BHJS2Iu2jK6R4vgnQ786+5BnSCn6aZRJRf0msTDdQQnFRuea3IgDJCm4GuMkhcZJJ2w5AmqyV1cErNtCgmAqmQVz5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764083506; c=relaxed/simple; bh=Mr9UDvX4pjQspAwhlrf/Q+17Tiuqp5p/H8tf+6yybHE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tte0yYwO6Bl3+/SiJumoG9wQTt0It3/KxvKSJ7qoh9oIYkAJq3kM39UtLg2zNUo4UUGwPffM4p9/ivwrYZGWiQkCdn4Hp+cm2HNq0KZ1mXB2QrrFD8fdc62wpoK+8i4s32/UN6MfJ5GIKcfBpf28EiQyv7tp6R0ni1K49dgnXkQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=jCRB0X8E; arc=none smtp.client-ip=74.125.82.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="jCRB0X8E" Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-11beb0a7bd6so6505310c88.1 for ; Tue, 25 Nov 2025 07:11:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1764083503; x=1764688303; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=O4uI7wAjQQoxDlTlVcBoB1GfjN4ZFWoQnkDnK/7MZ88=; b=jCRB0X8E7XpDClW3uJIX2Z3yghpC61OKr3gBcIcw58PJ1LzW8bn+vh5x/lkno1Zrwm /LVFu/onlqSevr0C6g6/vrQj8UBQPCGfn+YS4nw7oN8gJ+9sjiir//Su6Dh4t0CLxr5l 7CupU3eA2R7zZ1c2m8ALl5tDYyEbjqCh83UE9JD1SvU7okd/RjIP2hCDYALVVyDjMl5P touM8XVNJf7x8G9517hHiLP3ysTqh+C/tkH1akzb0nhgDROY7hApt48cRGVxdEpI4oEW +7WUnQgP5tifkujucI+RzYDbAABoQK7o+p8vtnk/uzsVUcWh8z5XS5tsQL1YzZd3m0T/ OWCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764083503; x=1764688303; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O4uI7wAjQQoxDlTlVcBoB1GfjN4ZFWoQnkDnK/7MZ88=; b=RDxHj7VMfmS+b+cgZ0cgbGqAC9KzLiNiQ/HsiDPHXgUsLcJoM2YjJG+eooz3QNK+AG O1pEc00VK14WLBHyUEUa6BtOb1FrOljcGnva7t/MqfXznVjVqkKoDNlQMK/vgFkTrcZm MXqZpamR1z1N0bL7NyZTBtXQZvbDm9tiz7NrgJcX5EYPOzS7u267aphH/Ioj5QnoyCh3 PPMfXU3aFeBW+/zyu3AWGGFIvIbwJQmyd6ZOC4jiu8uglAr4sC29yhfGEcgTuhvr+hp1 qjMojxXl0upKKLaj1SwpQX4UM5+k8fzEX3j3jff0TTSc+mmEuyZqAKhw2MCKLBs19Sn0 b2eA== X-Forwarded-Encrypted: i=1; AJvYcCXGorVB3KcdbY2FptkFZxmCuMP74Q68fHikYi7rCJZbRnV9sSuulL43hWt4NfwugGOyEApmprJSHdcOU/k=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6t0+rgt0d3qiUZZjbV4AVJ90nyOghFgOQtxysFH+/HqHn44mh V+ef67jCSAkkSiSrhqPEfsxH9pmu9t7tVftxj35rrY/+wjdKqRC4aFR1Nq1q09rT8g== X-Gm-Gg: ASbGnctPQXGkp8HPf13Q3DkX3780v+VTC1Go4Dfcy0F1B6WwisOSWAS7AeSkVobFFR9 COTHslyLQWtC+WThJUX71pVazIurs6suOIyVG0eGY642GJMcbcPfibvjkxUI1QvELwP+WAMdVhx jXfuj1T2V4RHyPsS4T1mNj2V/0inOdpSxQlvQU1OwXM+n976GzweMKk2rb9zMy1fVezNgq4RFBb wF72yecOhRbg2s3fqpE29zs9t3TlXeb8bqFiNfPrV/9AderfyHZcH7ApW6rAO+wvJtJqt3hfFv/ RsVnhDR3gLnG0Hznok97xYgt2OWGWv2RqTO67Ik95wz9/ywCWMnNrZSKIcDB95DRbMxBAgf/WVf o30oInby2QKCVwvcOGtLSgts9MUMGC7WdQamLn5PESgbNauCJkAUS3h7GyWlCWB5Y9fyKNlBOan PYt0hmZdAOxZqfKJQ9vTc3a9rqxcl8OpU9 X-Google-Smtp-Source: AGHT+IETeCYILT5QKjNeOZaFg36DUaHdtQHjhDugYgT92ZT6oGjUIP24oEh4rcwjNcjpug4SgBnh2g== X-Received: by 2002:a05:7022:ec8a:b0:11c:2632:b7c1 with SMTP id a92af1059eb24-11c9c8a63a8mr9940558c88.0.1764083503114; Tue, 25 Nov 2025 07:11:43 -0800 (PST) Received: from gmail.com (ip72-200-102-19.tc.ph.cox.net. [72.200.102.19]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11c93e5674csm82821257c88.8.2025.11.25.07.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 07:11:42 -0800 (PST) Date: Tue, 25 Nov 2025 08:11:40 -0700 From: Will Rosenberg To: Paul Moore Cc: Oliver Rosenberg , Greg Kroah-Hartman , Tejun Heo , Casey Schaufler , Ondrej Mosnacek , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] kernfs: fix memory leak of kernfs_iattrs in __kernfs_new_node Message-ID: References: <2025112442-favorite-draw-76b0@gregkh> <20251124183733.1943956-1-whrosenb@asu.edu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Nov 24, 2025 at 03:41:51PM -0500, Paul Moore wrote: > > Should this be kmem_cache_free(kernfs_iattrs_cache, kn->iattr) > instead? I suspect it would also probably be a good idea to call > simple_xattrs_free() first. > > I also noticed there is a reasonable amount of duplicated kernfs > cleanup code spread around fs/kernfs/dir.c, we could probably benefit > from some helper functions here, but that would be a follow-on patch; > keeping a small bugfix patch to ease stable tree backporting is a good > thing. I agree. Helper functions could also help prevent this type of bug from re-emerging. > [HINT FOR THE FUTURE: for patches like this, look for a function that > normally does resource cleanup for the object and do what it does, in > this case kernfs_free_rcu() is a good example.] Thank you for all the help. I updated kfree to kmem_cache_free() and added simple_xattrs_free() just to be safe for future changes. -- will rosenberg