mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KeMeng Shi <shikemeng@huawei.com>
To: <akpm@linux-foundation.org>, <james.morris@microsoft.com>,
	<gregkh@linuxfoundation.org>, <mortonm@chromium.org>,
	<will.deacon@arm.com>, <kristina.martsenko@arm.com>,
	<yuehaibing@huawei.com>, <malat@debian.org>,
	<j.neuschaefer@gmx.net>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] connector: report comm change event when modifying /proc/pid/task/tid/comm
Date: Mon, 16 Sep 2019 10:13:41 -0400	[thread overview]
Message-ID: <20190916141341.658-1-shikemeng@huawei.com> (raw)

Commit f786ecba41588 ("connector: add comm change event report to proc
 connector") added proc_comm_connector to report comm change event, and
prctl will report comm change event when dealing with PR_SET_NAME case.

prctl can only set the name of the calling thread. In order to set the name
of other threads in a process, modifying /proc/self/task/tid/comm is a
general way.It's exactly how pthread_setname_np do to set name of a thread.

It's unable to get comm change event of thread if the name of thread is set
by other thread via pthread_setname_np. This update provides a chance for
application to monitor and control threads whose name is set by other
threads.

Signed-off-by: KeMeng Shi <shikemeng@huawei.com>
---
 fs/proc/base.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index ebea9501afb8..34ffe572ac69 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -94,6 +94,7 @@
 #include <linux/sched/debug.h>
 #include <linux/sched/stat.h>
 #include <linux/posix-timers.h>
+#include <linux/cn_proc.h>
 #include <trace/events/oom.h>
 #include "internal.h"
 #include "fd.h"
@@ -1549,10 +1550,12 @@ static ssize_t comm_write(struct file *file, const char __user *buf,
 	if (!p)
 		return -ESRCH;
 
-	if (same_thread_group(current, p))
+	if (same_thread_group(current, p)) {
 		set_task_comm(p, buffer);
-	else
+		proc_comm_connector(p);
+	} else {
 		count = -EINVAL;
+	}
 
 	put_task_struct(p);
 
-- 
2.19.1


             reply	other threads:[~2019-09-16 14:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16 14:13 KeMeng Shi [this message]
2019-09-16 21:10 ` Will Deacon
2019-09-17  2:36   ` KeMeng Shi
2019-09-17 13:56   ` KeMeng Shi
2019-09-17 17:07     ` Will Deacon
2019-09-19  2:43       ` KeMeng Shi
2019-09-19 20:07         ` Andrew Morton

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=20190916141341.658-1-shikemeng@huawei.com \
    --to=shikemeng@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=j.neuschaefer@gmx.net \
    --cc=james.morris@microsoft.com \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malat@debian.org \
    --cc=mortonm@chromium.org \
    --cc=will.deacon@arm.com \
    --cc=yuehaibing@huawei.com \
    /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

all inboxes | Powered by JetHome®