Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9090716pxu; Mon, 28 Dec 2020 06:24:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJywtS4RtfiPuU/uyPxximtHcLY7saNVfQeCRl3ru//BNUFwBtYPJX733/ohTgzACrZ3SG2d X-Received: by 2002:aa7:d154:: with SMTP id r20mr44007883edo.258.1609165478008; Mon, 28 Dec 2020 06:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165478; cv=none; d=google.com; s=arc-20160816; b=rm6OChyK8lwlVZu4Ou6650SS7FgxQjWqu+hUcPuqOuu2yE9jGNWEUbxlGMJ/pd6T/j hVwCWRYP3L9kddVe0CB19WFGeOgIovC08Vzfv/m7d32V7WGtXArAvUEK1dhpekXiTxlW hRmX/HPd5F1/nDfyS6IgiWKaXMlEmkMTy5TXSrbzc5BP9+jPBB5e6AFtXk7bYFvmE6ra 7h5PpTGDId4h7xS8FLfuJmjBurut1av/0WgMNH6/CfQhi/XjoJDHff2bDwTPR88owGr5 ZbXf5c/HDMsfVuu+NTYLF7XlZ/QOSttRnHm0SrjdyAyRXqYTg7sZt64o9pHUPuZ++Y1k gXew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ig74yW75klElDx95mfWTbFWcm3pzAyinEhy+S/ZJAjc=; b=Ww6/s4o6knwTqYCPUyPlJaWKoeMX494IMtNDsmPrMqCBkesI79xeHEYKI4qtjU6znG oxEZigh5j5MzlSeNjh4fvIlrta2w1PR7VLvwBgN+dND+ySXcCbqLFgSB2hrOrTTp0jvO GsYnKFlhUAPqiQ9WtjFLce7M3aL3tEMDHOMQWYtb4KxBkZgVNkb9tB8QiTobFLUyy8zX I37dKGEMf0vSPO4DaAblzqKiWv6IZ76+Zklsf3yjg27kP5bzGMVxvKZf9Us2m2AkoyJP jGMe2QxoqzQOMxqniBK7zTvopmjCpq2N5vm+eeLdbTCoaLZGJdF3HIIEc4mZ/k/0Pg1j E6kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kwMx1nf+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si18855037ejw.548.2020.12.28.06.24.15; Mon, 28 Dec 2020 06:24:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kwMx1nf+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441680AbgL1OWN (ORCPT + 99 others); Mon, 28 Dec 2020 09:22:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:57716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438156AbgL1OWJ (ORCPT ); Mon, 28 Dec 2020 09:22:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 582B42063A; Mon, 28 Dec 2020 14:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165289; bh=gnELdCjELm98NJSssu0Y6p/tT9x6O8zCKJr0XYtKegc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kwMx1nf+BTK74P0qGNDeMa1Qnh0B8NYo/44IFeZ3gWRpC9JFLSWrf8i1iDBY1FhuD oGqcBeZ7xbBooNOYmq+678E8BEiV+PQKyaFyx7nKciaxtjtrylzbO8diHhnG6mWlUe hi5/vyIL8YMxNNlWf4pmHmEjN67iPJdVj6GW5uyo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muchun Song , Roman Gushchin , Johannes Weiner , Michal Hocko , Vladimir Davydov , Shakeel Butt , Joonsoo Kim , Yafang Shao , Chris Down , Christian Brauner , Peter Zijlstra , Ingo Molnar , Kees Cook , Thomas Gleixner , Eugene Syromiatnikov , Suren Baghdasaryan , Adrian Reber , Marco Elver , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 449/717] mm: memcg/slab: fix return of child memcg objcg for root memcg Date: Mon, 28 Dec 2020 13:47:27 +0100 Message-Id: <20201228125042.489584214@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muchun Song [ Upstream commit 2f7659a314736b32b66273dbf91c19874a052fde ] Consider the following memcg hierarchy. root / \ A B If we failed to get the reference on objcg of memcg A, the get_obj_cgroup_from_current can return the wrong objcg for the root memcg. Link: https://lkml.kernel.org/r/20201029164429.58703-1-songmuchun@bytedance.com Fixes: bf4f059954dc ("mm: memcg/slab: obj_cgroup API") Signed-off-by: Muchun Song Acked-by: Roman Gushchin Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Shakeel Butt Cc: Joonsoo Kim Cc: Yafang Shao Cc: Chris Down Cc: Christian Brauner Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Kees Cook Cc: Thomas Gleixner Cc: Eugene Syromiatnikov Cc: Suren Baghdasaryan Cc: Adrian Reber Cc: Marco Elver Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/memcontrol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 29459a6ce1c7a..74b85077f89ad 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2987,6 +2987,7 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void) objcg = rcu_dereference(memcg->objcg); if (objcg && obj_cgroup_tryget(objcg)) break; + objcg = NULL; } rcu_read_unlock(); -- 2.27.0