From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4788EC76186 for ; Mon, 29 Jul 2019 06:25:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC4852075B for ; Mon, 29 Jul 2019 06:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564381504; bh=o7Y4gnoBkfgwdcSl3a/KZkez69zJ7peWRa+sloNUEr0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=nuMP+G18vxE+vWx0cNu2749GkreXkezS7LibmjRJLv2+ped1m39Jp/ldUjiLnMQ3P uFd+x8BisjOiDA3yKC+25viXgc2tqIvSJstpIZFqsPyIYIYLitYBK/nZ3ZR5oJvAER mJkjQlLehB/xrE3Bav1mZ9Ir56Xg3E4IJzuJqFk8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbfG2GZD (ORCPT ); Mon, 29 Jul 2019 02:25:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:47252 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725934AbfG2GZC (ORCPT ); Mon, 29 Jul 2019 02:25:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 765A3ADFC; Mon, 29 Jul 2019 06:25:01 +0000 (UTC) Date: Mon, 29 Jul 2019 08:25:00 +0200 From: Michal Hocko To: Miles Chen Cc: Johannes Weiner , Vladimir Davydov , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com Subject: Re: [PATCH v2] mm: memcontrol: fix use after free in mem_cgroup_iter() Message-ID: <20190729062500.GB9330@dhcp22.suse.cz> References: <20190726021247.16162-1-miles.chen@mediatek.com> <20190726124933.GN6142@dhcp22.suse.cz> <20190726125533.GO6142@dhcp22.suse.cz> <1564184878.19817.5.camel@mtkswgap22> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1564184878.19817.5.camel@mtkswgap22> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 27-07-19 07:47:58, Miles Chen wrote: > On Fri, 2019-07-26 at 14:55 +0200, Michal Hocko wrote: [...] > > > I am sorry, I didn't get to comment an earlier version but I am > > > wondering whether it makes more sense to do and explicit invalidation. > > > > > I think we should keep the original v2 version, the reason is the > !use_hierarchy does not imply we can reach root_mem_cgroup: > > cd /sys/fs/cgroup/memory/0 > mkdir 1 > cd /sys/fs/cgroup/memory/0/1 > echo 1 > memory.use_hierarchy // only 1 and its children has > use_hierarchy set > mkdir 2 > > rmdir 2 // parent_mem_cgroup(2) goes up to 1 You are right I have missed this case. I am not sure anybody is using layout like that but your fix is more robust and catches that case as well. Acked-by: Michal Hocko -- Michal Hocko SUSE Labs