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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 2AE6AC43215 for ; Fri, 22 Nov 2019 10:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C02120714 for ; Fri, 22 Nov 2019 10:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574418666; bh=sn+m3BOLErBC6AKGL1xcvAxm0UFVxlNoCMzo8vEdi8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TnKTFHnaeXg1HU/C1YjG+iA153lSGx0hR3zbUPlTY98Gqao7imymWy/6WNtkRGnnb Mg6IlXSVCCTCOBbEjc8l9L1y47hGAQfOZpX3TCoJI+YjWhIZUPCY8vNkHhpiY1UrJ1 zRGMiiBhWTKfHOi1aOpP+HWTOYVWyvz5WhyATaLM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbfKVKbF (ORCPT ); Fri, 22 Nov 2019 05:31:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:50818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbfKVKbE (ORCPT ); Fri, 22 Nov 2019 05:31:04 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBC392071F; Fri, 22 Nov 2019 10:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574418662; bh=sn+m3BOLErBC6AKGL1xcvAxm0UFVxlNoCMzo8vEdi8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hLJyEpnLh2C987tYfy29zVAVfz4Rw7ayjjlloLtAH5eHhjtnqLLepGs/UK+TllC7+ F41X2XBaOfvV71IRY6g7GZkwNzWo5dvgNm/ew9tNCQDOgR2lPV1tlprUO2YaSh6cDx jqwtuXmrGkLvwFeOixyKew5M/+9APGtoejDkHuNw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roman Gushchin , Johannes Weiner , Tejun Heo , Shakeel Butt , Michal Hocko , Andrew Morton , Linus Torvalds Subject: [PATCH 4.4 010/159] mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup() Date: Fri, 22 Nov 2019 11:26:41 +0100 Message-Id: <20191122100716.019364466@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100704.194776704@linuxfoundation.org> References: <20191122100704.194776704@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Gushchin commit 0362f326d86c645b5e96b7dbc3ee515986ed019d upstream. An exiting task might belong to an offline cgroup. In this case an attempt to grab a cgroup reference from the task can end up with an infinite loop in hugetlb_cgroup_charge_cgroup(), because neither the cgroup will become online, neither the task will be migrated to a live cgroup. Fix this by switching over to css_tryget(). As css_tryget_online() can't guarantee that the cgroup won't go offline, in most cases the check doesn't make sense. In this particular case users of hugetlb_cgroup_charge_cgroup() are not affected by this change. A similar problem is described by commit 18fa84a2db0e ("cgroup: Use css_tryget() instead of css_tryget_online() in task_get_css()"). Link: http://lkml.kernel.org/r/20191106225131.3543616-2-guro@fb.com Signed-off-by: Roman Gushchin Acked-by: Johannes Weiner Acked-by: Tejun Heo Reviewed-by: Shakeel Butt Cc: Michal Hocko Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -180,7 +180,7 @@ int hugetlb_cgroup_charge_cgroup(int idx again: rcu_read_lock(); h_cg = hugetlb_cgroup_from_task(current); - if (!css_tryget_online(&h_cg->css)) { + if (!css_tryget(&h_cg->css)) { rcu_read_unlock(); goto again; }