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

Konstantin Khorenko khorenko at virtuozzo.com
Mon Aug 29 19:55:37 MSK 2022


The commit is pushed to "branch-rh9-5.14.0-70.13.1.vz9.16.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-70.13.1.vz9.16.10
------>
commit 90702e539f96c7afbbe78d96e2765918ab490b33
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 17acc14be173..6c10e857d34a 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -32,6 +32,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>
@@ -3125,8 +3126,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