From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4CA96315776 for ; Mon, 24 Nov 2025 16:15:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764000932; cv=none; b=UMypWq3+aWrcubjJgZuyS2OwVWkAYxO99rOSWyGE10Cn7f0dDmcNAT/BZIHNEOwUHrdyUb4tnFmdg/xSJTuoWoH0+3c/axkGit4zRiHzcIFEq0+mubaFA3hM4npdETaVZ+KWHmlDUDUGGV67oIHhTx+uzryn1HGrOo49DV81n6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764000932; c=relaxed/simple; bh=B++dpK7o+BZv70Id5oxQ7EdyP4dIsUEMmwPXsQ49KZY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lgFEV+Jw1quK7zG346bhQ256lYDsbE51Z7oiADutX4ReOz1JasWXTKIDmmbh0423R0E1VR+scqx+0eItb+exOHfJ9tl9zUzc+NwnnTQRwNQrPnixU208AYOpnKTLqtv/DqOeKQYcsOj18+OeCUCm91sk5o9ZqSMLx0ZsZXghaNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gmzi38OR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gmzi38OR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72D3AC4CEF1; Mon, 24 Nov 2025 16:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764000931; bh=B++dpK7o+BZv70Id5oxQ7EdyP4dIsUEMmwPXsQ49KZY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gmzi38ORZjpB+7/3Oi8z660U8vxqZZGF7yWptx1RBni4awmavGMnCLs5j7j0z5G0M fw1KwbjtPBtKHlcFUH8VjVdlzAKw9yshz5bmE96Lduv6D0cj0OwkipUo0ZlySEMTKd 7J4AeeXI2U8yqSv/YqhvYIufmMW2RzAoPXQ1zrcg= Date: Mon, 24 Nov 2025 17:15:28 +0100 From: Greg Kroah-Hartman To: Will Rosenberg Cc: Oliver Rosenberg , Tejun Heo , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] kernfs: fix memory leak of kernfs_iattrs in __kernfs_new_node Message-ID: <2025112442-favorite-draw-76b0@gregkh> References: <20251124160226.1921258-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: <20251124160226.1921258-1-whrosenb@asu.edu> On Mon, Nov 24, 2025 at 09:02:26AM -0700, Will Rosenberg wrote: > There exists a memory leak of kernfs_iattrs contained as an element > of kernfs_node allocated in __kernfs_new_node(). __kernfs_setattr() > allocates kernfs_iattrs as a sub-object, and the LSM security check > incorrectly errors out and does not free the kernfs_iattrs sub-object. > > Make an additional error out case that properly frees kernfs_iattrs if > security_kernfs_init_security() fails. > > Fixes: f72dae20891d7bcc43e9263ab206960b6ae5209f ("Merge tag 'selinux-pr-20190507' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux") Did the error really happen on a merge? That feels very wrong. Also, please read the docs, it says how big to make that sha1 value :) > Co-developed-by: Oliver Rosenberg > Signed-off-by: Oliver Rosenberg > Signed-off-by: Will Rosenberg > --- > fs/kernfs/dir.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) What changed from v2? Again, please read the kernel docs on how to submit a patch. thanks, greg k-h