From patchwork Wed Oct 19 08:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp266175wrs; Wed, 19 Oct 2022 04:24:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7I9YWcVQ8qmL7IcGgAkTL2rT8iS+04oRXNNM8vrjyAy+xf5LoJkGDW1HBBsSeFvm4yYp6A X-Received: by 2002:a05:6402:27c7:b0:45d:45f0:e6c4 with SMTP id c7-20020a05640227c700b0045d45f0e6c4mr6846296ede.325.1666178643264; Wed, 19 Oct 2022 04:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666178643; cv=none; d=google.com; s=arc-20160816; b=nIZYmO4T/NNSijCviw/23ohM2gSV4Pcmb/5WnfvQB6Za9It+PX5DatwjbFpkPkC3xk D4qknBL10o2cGkjywNeXo7Z38q68vqDU9FcSArkEurP+6YAEuyBhAsXAY2QeD+q7NAfv 5zX53u9snSd8SRYqMrvmYTl1ArfOTSPeSWfqooRlBFXK8cI4MvNwQYrqmLLpQTVyuz+/ wPvPAPdwKYwFuJ5JR+3JtwlkXP5QkW161P0XLdg2rFoC+z9I4Ng4bCuSo7xQdWLW4aC4 xeLdmVyJ0vIqQjk9CI6qdPOyGq2EPZ45ZGlfD9ZnxBnmQQAxFdqj3xm7n9Ktip9gh1hH 9r1w== 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=sbOb4dJcVuy57BmWxmthd6B9PNMKKzmA8068V8/2l40=; b=CgPHucs0Ypq5CcEMq1itFA23Fzw1pqX1n1UXveEnunfuB0imD8oxxLYxbgRl0n2lJo a9szKe174UqD5AuOYSBKt8QGMN088Wi/IC2nIHiTT9i/p7YUbzEpr4D/15JslEiBT2/P 3TVsrxWzioKNV46o1L59Oqi1sHSAH4rQNPB0IOYxAdt8KzHCCzbYhPgIA6tAuC4bNbH/ htQXSrDDQjljCgw9F/mnhGMVEndyyaJv3sBEV0corubFBJFurso6JCYAfDe5ldZbodO8 fwd6Q+CEX3RNyjIFyc4NQtz3PEgDbAJBeA51rvLVvTWEIC9rWmyiL+JpJ67ESv/MrDGM tVaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oVHMpOdC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a05640211c900b0045db850a506si6259675edw.46.2022.10.19.04.23.35; Wed, 19 Oct 2022 04:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oVHMpOdC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230107AbiJSLLX (ORCPT + 99 others); Wed, 19 Oct 2022 07:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232978AbiJSLKI (ORCPT ); Wed, 19 Oct 2022 07:10:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8239152C49; Wed, 19 Oct 2022 03:38:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 01315B82333; Wed, 19 Oct 2022 09:06:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 580A5C433D6; Wed, 19 Oct 2022 09:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170369; bh=I/XUHacc8FBmkhRg2IdQdCttKWx2Fpa5yIMG9Xa+66c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oVHMpOdCx78pcRVncNszUqy/vP63O0kUDlry+tS+WQ8VEySAJl/9W0o+W0Rv3tCVP 0LbgFV2j8bQm2r8R581Exkkh1ssswJDEVF1VxLPasMLADUsfPJs3duR8BNqyFjVN1R 5Al4bF5EDZYyFhn6NjGa/SBNOnJ5Dhn4tf8pBfLo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Michal_Koutn=C3=BD?= , Tejun Heo , Sasha Levin Subject: [PATCH 6.0 628/862] cgroup: Honor callers cgroup NS when resolving path Date: Wed, 19 Oct 2022 10:31:55 +0200 Message-Id: <20221019083317.668836387@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747114936797597058?= X-GMAIL-MSGID: =?utf-8?q?1747114936797597058?= From: Michal Koutný [ Upstream commit 74e4b956eb1cac0e4c10c240339b1bbfbc9a4c48 ] cgroup_get_from_path() is not widely used function. Its callers presume the path is resolved under cgroup namespace. (There is one caller currently and resolving in init NS won't make harm (netfilter). However, future users may be subject to different effects when resolving globally.) Since, there's currently no use for the global resolution, modify the existing function to take cgroup NS into account. Fixes: a79a908fd2b0 ("cgroup: introduce cgroup namespaces") Signed-off-by: Michal Koutný Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/cgroup/cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 5f2090d051ac..29296a6374ef 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -6638,8 +6638,12 @@ struct cgroup *cgroup_get_from_path(const char *path) { struct kernfs_node *kn; struct cgroup *cgrp = ERR_PTR(-ENOENT); + struct cgroup *root_cgrp; - kn = kernfs_walk_and_get(cgrp_dfl_root.cgrp.kn, path); + spin_lock_irq(&css_set_lock); + root_cgrp = current_cgns_cgroup_from_root(&cgrp_dfl_root); + kn = kernfs_walk_and_get(root_cgrp->kn, path); + spin_unlock_irq(&css_set_lock); if (!kn) goto out;