[Devel] [PATCH RHEL7 COMMIT] sunrpc: print debug info for kill-tasks

Konstantin Khorenko khorenko at virtuozzo.com
Mon Aug 29 19:53:41 MSK 2022


The commit is pushed to "branch-rh7-3.10.0-1160.76.1.vz7.189.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.76.1.el7
------>
commit 0f4d01ce1e399eee73f1e0eccf8827df36e867ea
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Tue Aug 16 17:26:52 2022 +0300

    sunrpc: print debug info for kill-tasks
    
    We see that userspace can by accident kill-tasks in network namespaces
    not belonging to the container it desires to kill, so to make easier the
    debug of such cases let's print some info in dmesg.
    
    https://jira.sw.ru/browse/PSBM-141604
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 net/sunrpc/clnt.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 4aebe8a78bc0..c5947dd6a0a5 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -31,6 +31,7 @@
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/un.h>
+#include <linux/ve.h>
 
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/addr.h>
@@ -2922,8 +2923,16 @@ static ssize_t write_kill_tasks(struct file *file, const char __user *buf,
 	sn->kill_tasks = !!kill_tasks;
 
 	/* Kill pending tasks */
-	if (sn->kill_tasks && !prev_kill_tasks)
+	if (sn->kill_tasks && !prev_kill_tasks) {
 		rpc_kill_tasks(net);
+		pr_info_ratelimited(
+			"kill-tasks: by task (%s:%d) in net:[%u]%s\n",
+			current->comm, current->pid, net->ns.inum,
+#ifdef CONFIG_VE
+			net->owner_ve == &ve0 ? "(host)" :
+#endif
+			"");
+	}
 
 	return count;
 }


More information about the Devel mailing list