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 B5A2B28642B for ; Sun, 22 Mar 2026 22:34:59 +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=1774218899; cv=none; b=tnEb36KxBQKS8wVWGaIFjrgRqCcsLWKQrO48eZcX4KZi9xqovoXTwGm0lulCG95DWagA6vVLtgvAA5bhFN9rzJaV9+Cb2EjBV3s2Yo8GbbRJH0lE5V/FEOmOyjjXN0l1h+UxmX8Kyz0xumr2HuUPAR7kZaT8G5ZZNnI2ZZEgUJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774218899; c=relaxed/simple; bh=Savqoq+1da5mlltJawsJ0m3iwpbknkmSXsByhCsojJw=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=aarkplSBHO4d6k2RR5xTudV5LVxWxqq5hKAy+zmv6MWyHuLxvZ/zQU5kDl5DSoJqKmPpRmr2ZOcuPdEXhrEembnfYtxi/hXcXi3HP6fOxhXTj28x2EOputYo7zXdDzhT6Ubcp98ogR4Z4fN9TsfnpZ26ZfQJT+adGXkJEr1M/QQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=BZKlad+F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="BZKlad+F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DA97C19424; Sun, 22 Mar 2026 22:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774218899; bh=Savqoq+1da5mlltJawsJ0m3iwpbknkmSXsByhCsojJw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BZKlad+FQFaJnrsAKYEbygGXQNLKDbYqZXaYDEQKe+02JfQPkL81VfHswVMEapP2D 6yZ2LeH/m4bbfY3AYe7X/h+lYVLxNeViVA/JEXK8jr8q7aKkwui2g0rG+IzS844m5m T4BoTh0d40xZcq0g88AaK6G/nez3laDJOtRJ0iRk= Date: Sun, 22 Mar 2026 15:34:58 -0700 From: Andrew Morton To: David Carlier Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Qi Zheng , linux-mm@kvack.org, stable@vger.kernel.org Subject: Re: [PATCH] mm/memcontrol: fix obj_cgroup leak in mem_cgroup_css_online() error path Message-Id: <20260322153458.245cf0eae46bf8f57d6fe4ce@linux-foundation.org> In-Reply-To: <20260322193631.45457-1-devnexen@gmail.com> References: <20260322080142.5834-1-devnexen@gmail.com> <20260322193631.45457-1-devnexen@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 22 Mar 2026 19:36:31 +0000 David Carlier wrote: > When obj_cgroup_alloc() fails partway through the NUMA node loop in > mem_cgroup_css_online(), the free_objcg error path drops the extra > reference held by pn->orig_objcg but never kills the initial percpu_ref > from obj_cgroup_alloc() stored in pn->objcg. > > Since css_offline is never called when css_online fails, > memcg_reparent_objcgs() never runs, so the percpu_ref_kill() that > normally drops this initial reference never executes. The obj_cgroup and > its per-cpu ref allocations are leaked. > > Clear pn->objcg via rcu_replace_pointer() and add the missing > percpu_ref_kill() in the error path, matching the normal teardown > sequence in memcg_reparent_objcgs(). > > Also add a NULL check for pn in __mem_cgroup_free() to prevent a NULL > pointer dereference when alloc_mem_cgroup_per_node_info() fails partway > through the node loop in mem_cgroup_alloc(). Cool. > Fixes: 098fad3e1621 ("mm: memcontrol: convert objcg to be per-memcg per-node type") This is presently in mm.git's mm-unstable branch, not in mainline. > Cc: stable@vger.kernel.org So the cc:stable is inappropriate.