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

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Aug 16 17:26:52 MSK 2022


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 debb9414d046..9d9491548260 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>
@@ -2919,8 +2920,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;
 }
-- 
2.37.1



More information about the Devel mailing list