From patchwork Sat Oct 22 07:26:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1106746wrr; Sat, 22 Oct 2022 01:38:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4R6aOmc9ShaPllFWMbubIvk2vIuxytA+6GapxkYsuQdLgfyJcjZqfJfPMI+FXI+L5dAg7v X-Received: by 2002:a05:6402:8cc:b0:45c:a5c9:c0a with SMTP id d12-20020a05640208cc00b0045ca5c90c0amr21083523edz.135.1666427932442; Sat, 22 Oct 2022 01:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427932; cv=none; d=google.com; s=arc-20160816; b=WgJSOR5q16WDvDie5KWHp2IpUVSVm6ZV0l4E/UTc0MPaT1/uWNaj8ra/9qlunLaVVQ +dC+60Civ3PSw8fz5nHw1OlmnR4kFjn2jhawiWkEHh5NFomJcuQz6lPZ+AygJOSQdFOF 1s8G0pxnMri9Ea0Eb6CJoBeEmNXni77eWFhbbn0jwUGobf4aKcxBUoe20X/e7pgIsTl6 7uNRqJ49QIIDDgSce43kbVmC63mAt4d0L1DZqUgB+z1ZcEAcJ6rB8eTJZeo5LhlvofTa g9OY9MOpRoIqLt9GUcfJSxu5MLP6xINwz+Vp3MOMR6AWYuOT8LwPyZESfw17XjITxXMf 2Daw== 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=pvMe6m3X6tijpRe5l9xTDjeUV+n7R6qu7LhOjTQGdrY=; b=OZSvvgZkT2TYciWPYT5MDTV0pSDkvV41xYJxbEwEHn8KF/177fpTt++m/clPw/Szhe 7JcPsvhRXXgvmauTCywWjwc2/EWywTgaejj4IuGB5xWBtHR2iyYcS73PdSGZ8MgsA9ZU QmB5j4e1ibNfWLkCU7KIBdbeQ0m9m2VKR5HGASR9L4A9Ei0iOAejuRP2Vr7ywDlKkgMi 24HNQYYB/NrkjFzrnGqJdSv3K4xcijwOJhgpir2T0pZ0DTym5JPXhE5KJeNCAbI/jY8U NHoz7o8vfudvtJu3RJKxYYxKNFKaqw8GLFEeGoZoPPMKixp8/L1dCzbHJniJBS0nD0qP LTdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=seW0QweO; 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 gn17-20020a1709070d1100b0078e254ae418si22027483ejc.640.2022.10.22.01.38.24; Sat, 22 Oct 2022 01:38:52 -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=seW0QweO; 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 S233677AbiJVIWf (ORCPT + 99 others); Sat, 22 Oct 2022 04:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233687AbiJVIUo (ORCPT ); Sat, 22 Oct 2022 04:20:44 -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 D107313A580; Sat, 22 Oct 2022 00:58:37 -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 3E231B82E1A; Sat, 22 Oct 2022 07:57:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 951D1C433D7; Sat, 22 Oct 2022 07:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425470; bh=gLfPVt/hzTDak0xAaXlvDvTTkyu+KcPowc7Cv3qqwwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=seW0QweOwDp2FZP1JiyQPs4Tm57YTXakAtJYivXyrmyZrDui5hEPYPEEhgGdhj8JE AXKWRQhe/+4UlFvX91T3M0RGJDZIas+5PfGldRP33/wBp2ItXA8WTAkCRStgEaCHC9 8vvusxK9XwjifKMc4zoJeFkZBSdo91nXHhtWk7Vs= 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 5.19 511/717] cgroup: Honor callers cgroup NS when resolving path Date: Sat, 22 Oct 2022 09:26:30 +0200 Message-Id: <20221022072520.870616339@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376335897562559?= X-GMAIL-MSGID: =?utf-8?q?1747376335897562559?= 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 80c23f48f3b4..90019724c719 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -6615,8 +6615,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;