linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michal Koutný" <mkoutny@suse.com>
To: Romain Perier <romain.perier@gmail.com>
Cc: Kees Cook <keescook@chromium.org>,
	kernel-hardening@lists.openwall.com, Tejun Heo <tj@kernel.org>,
	Zefan Li <lizefan.x@bytedance.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/20] cgroup: Manual replacement of the deprecated strlcpy() with return values
Date: Tue, 23 Feb 2021 17:13:30 +0100	[thread overview]
Message-ID: <YDUpqn+cRWg1ZYYT@blackbook> (raw)
In-Reply-To: <20210222151231.22572-2-romain.perier@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3355 bytes --]

Hello.

On Mon, Feb 22, 2021 at 04:12:12PM +0100, Romain Perier <romain.perier@gmail.com> wrote:
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -2265,7 +2265,7 @@ int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
Actually, this function isn't used at all. So I'd instead propose the
patch below.

-- >8 --
From 4f7e0b9c0412f60e0b0e8b7d1ef6eb2790dca567 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>
Date: Tue, 23 Feb 2021 17:05:57 +0100
Subject: [PATCH] cgroup: Drop task_cgroup_path()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The function has no current users and it is a remnant from kdbus
enthusiasm era 857a2beb09ab ("cgroup: implement
task_cgroup_path_from_hierarchy()"). Drop it to eliminate unused code.

Suggested-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Michal Koutný <mkoutny@suse.com>
---
 include/linux/cgroup.h |  1 -
 kernel/cgroup/cgroup.c | 39 ---------------------------------------
 2 files changed, 40 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 4f2f79de083e..e9c41b15fd4e 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -115,7 +115,6 @@ int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
 int cgroup_rm_cftypes(struct cftype *cfts);
 void cgroup_file_notify(struct cgroup_file *cfile);
 
-int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
 int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);
 int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
 		     struct pid *pid, struct task_struct *tsk);
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index c80fe99f85ae..d75ffd461222 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2235,45 +2235,6 @@ int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
 }
 EXPORT_SYMBOL_GPL(cgroup_path_ns);
 
-/**
- * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy
- * @task: target task
- * @buf: the buffer to write the path into
- * @buflen: the length of the buffer
- *
- * Determine @task's cgroup on the first (the one with the lowest non-zero
- * hierarchy_id) cgroup hierarchy and copy its path into @buf.  This
- * function grabs cgroup_mutex and shouldn't be used inside locks used by
- * cgroup controller callbacks.
- *
- * Return value is the same as kernfs_path().
- */
-int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
-{
-	struct cgroup_root *root;
-	struct cgroup *cgrp;
-	int hierarchy_id = 1;
-	int ret;
-
-	mutex_lock(&cgroup_mutex);
-	spin_lock_irq(&css_set_lock);
-
-	root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id);
-
-	if (root) {
-		cgrp = task_cgroup_from_root(task, root);
-		ret = cgroup_path_ns_locked(cgrp, buf, buflen, &init_cgroup_ns);
-	} else {
-		/* if no hierarchy exists, everyone is in "/" */
-		ret = strlcpy(buf, "/", buflen);
-	}
-
-	spin_unlock_irq(&css_set_lock);
-	mutex_unlock(&cgroup_mutex);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(task_cgroup_path);
-
 /**
  * cgroup_migrate_add_task - add a migration target task to a migration context
  * @task: target task
-- 
2.30.1


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-02-23 16:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 15:12 [PATCH 00/20] Manual replacement of all strlcpy in favor of strscpy Romain Perier
2021-02-22 15:12 ` [PATCH 01/20] cgroup: Manual replacement of the deprecated strlcpy() with return values Romain Perier
2021-02-23 16:13   ` Michal Koutný [this message]
2021-02-22 15:12 ` [PATCH 02/20] crypto: " Romain Perier
2021-03-04  4:37   ` Herbert Xu
2021-02-22 15:12 ` [PATCH 03/20] devlink: " Romain Perier
2021-02-23  0:56   ` Jakub Kicinski
2021-02-22 15:12 ` [PATCH 04/20] dma-buf: " Romain Perier
2021-02-22 15:12 ` [PATCH 05/20] kobject: " Romain Perier
2021-02-22 15:12 ` [PATCH 06/20] ima: " Romain Perier
2021-03-02 13:29   ` Mimi Zohar
2021-02-22 15:12 ` [PATCH 07/20] SUNRPC: " Romain Perier
2021-03-01 18:25   ` Chuck Lever
2021-02-22 15:12 ` [PATCH 08/20] kernfs: " Romain Perier
2021-02-22 15:12 ` [PATCH 09/20] m68k/atari: " Romain Perier
2021-02-22 15:12 ` [PATCH 10/20] module: " Romain Perier
2021-02-22 15:12 ` [PATCH 11/20] hwmon: " Romain Perier
2021-02-22 15:46   ` Guenter Roeck
2021-02-28 11:50     ` Joe Perches
2021-02-22 15:12 ` [PATCH 12/20] s390/hmcdrv: " Romain Perier
2021-02-22 15:12 ` [PATCH 13/20] scsi: zfcp: " Romain Perier
2021-02-22 16:04   ` Benjamin Block
2021-02-22 15:12 ` [PATCH 14/20] target: " Romain Perier
2021-02-22 16:00   ` Bodo Stroesser
2021-02-22 18:09   ` kernel test robot
2021-02-22 15:12 ` [PATCH 15/20] ALSA: usb-audio: " Romain Perier
2021-02-22 15:39   ` Takashi Iwai
2021-02-22 15:12 ` [PATCH 16/20] tracing/probe: " Romain Perier
2021-02-22 17:49   ` Steven Rostedt
2021-02-22 15:12 ` [PATCH 17/20] vt: " Romain Perier
2021-02-26  9:49   ` Jiri Slaby
2021-02-22 15:12 ` [PATCH 18/20] usb: gadget: f_midi: " Romain Perier
2021-02-22 15:12 ` [PATCH 19/20] usbip: usbip_host: " Romain Perier
2021-02-22 16:21   ` Shuah Khan
2021-02-28  9:03   ` Sergei Shtylyov
2021-02-22 15:12 ` [PATCH 20/20] s390/watchdog: " Romain Perier
2021-02-22 15:55   ` Guenter Roeck
2021-02-22 16:36 ` [PATCH 00/20] Manual replacement of all strlcpy in favor of strscpy Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YDUpqn+cRWg1ZYYT@blackbook \
    --to=mkoutny@suse.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=romain.perier@gmail.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).