Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4668306ybe; Mon, 16 Sep 2019 16:39:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjTIpMJmYXDdGlcOCfOHGGqyDgKZlNPhRdIu8PwHVKFApAcjhWWj1oyVxOnoa84vDzG+AI X-Received: by 2002:a17:906:e2d8:: with SMTP id gr24mr2258888ejb.55.1568677160063; Mon, 16 Sep 2019 16:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568677160; cv=none; d=google.com; s=arc-20160816; b=xvX3BjIBOcL3mNDAFPCUn4TW0BoWKNGBDDI0Bu2ZEKXfE+eP8NspExFLX1d7BWxMmK akwgfByd97xJoMUcTnI1GnebvbnWq509qKQkBrYov7QJ24Jle4R8Djr7AUCMS4i710o2 pgjdTqqVvO3H4JWirIka/HZLt7kWEWXt4Ale90f735yU4bg0M2kyz8ZTIZBEkywXlADG EX7vkLsYmCHUwAGtEsBQF35XQL2/R7bI3FOXduvQJV2YJ4A7fH75knbH9ozu77rPo2Sq 766v4X8uHv5rMQHyhcm97cRjV93QEoKrwylBr7eFLH3B0emkWtlba75F78pzLrMTEfsA ROwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=LPELyuoqFJ7sWI0S/7vyVXSAMKY/SEDQegtymGUrZHE=; b=GNof3MgjCD0bvei2Ui0q8ZU0Br2qN60qbYViw7ZYuz8pfSwfAF5wsGbCVl9tkHrugk jMg7FiP/gG3jNmAT+1p4OdovkvjBtQVAQasmWHwI5FEmIrPxExeSYJThEny3yyh+hOuU xjl/WyXbvAGkVKcS2bX2iATW3HY89K0wuaboHLUCBgIZbyVLYahonnoNVxbUeql1JtYt /YAvW8PNAQu56pxJUvhFif/vuxwKWB+rG9Ps5Kts5rhPRagZTpuQehthfIPmxFy6GsRB Ql3Pk+Dia/Jjzr1BvQbABZYdFgCbqC1ja2cBaWKxXFcTenjSLYOLCs5ZQ/uXrUzEL1wX JcnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21si350304edq.65.2019.09.16.16.38.56; Mon, 16 Sep 2019 16:39:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbfIPONy (ORCPT + 99 others); Mon, 16 Sep 2019 10:13:54 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2274 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726821AbfIPONy (ORCPT ); Mon, 16 Sep 2019 10:13:54 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0BE2813160E462C8145A; Mon, 16 Sep 2019 22:13:52 +0800 (CST) Received: from huawei.com (10.175.104.232) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Mon, 16 Sep 2019 22:13:45 +0800 From: KeMeng Shi To: , , , , , , , , CC: Subject: [PATCH] connector: report comm change event when modifying /proc/pid/task/tid/comm Date: Mon, 16 Sep 2019 10:13:41 -0400 Message-ID: <20190916141341.658-1-shikemeng@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.232] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 #include #include +#include #include #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