[Devel] [PATCH RHEL COMMIT] VE/sysrq-trigger: make it VE-namespace aware

Konstantin Khorenko khorenko at virtuozzo.com
Fri Oct 1 19:38:37 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit c26713410b87310979034dc58892aa998725a113
Author: Stanislav Kinsbursky <skinsbursky at parallels.com>
Date:   Fri Oct 1 19:38:37 2021 +0300

    VE/sysrq-trigger: make it VE-namespace aware
    
    Logic inherited from rhel6: instead of doing something, echo passed command in
    container.
    
    https://jira.sw.ru/browse/PSBM-20664
    
    Signed-off-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
    
    ==========================
    Original comment:
    
    It's backport of patch:
    diff-ve-fake-sysrq-trigger-in-ct-20091002
    
    Patch from Konstantin Khorenko <khorenko at openvz.org>:
    provides /proc/sysrq-trigger file inside a Container -
    Oracle 11g Release 1 RAC needs this.
    
    Writing to the file inside a CT leads to nothing, first 10 writes are logged.
    
    https://bugzilla.sw.ru/show_bug.cgi?id=448149
    ==========================
    
    (cherry picked from vz7 commit 103e7fa4e8e182287162a202cbab188fdec8509f)
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    
    Cherry-picked from vz8 commit 579cc5b6f2f5 ("VE/sysrq-trigger: make it
    VE-namespace aware").
    
    Fix log limiting.
    
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 drivers/tty/sysrq.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 6628792431dc..be9b2a150e3c 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -51,6 +51,7 @@
 #include <linux/syscalls.h>
 #include <linux/of.h>
 #include <linux/rcupdate.h>
+#include <linux/ve.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq_regs.h>
@@ -1152,10 +1153,18 @@ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
 {
 	if (count) {
 		char c;
+		struct ve_struct *cur = get_exec_env();
+		static int pnum = 10;
 
 		if (get_user(c, buf))
 			return -EFAULT;
-		__handle_sysrq(c, false);
+		if (ve_is_super(cur))
+			__handle_sysrq(c, false);
+		else if (pnum > 0) {
+			printk("SysRq: CT#%s sent '%c' magic key.\n",
+				cur->ve_name, c);
+			pnum--;
+		}
 	}
 
 	return count;
@@ -1168,7 +1177,7 @@ static const struct proc_ops sysrq_trigger_proc_ops = {
 
 static void sysrq_init_procfs(void)
 {
-	if (!proc_create("sysrq-trigger", S_IWUSR, NULL,
+	if (!proc_create("sysrq-trigger", S_ISVTX | S_IWUSR, NULL,
 			 &sysrq_trigger_proc_ops))
 		pr_err("Failed to register proc interface\n");
 }


More information about the Devel mailing list