lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 2 Jul 2020 13:20:43 +0800
From:   Weiping Zhang <zhangweiping@...iglobal.com>
To:     <mingo@...hat.com>, <peterz@...radead.org>,
        <juri.lelli@...hat.com>, <vincent.guittot@...aro.org>,
        <dietmar.eggemann@....com>, <rostedt@...dmis.org>,
        <bsegall@...gle.com>, <mgorman@...e.de>
CC:     <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH] proc: add support detach proccess's autogroup

Since setid will create a autogroup for that process, there is no
way to detach a process from that autogroup, this patch add a new interface
to detach a process from its autogroup. You can write anything to
/proc/<pid>/autogroup_detach to do that.

Signed-off-by: Weiping Zhang <zhangweiping@...iglobal.com>
---
 fs/proc/base.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index d86c0afc8a85..a210cab8b52d 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1541,6 +1541,55 @@ static const struct file_operations proc_pid_sched_autogroup_operations = {
 	.release	= single_release,
 };
 
+static int sched_autogroup_detach_show(struct seq_file *m, void *v)
+{
+	struct inode *inode = m->private;
+
+	seq_printf(m, "write any data to detach this task from a autogroup\n");
+
+	return 0;
+}
+
+static int sched_autogroup_detach_open(struct inode *inode, struct file *filp)
+{
+	int ret;
+
+	ret = single_open(filp, sched_autogroup_detach_show, NULL);
+	if (!ret) {
+		struct seq_file *m = filp->private_data;
+
+		m->private = inode;
+	}
+	return ret;
+}
+
+static ssize_t
+sched_autogroup_detach_write(struct file *file, const char __user *buf,
+	    size_t count, loff_t *offset)
+{
+	struct inode *inode = file_inode(file);
+	struct task_struct *p;
+	int ret;
+
+	p = get_proc_task(inode);
+	if (!p)
+		return -ESRCH;
+
+	sched_autogroup_detach(p);
+
+	put_task_struct(p);
+
+	return count;
+}
+
+static const struct file_operations proc_pid_sched_autogroup_detach_operations = {
+	.open		= sched_autogroup_detach_open,
+	.read		= seq_read,
+	.write		= sched_autogroup_detach_write,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 #endif /* CONFIG_SCHED_AUTOGROUP */
 
 #ifdef CONFIG_TIME_NS
@@ -3161,6 +3210,7 @@ static const struct pid_entry tgid_base_stuff[] = {
 #endif
 #ifdef CONFIG_SCHED_AUTOGROUP
 	REG("autogroup",  S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
+	REG("autogroup_detach",  S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_detach_operations),
 #endif
 #ifdef CONFIG_TIME_NS
 	REG("timens_offsets",  S_IRUGO|S_IWUSR, proc_timens_offsets_operations),
-- 
2.14.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ