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

Konstantin Khorenko khorenko at virtuozzo.com
Fri Oct 2 18:19:13 MSK 2020


The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.11
------>
commit a4534c36188448fdd9d55dfbc06e28dbc4ae1637
Author: Stanislav Kinsbursky <skinsbursky at parallels.com>
Date:   Wed Dec 18 13:11:04 2013 +0400

    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>
---
 drivers/tty/sysrq.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 22973a5c59a2..40544af4d36f 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -50,6 +50,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>
@@ -1105,10 +1106,16 @@ 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--)
+			printk("SysRq: CT#%s sent '%c' magic key.\n",
+				cur->ve_name, c);
 	}
 
 	return count;
@@ -1121,7 +1128,7 @@ static const struct file_operations proc_sysrq_trigger_operations = {
 
 static void sysrq_init_procfs(void)
 {
-	if (!proc_create("sysrq-trigger", S_IWUSR, NULL,
+	if (!proc_create("sysrq-trigger", S_ISVTX | S_IWUSR, NULL,
 			 &proc_sysrq_trigger_operations))
 		pr_err("Failed to register proc interface\n");
 }


More information about the Devel mailing list